I was wondering what the "best" way to set a bit in a variable declared in the bit addressable area. Originally I declared each bit as an sbit and therefore can set and clear them as follows
uint8_t bdata status ; sbit enable = staus ^ 0 ; enable = 1 ; enable = 0 ;
#define ENABLE 0x01 uint8_t bdata status ; status |= ENABLE ; status &= ~ENABLE ;
"Personally, I would always go for the first method as it is so much clearer." (my emphasis) I agree, although the OP thinks the opposite! "The only down-side is that the first method it is absolutly non-portable." But it can (I say should) be encapsulated in a macro, so that porting is simply a matter of suitably redefining the macro. Similarly for all other compiler-specifics. "The compiler will generate quite different code in each case." Absolutely. Why would Keil bother to dream up this special syntax if it made no difference?!