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

Back to Subject List

Old thread has been locked -- no new posts accepted in this thread
???
06/22/09 13:16
Read: times


 
#166346 - "bit" is more useful
Responding to: ???'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            01/01/70 00:00      
   doesn't SDCC warn about line 36?            01/01/70 00:00      
      that's it            01/01/70 00:00      
         ah ha            01/01/70 00:00      
            Don't blame the optimiser!            01/01/70 00:00      
      doesn't SDCC warn about line 36            01/01/70 00:00      
         hmmm            01/01/70 00:00      
         modified dog            01/01/70 00:00      
   I cannot remember now            01/01/70 00:00      
   xmt_flag., why "int"?            01/01/70 00:00      
      if you want to use it as "int" / "char"            01/01/70 00:00      
   You destroy succeding putchar()'s            01/01/70 00:00      
      "Volatile" Helps            01/01/70 00:00      
         "bit" is more useful            01/01/70 00:00      
            buzzzzz            01/01/70 00:00      
               family            01/01/70 00:00      
            stdbool            01/01/70 00:00      

Back to Subject List