Addressing Modes: Department of EIE / Pondicherry Engineering College
Addressing Modes: Department of EIE / Pondicherry Engineering College
Addressing Modes: Department of EIE / Pondicherry Engineering College
ADDRESSING MODES
ADDRESSING MODES
There are a number of addressing modes available to the 8051 instruction set, as follows:
Immediate Addressing
Indirect Addressing
Long Addressing
Register Addressing
Relative Addressing
Indexed Addressing
Direct Addressing
Absolute addressing
Immediate Addressing
Immediate addressing simply means that the operand (which immediately follows the
instruction op. code) is the data value to be used. For example the instruction:
MOV A, #99d
Accumulator
number 99d
Moves the value 99 into the accumulator (note this is 99 decimal since we used 99d). The
# symbol tells the assembler that the immediate addressing mode is to be used.
Register Addressing
One of the eight general-registers, R0 to R7, can be specified as the instruction operand.
The assembly language documentation refers to a register generically as Rn. An example
instruction using register addressing is :
ADD A, R5
Accumulator
48h
47h
46h
The instruction reads the data from Internal RAM address 47h and stores this in the
accumulator. Direct addressing can be used to access Internal RAM , including the SFR
registers.
Indirect Addressing
Indirect addressing provides a powerful addressing capability, which needs to be
appreciated. An example instruction, which uses indirect addressing, is as follows:
MOV A, @R0
Internal RAM
Accumulator
55h
54h
53h
R0
54h
Note the @ symbol indicated that the indirect addressing mode is used. R0 contains a
value, for example 54h, which is to be used as the address of the internal RAM location,
which contains the operand data. Indirect addressing refers to Internal RAM only and
cannot be used to refer to SFR registers.
Note, only R0 or R1 can be used as register data pointers for indirect addressing when
using MOV instructions.
The 8052 (as opposed to the 8051) has an additional 128 bytes of internal RAM. These
128 bytes of RAM can be accessed only using indirect addressing.
Relative Addressing
This is a special addressing mode used with certain jump instructions. The relative
address, often referred to as an offset, is an 8-bit signed number, which is automatically
added to the PC to make the address of the next instruction. The 8-bit signed offset value
gives an address range of + 127 to 128 locations. Consider the following example:
SJMP LABEL_X
Code
Memory
2006h
2005h
2004h
2003h
2002h
2001h
2000h
1FFFh
SJMP
LABEL_X
and the accumulator value us referred to as the index address. An example program using
the indexed addressing mode will be shown later.