Addressing Modes of 8051
Addressing Modes of 8051
in
8051 MC
S. Lourduraj
Asst. Prof. of Physics
St. Joseph’s College.
Addressing Mode MC 8051
Method of specifying the data to be operated by the instruction
P1(80H),
P1(90H),
P2(A0H),
P3(B0H) &
PSW(D0H)
PSW(D0H)
3. Register Indirect Addressing mode
A register is used to hold the effective address of the operand.
This register, which holds the address, is called the
Pointer register and is said to point to the operand.
Only registers R0, R1 and DPTR can be used as pointer
registers.
R0 and R1 registers can hold an 8-bit address where as
DPTR can hold a 16-bit address.
DPTR is useful in accessing operands which are in
the
external memory.
3. Indirect Addressing mode (cont’d)
Examples:
MOV @ R0, A ;Store the content of accumulator into the memory location pointed
to by the contents of register R0. R0 could have an 8-bit
address, such as 60H.
Eg:
MOV P1, #0xFF H Let P1: 0000 0100b (OR) 04 H
MOV A, P1 A = 04H
MOV R0, # 050H R0 = 50 H
MOV @R0, A Add. of Memory
0050 H = ------
MOV A, @R0 A = ---H
Examples:
MOV DPTR, #0FE00 H ;Move 16-bit data constant FE00H into the
16-bit Data Pointer Register.
4. Immediate Addressing mode (cont’d)
Examples:
After the execution of the above instructions, the program will branch to address
1F08H (1F00H+08H) and transfer into the accumulator the data byte retrieved
from that location (from the look-up table)
ORG 0000
MOV DPTR, #200H
CLR A
MOVC A, @A+DPTR ORG 0200H
MOV R0,A
MY DATA: DB “ SLR”
INC DPTR END.
CLR A
MOVC A,@A+DPTR
MOV R1, A
INCR DPTR
CLR A
MOVC A,@A+DPTR
MOV R2, A
HERE:
SJMP HERE
Program to understand the concept of LOOK –UP table with INDEXED ADDRESSING MODE
ORG 0000
MOV DPTR, #300H MEMORY 307CONTENTS
LOCATIONS IN
MOV A, #0FFH ROM
MOV P1, A 300 00
BACK: 301 01
MOV A, P1 302 04
MOVC A, @A+DPTR 303 09
MOV P2 ,A 304 10 Equivalent to 16
SJMP BACK 305 19 Equivalent to 25
306 24 Equivalent to 36