tags:

views:

44

answers:

2

Hello,

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?

A: 

P0.0 and P0.1 only refers to individual bits of the 8-bit P0 register (from what I understand).

leppie
Yup, but if they are bit addressable, they will have an address eventually.
Grissiom
+1  A: 

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

mocj
Thanks very much for your explanation. It true for SFRs. But what if `SETB 01h`? It should be byte address #20 and bit #1. May I say that bit addressable memory and byte addressable memory are in different memory space that can be handled by hardware(or introductions) automatically?
Grissiom
Yes, as you noted, the procedure is the same for non-SFRs (addresses < 80h) except there is an additional offset of 20h added to the byte address. Instructions will handle the addressing internally but, be careful thinking of them as 'different' memory spaces, they do overlap. SETB 01h will set the #1 bit in memory location 20h. This can be overwritten by a byte addressable MOV instruction that targets address 20h. MOV 20h,00h. This will clear bit addresses 00h to 07h. Programmer beware ;)
mocj