
Site Search
SECTION III - ADDRESSES OF SPECIAL FUNCTION REGISTERS IN 8051
SECTION III - ADDRESSES OF SPECIAL FUNCTION REGISTERS IN 8051
'B' register, 'A' register, 'PSW' register and 'DPTR' register as discussed in previous sections also have addresses. these registers are 'Special Function Registers' or 'SFR'. There are many other special function registers widely used. The special function registers have their names through which SPF can be accessed by their names or by their addresses. Register 'A' has address 'E0H' and register 'B' has address 'F0H'. The SFR table is listed below showing addresses and names:
Special Function Registers [SFR] Addresses:
SYMBOL | NAME | ADDRESS | BIT / BYTE ADDRESSABLE |
---|---|---|---|
ACC | Accumulator | 0E0H | BIT addressable |
B | B Register | 0F0H | BIT addressable |
PSW | Program Status Word | 0D0H | BIT addressable |
SP | Stack Pointer | 81H | BYTE addressable |
DPTR | Data Pointer [2 bytes] | ||
DPL | Data Pointer Low Byte | 82H | BYTE addressable |
DPH | Data Pointer High Byte | 83H | BYTE addressable |
P0 | Port 0 | 80H | BIT addressable |
P1 | Port 1 | 90H | BIT addressable |
P2 | Port 2 | 0A0H | BIT addressable |
P3 | Port 3 | 0B0H | BIT addressable |
IP | Interrupt Priority Control | 0B8H | BIT addressable |
IE | Interrupt Enable Control | 0A8H | BIT addressable |
TMOD | Timer/Counter Mode Control | 89H | BYTE addressable |
TCON | Timer/Counter Control | 88H | BIT addressable |
T2CON | Timer/COunter 2 Control | 0C8H | BIT addressable |
T2MOD | Timer/Counter Mode Control | 0C9H | BYTE addressable |
TH0 | Timer/Counter 0 High Byte | 8CH | BYTE addressable |
TL0 | Timer/Counter 0 Low Byte | 8AH | BYTE addressable |
TH1 | Timer/Counter 1 High Byte | 8DH | BYTE addressable |
TL1 | Timer/Counter 1 Low Byte | 8BH | BYTE addressable |
TH2 | Timer/Counter 2 High Byte | 0CDH | BYTE addressable |
TL2 | Timer/Counter 2 Low Byte | 0CCH | BYTE addressable |
RCAP2H | Timer/Counter 2 Capture Register High Byte | 0CBH | BYTE addressable |
RCAP2L | Timer/Counter 2 Capture Register Low Byte | 0CAH | BYTE addressable |
SCON | Serial Control Register | 98H | BIT addressable |
SBUF | Serial Data Buffer Register | 99H | BYTE addressable |
PCON | Power Control | 87H | BYTE addressable |
The special function registers SFR has addresses between 80H and FFH. The addresses 00 to 7FH are addresses of RAM memory inside the 8051. There are some unused locations between 80H to FFH. These are reserved and must not be used by the 8051 programmer.
The pairs of instructions given below are the same thing:
MOV 0E0H, #AAH | ;is same as the instruction given below |
---|---|
MOV A, #AAH | ;Load value AAH into accumulator A i.e A=AAH |
MOV 0F0H, #24H | ;is same as the instruction given below |
MOV B, #24H | ;Load value 24H into B register i.e B=24H |
MOV 0E0H, #R1 | ;is same as the instruction given below |
MOV A, #R1 | ;Load value of R1 into accumulator A i.e A=R1 |
MOV 0F0H, #R7 | ;is same as the instruction given below |
MOV B, R7 | ;Load value of R7 into register B i.e B=R7 |
Example # 1:
Lets write a code to send 55H to Port 2 and Port 3 by using their original names and by using their addresses:
By Using their Names:
MOV A, #55H | ;Load 55H into accumulator register A |
---|---|
MOV P2, A | ;Send 55H value to Port 2 |
MOV P3, A | ;Send 55H value to Port 3 |
By Using their Addresses:
MOV 0E0H, #55H | ;Load 55H into accumulator A [0E0H accumulator address] |
---|---|
MOV 0A0H, 0E0H | ;Send 55H value to Port 2 [0A0H port2 address] |
MOV 0B0H, 0E0H | ;Send 55H value to Port3 [0B0H port3 address] |