Email: Password: Remember Me | Create Account (Free)

Back to Subject List

Old thread has been locked -- no new posts accepted in this thread
Mahesh Joshi
06/22/09 08:16
Read: 195 times
Mumbai
India


 
#166346 - "bit" is more useful
Responding to: Girish Nikam's previous message
Dear Girish,

It is good that your code is now working by use of "volatile"

But, remember you are working with MCS51 fly. This fly supports a veriety of bit operation. Try to take advantage of it.

If the variable is going to assume only 2 values (True & False), I would prefer declaring it as "bit".

Using "int" or "char" (signed or unsigned) instead of bit is OK, but it increases code as well as RAM memory required by program. (Your current example may not need it, but in future this can verywell help you)

Also execution time increases due to integer operations.

just for example:
int my_int;
my_int = 0;

asm generated will be something like this
 mov dptr,#_my_int
clr a
movx @dptr,a
inc dptr
movx @dptr,a


on other hand if you use bit
bit my_bit
my_bit = 0;

the asm generated would be something like
 clr _my_bit


Regards,
Mahesh

List of 17 messages in thread
TopicAuthorDate
UART code porting to SDCC      Girish Nikam      06/21/09 13:29      
   doesn't SDCC warn about line 36?      Frieder Ferlemann      06/21/09 13:59      
      that's it      Jan Waclawek      06/21/09 15:03      
         ah ha      Jez Smith      06/21/09 15:08      
            Don't blame the optimiser!      Andy Neil      06/22/09 01:36      
      doesn't SDCC warn about line 36      Girish Nikam      06/21/09 22:13      
         hmmm      Jez Smith      06/22/09 00:42      
         modified dog      Andy Peters      06/23/09 14:21      
   I cannot remember now      Jez Smith      06/21/09 14:33      
   xmt_flag., why "int"?      Mahesh Joshi      06/22/09 01:53      
      if you want to use it as "int" / "char"      Andy Neil      06/22/09 02:47      
   You destroy succeding putchar()'s      David Prentice      06/22/09 05:14      
      "Volatile" Helps      Girish Nikam      06/22/09 07:42      
         "bit" is more useful      Mahesh Joshi      06/22/09 08:16      
            buzzzzz      Erik Malund      06/22/09 08:37      
               family      Jan Waclawek      06/22/09 13:44      
            stdbool      Oliver Sedlacek      06/23/09 06:44      

Back to Subject List