Why some sfr in 8051 are bit addressable?

advertisements

According to this: http://www.8052.com/tutsfr.php , the sfrs whose address are divisible by 8 are bit addressable. You can do things like SETB or CLR on them. But aren't they overlap other memory addresses? I mean, for example, P0 is in 80h. So P0.0 will be 80h, P0.1 will be 81h. But 81h is the address of SP. Aren't they overlap?


You are confusing a bit address with a byte address. They do not overlap or refer to the same physical location. Instructions that take bit addresses (eg. SETB) know how to decode the bit address into a byte address and bit number. The byte address is obtained by masking out the 3 lowest bits in the bit address. The bit number is obtained by masking out the highest 5 bits.

eg. bit address 87h --> byte address 80h, bit #7