2. What is an Addressing Mode?
• An Addressing Mode is a way to locate a target Data,
which is also called as Operand.
• The 8051 Family of Microcontrollers allows five types of
Addressing Modes for addressing the Operands. They
are:
• Immediate Addressing
• Register Addressing
• Direct Addressing
• Register – Indirect Addressing
• Indexed Addressing
3. Immediate Addressing
• In Immediate Addressing mode, the operand, which follows the Opcode, is a
constant data of either 8 or 16 bits.
• The constant value to be stored is specified in the instruction itself rather than
taking from a register.
• The destination register to which the constant data must be copied should be the
same size as the operand mentioned in the instruction.
Example: MOV A, #030H
Explanation: Here, the Accumulator is loaded with 30 (hexadecimal).
The # in the operand indicates that it is a data and not the address of a Register.
• Immediate Addressing is very fast as the data to be loaded is given in the
instruction itself.
4. Register Addressing
• In the 8051 Microcontroller Memory Organization Tutorial, we have seen
the organization of RAM and four banks of Working Registers with eight
Registers in each bank.
• In Register Addressing mode, one of the eight registers (R0 – R7) is
specified as Operand in the Instruction.
Example: MOV A, R5
Explanation: Here, the 8-bit content of the Register R5 of Bank0 is
moved to the Accumulator
Note: It is important to select the appropriate Bank with the help
of PSW Register.
5. Direct Addressing
• In Direct Addressing Mode, the address of the data is specified as
the Operand in the instruction.
• Using Direct Addressing Mode, we can access any register or on-
chip variable.
• This includes general purpose RAM, SFRs, I/O Ports, Control
registers.
Example: MOV A, 47H
• Explanation: Here, the data in the RAM location 47H is
moved to the Accumulator.
6. Register Indirect Addressing
• In the Indirect Addressing Mode or Register Indirect Addressing Mode,
the address of the Operand is specified as the content of a Register.
Example: MOV A, @R1
Explanation :
The @ symbol indicates that the addressing mode is indirect.
If the contents of R1 is 56H,
For example, then the operand is in the internal RAM location 56H.
If the contents of the RAM location 56H is 24H, then 24H is move into
accumulator.
• Only R0 and R1 are allowed in Indirect Addressing Mode. These
register in the indirect addressing mode are called as Pointer registers.
7. Indexed Addressing Mode
• With Indexed Addressing Mode, the effective address of the Operand is the sum of a base
register and an offset register.
• The Base Register can be either Data Pointer (DPTR) or Program Counter (PC) while the Offset
register is the Accumulator (A).
• In Indexed Addressing Mode, only MOVC and JMP instructions can be used.
• Indexed Addressing Mode is useful when retrieving data from look-up tables.
Example: MOVC A, @A+DPTR
Explanation : Here, the address for the operand is the sum of contents of DPTR and Accumulator.
NOTE: Some authors and textbooks add few other Addressing Modes like Absolute
Addressing Mode, Relative Addressing Mode and Long Addressing Mode.