We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 5
8051
Addressing modes of 8051
• Immediate addressing mode • Register addressing mode • Direct addressing mode • Register indirect addressing mode • Indexed addressing mode • Immediate addressing mode: MOV A,#25H ;load 25H into A MOV R4,#62 ;load 62 into R4 MOV B,#40H ;load 40H into B MOV DPTR,#4521H ;DPTR=4512H MOV DPL,#21H ;This is the same MOV DPH,#45H ;as above
• Register addressing mode
MOV A,R0 ;copy contents of R0 into A MOV R2,A ;copy contents of A into R2
ADD A,R5 ;add contents of R5 to A MOV DPTR,A will give an error
ADD A,R7 ;add contents of R7 to A MOV R6,A ;save accumulator in R6
• Direct addressing mode
MOV R0,40H ;save content of 40H in R0 MOV 56H,A ;save content of A in 56H • Register indirect addressing mode A register is used as a pointer to the data Only register R0 and R1 are used for this purpose R2 – R7 cannot be used to hold the address of an operand located in RAM When R0 and R1 hold the addresses of RAM locations, they must be preceded by the “@” sign ✔ MOV A,@R0 ;move contents of RAM whose address is held by R0 into A ✔ MOV @R1,B ;move contents of B into RAM whose address is held by R1
•Indexed addressing mode
Indexed addressing mode is widely used in accessing data elements of look-up table entries located in the program ROM The instruction used for this purpose is MOVC A,@A+DPTR Use instruction MOVC, “C” means code The contents of A are added to the 16-bit register DPTR to form the 16-bit address of the needed data