The 8051 provides a total of five distinct addressing modes.

  1. immediate
  2. register
  3. direct
  4. register indirect
  5. indexed

1. Immediate Addressing Mode

  • The operand comes immediately after the op-code.
  • The immediate data must be preceded by the pound sign, "#".

2. Register Addressing Mode

  • Register addressing mode involves the use of registers to hold the data to be manipulated

3. Direct Addressing Mode

  • It is most often used to access RAM locations 30 - 7FH.
  • This is due to the fact that register bank locations are accessed by the register names of R0 - R7.
  • There is no such name for other RAM locations so must use direct addressing
  • In the direct addressing mode, the data is in a RAM memory location whose address is known, and this address is given as a part of the instruction

4. Register Indirect Addressing Mode

  • A register is used as a pointer to the data.
  • If the data is inside the CPU, only registers R0 and R 1 are used for this purpose.
  • R2 - R7 cannot be used to hold the address of an operand located in RAM when using indirect addressing mode.
  • When RO and R 1 are used as pointers they must be preceded by the @ sign.

5. Indexed Addressing Mode

  • Indexed addressing mode is widely used in accessing data elements of look-up table entries located in the program ROM space of the 8051.
  • The instruction used for this purpose is : MOVC A, @ A+DPTR
  • The 16-bit register DPTR and register A are used to form the address of the data element stored in on-chip ROM.
  • Because the data elements are stored in the program (code) space ROM of the 8051, the instruction MOVC is used instead of MOV. The "C" means code.
  • In this instruction the contents of A are added to the 16-bit register DPTR to form the 16- bit address of the needed data