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

Back to Subject List

Old thread has been locked -- no new posts accepted in this thread
???
03/30/08 12:59
Read: times


 
#152710 - SFR as a byte or bit address
Responding to: ???'s previous message
Some mcs51 opcodes address a byte like SBUF.
Other opcodes address a bit like SCON.1

The hex that is generated is 0x99 for either operand. However the preceding opcode has told the mcs51 which type of operand it needs for the particular opcode.

e.g. SETB SCON.1 // bit
e.g. PUSH SBUF // byte

You will notice that the only byte registers that will accept bit addressing have addresses like 0bxxxxx000.

If you try doing the wrong thing in ASM, you will get told off.
If you write in C, then the compiler looks after this sort of thing. Certain important SFRs have names for the bit-addressable bits. If there is no name in the header file, then it is probably not bit-addressable. So you have to use var |= (1<<x); construction.

The exception to this rule is that Ports P0, P1, P2, P3 are bit-addressable. ( and all the regular (non-special-function) registers )

David

List of 6 messages in thread
TopicAuthorDate
SFR question            01/01/70 00:00      
   Address Spaces            01/01/70 00:00      
   SFR as a byte or bit address            01/01/70 00:00      
      what exception            01/01/70 00:00      
         Same value - different address            01/01/70 00:00      
            SFR's and bit Addressable SFR's            01/01/70 00:00      

Back to Subject List