Various Addressing Modes of 8051 Microcontroller

Various Addressing Modes of 8051 Microcontroller

Verified Sources
May 21, 2026

The 8051 microcontroller supports multiple addressing modes so that instructions can access registers, internal RAM, special function registers, and program memory efficiently. In short notes, addressing modes describe how the operand is identified rather than what operation is performed.2

For the 8051, the most commonly taught data-access modes are immediate, register, direct, register indirect, and indexed.2 In a broader instruction-set view, the architecture also uses relative, absolute, and long addressing for branch instructions. Understanding these modes is essential because the same mnemonic such as MOV behaves differently depending on how the operand is addressed.

A useful way to classify them is shown below:

In assembly notation, symbols often indicate the addressing style:

  • #data → immediate operand
  • Rn → register operand
  • direct → direct byte address
  • @R0, @R1, @DPTR → indirect operand
  • @A+DPTR, @A+PC → indexed access to code memory2

Footnotes

  1. 8051 Microcontroller Addressing Modes | JunctionByte - Explains immediate, register, direct, register indirect, and indexed modes with examples. 2 3

  2. 8051 Instruction Set - Silicon Labs - Instruction-set overview including register, direct, indirect, immediate, relative, absolute, long, and indexed addressing. 2 3

  3. [PDF] UNIT – 4 8051 MICROCONTROLLER Architecture - WordPress.com - Academic notes summarizing the main five 8051 addressing modes and examples.

  4. Addressing modes of 8051 - TutorialsPoint - Provides concise descriptions and sample instructions for core 8051 addressing modes.

Addressing Modes of 8051 Microcontroller: Immediate, Register, Direct, Indirect, and Indexed

Exam-Oriented View

In many university short-note questions, the expected core modes are immediate, register, direct, register indirect, and indexed. Some advanced notes also include relative, absolute, and long modes for branching.2

Footnotes

  1. 8051 Instruction Set - Silicon Labs - Instruction-set overview including register, direct, indirect, immediate, relative, absolute, long, and indexed addressing.

  2. [PDF] UNIT – 4 8051 MICROCONTROLLER Architecture - WordPress.com - Academic notes summarizing the main five 8051 addressing modes and examples.

1. Immediate Addressing Mode

In immediate addressing, the data is supplied directly inside the instruction. The operand is preceded by the # symbol, indicating that the given value is a constant and not a memory address.2

Examples:

1MOV A, #25H 2MOV R3, #45H 3MOV DPTR, #8245H 4ADD A, #10H

Explanation:

  • MOV A, #25H loads the accumulator with hexadecimal 25.
  • MOV DPTR, #8245H places a 16-bit constant into the DPTR register pair.2

Key features:

  • Fast and simple for loading constants.
  • No extra memory lookup is needed for the operand value.
  • Useful for initialization of registers, counters, masks, and fixed constants.

This mode is ideal when the programmer already knows the operand value at assembly time.

Footnotes

  1. [PDF] UNIT – 4 8051 MICROCONTROLLER Architecture - WordPress.com - Academic notes summarizing the main five 8051 addressing modes and examples. 2 3

  2. [PDF] ADDRESSING MODES - Pondicherry Engineering College - Notes on immediate, direct, indirect, relative, absolute, long, and indexed addressing in 8051. 2

2. Register Addressing Mode

In register addressing, the operand is stored in one of the working registers such as R0 to R7, or in some cases accumulator-oriented registers like A or B depending on the instruction.2

Examples:

1MOV A, R5 2MOV R2, A 3ADD A, R1

Explanation:

  • MOV A, R5 copies the contents of register R5 into accumulator A.
  • ADD A, R1 adds the contents of R1 to the accumulator.2

Important points:

  • R0 to R7 belong to the currently selected register bank.
  • Register addressing is compact and efficient because registers are internal to the CPU.
  • It usually gives shorter and faster code than memory-based addressing.

This mode is preferred for temporary data and arithmetic operations.

Footnotes

  1. 8051 Microcontroller Addressing Modes | JunctionByte - Explains immediate, register, direct, register indirect, and indexed modes with examples. 2

  2. Addressing modes of 8051 - TutorialsPoint - Provides concise descriptions and sample instructions for core 8051 addressing modes. 2 3

  3. 8051 Instruction Set - Silicon Labs - Instruction-set overview including register, direct, indirect, immediate, relative, absolute, long, and indexed addressing.

3. Direct Addressing Mode

In direct addressing, the instruction specifies the exact 8-bit address of the operand.2

Examples:

1MOV A, 30H 2MOV 40H, A 3MOV 90H, A

Explanation:

  • MOV A, 30H loads the accumulator with the byte stored at internal RAM address 30H.
  • MOV 40H, A stores the accumulator value into internal RAM location 40H.
  • Addresses from 80H to FFH can refer to SFRs in direct addressing.2

Characteristics:

  • Used for internal RAM locations and SFRs.
  • The address appears directly in the instruction.
  • Convenient for fixed variables and control registers.2

A major advantage is clarity: the programmer can directly access a known RAM or SFR location without using an intermediate pointer.

Footnotes

  1. 8051 Microcontroller Addressing Modes | JunctionByte - Explains immediate, register, direct, register indirect, and indexed modes with examples. 2 3

  2. [PDF] UNIT – 4 8051 MICROCONTROLLER Architecture - WordPress.com - Academic notes summarizing the main five 8051 addressing modes and examples. 2

  3. 8051 Instruction Set - Silicon Labs - Instruction-set overview including register, direct, indirect, immediate, relative, absolute, long, and indexed addressing.

Common Confusion

In 8051 assembly, MOV A, #30H means load the constant 30H, while MOV A, 30H means load the byte stored at address 30H. The presence or absence of # completely changes the meaning.2

Footnotes

  1. [PDF] UNIT – 4 8051 MICROCONTROLLER Architecture - WordPress.com - Academic notes summarizing the main five 8051 addressing modes and examples.

  2. [PDF] ADDRESSING MODES - Pondicherry Engineering College - Notes on immediate, direct, indirect, relative, absolute, long, and indexed addressing in 8051.

4. Register Indirect Addressing Mode

In register indirect addressing the instruction refers to a register that contains the address of the data rather than the data itself.2

Examples:

1MOV A, @R0 2MOV @R1, A 3MOVX A, @DPTR 4MOVX @DPTR, A

Explanation:

  • In MOV A, @R0, the 8051 first reads the address stored in R0, then fetches the data from that RAM location into A.
  • Only R0 and R1 can be used for indirect addressing of internal RAM in classic 8051 instructions.2
  • External data memory access commonly uses MOVX with @DPTR or sometimes @R0/@R1 depending on the instruction form.2

Characteristics:

  • Useful for arrays, buffers, and pointer-based traversal.
  • More flexible than direct addressing because the effective address can change during execution.
  • Essential when looping through memory locations.2

This mode is analogous to pointer-based memory access in higher-level programming.

Footnotes

  1. 8051 Microcontroller Addressing Modes | JunctionByte - Explains immediate, register, direct, register indirect, and indexed modes with examples. 2 3

  2. Addressing modes of 8051 - TutorialsPoint - Provides concise descriptions and sample instructions for core 8051 addressing modes. 2

  3. 8051 Instruction Set - Silicon Labs - Instruction-set overview including register, direct, indirect, immediate, relative, absolute, long, and indexed addressing. 2

  4. [PDF] ADDRESSING MODES - Pondicherry Engineering College - Notes on immediate, direct, indirect, relative, absolute, long, and indexed addressing in 8051.

5. Indexed Addressing Mode

In indexed addressing, the 8051 forms the effective address by adding the accumulator value to either DPTR or PC.2

Examples:

1MOVC A, @A+DPTR 2MOVC A, @A+PC

Explanation:

  • MOVC means move from code memory.
  • In MOVC A, @A+DPTR, the effective address is calculated as: Effective Address=A+DPTR\text{Effective Address} = \text{A} + \text{DPTR}
  • In MOVC A, @A+PC, the effective address is based on the program counter plus accumulator offset.2

Uses:

  • Accessing lookup tables stored in program memory.
  • Character conversion, seven-segment code tables, sine tables, and encoded constant tables.

This mode is especially important because the 8051 frequently stores constant tables in code memory rather than internal RAM.

Footnotes

  1. 8051 Instruction Set - Silicon Labs - Instruction-set overview including register, direct, indirect, immediate, relative, absolute, long, and indexed addressing. 2 3

  2. Addressing modes of 8051 - TutorialsPoint - Provides concise descriptions and sample instructions for core 8051 addressing modes. 2

How to Identify an 8051 Addressing Mode from an Instruction

  1. 1
    Step 1

    If the operand is preceded by #, the instruction uses immediate addressing, meaning the data value is embedded in the instruction itself.2

    Footnotes

    1. [PDF] UNIT – 4 8051 MICROCONTROLLER Architecture - WordPress.com - Academic notes summarizing the main five 8051 addressing modes and examples.

    2. [PDF] ADDRESSING MODES - Pondicherry Engineering College - Notes on immediate, direct, indirect, relative, absolute, long, and indexed addressing in 8051.

  2. 2
    Step 2

    If the operand is R0 to R7, A, or another CPU register without @, it is register addressing.2

    Footnotes

    1. 8051 Microcontroller Addressing Modes | JunctionByte - Explains immediate, register, direct, register indirect, and indexed modes with examples.

    2. Addressing modes of 8051 - TutorialsPoint - Provides concise descriptions and sample instructions for core 8051 addressing modes.

  3. 3
    Step 3

    If the operand is written as an address like 30H or 90H without # or @, it is direct addressing and usually refers to internal RAM or an SFR.2

    Footnotes

    1. 8051 Microcontroller Addressing Modes | JunctionByte - Explains immediate, register, direct, register indirect, and indexed modes with examples.

    2. 8051 Instruction Set - Silicon Labs - Instruction-set overview including register, direct, indirect, immediate, relative, absolute, long, and indexed addressing.

  4. 4
    Step 4

    If the operand is written as @R0, @R1, or @DPTR, the address is being taken indirectly from a register.2

    Footnotes

    1. 8051 Instruction Set - Silicon Labs - Instruction-set overview including register, direct, indirect, immediate, relative, absolute, long, and indexed addressing.

    2. Addressing modes of 8051 - TutorialsPoint - Provides concise descriptions and sample instructions for core 8051 addressing modes.

  5. 5
    Step 5

    If the form is @A+DPTR or @A+PC, it is indexed addressing and is generally used with MOVC for code-memory table access.

    Footnotes

    1. 8051 Instruction Set - Silicon Labs - Instruction-set overview including register, direct, indirect, immediate, relative, absolute, long, and indexed addressing.

Beyond operand-access modes, the 8051 instruction set also includes program branching modes: relative, absolute, and long.

Relative Addressing

In relative addressing, the target address is obtained by adding a signed 8-bit offset to the program counter. It is used in short jumps such as SJMP and conditional branches.

Example:

1SJMP LOOP 2JNZ NEXT

Range:

  • Approximately -128 to +127 bytes relative to the current PC.

Absolute Addressing

In absolute addressing the instruction supplies an 11-bit destination embedded in the opcode format for AJMP and ACALL.

Example:

1AJMP LABEL 2ACALL SUB1

Long Addressing

In long addressing the destination address is explicitly provided as a full 16-bit address, as in LJMP and LCALL.

Example:

1LJMP START 2LCALL DELAY

These are important when writing complete assembly programs, especially for code organization and subroutine calls.

Footnotes

  1. 8051 Instruction Set - Silicon Labs - Instruction-set overview including register, direct, indirect, immediate, relative, absolute, long, and indexed addressing. 2 3 4 5

1MOV A, #55H ; load constant 55H into A 2MOV A, 55H ; load data from RAM/SFR address 55H into A

7. Comparative Short Notes Table

The table below summarizes the major 8051 addressing modes in a compact examination-friendly form.4

Addressing ModeOperand SourceTypical SyntaxMain UseExample
ImmediateConstant inside instruction#dataLoad fixed valuesMOV A, #25H
RegisterCPU registerRnFast data manipulationMOV A, R2
DirectExplicit byte addressdirectAccess RAM/SFR directlyMOV A, 30H
Register IndirectAddress stored in register@R0, @R1, @DPTRPointer-based memory accessMOV A, @R0
IndexedBase + offset@A+DPTR, @A+PCTable lookup in code memoryMOVC A, @A+DPTR
RelativePC + signed offsetbranch labelShort jumpsSJMP LOOP
Absolute11-bit page targetbranch labelJump/call in 2 KB pageAJMP NEXT
LongFull 16-bit targetbranch labelJump/call anywhere in code memoryLJMP START

Footnotes

  1. 8051 Microcontroller Addressing Modes | JunctionByte - Explains immediate, register, direct, register indirect, and indexed modes with examples.

  2. 8051 Instruction Set - Silicon Labs - Instruction-set overview including register, direct, indirect, immediate, relative, absolute, long, and indexed addressing.

  3. [PDF] UNIT – 4 8051 MICROCONTROLLER Architecture - WordPress.com - Academic notes summarizing the main five 8051 addressing modes and examples.

  4. Addressing modes of 8051 - TutorialsPoint - Provides concise descriptions and sample instructions for core 8051 addressing modes.

Conceptual Comparison of 8051 Addressing Modes

Relative conceptual flexibility for operand selection and memory reach

Important Clarifications and Exam FAQs

Memory Access Tip

Use direct addressing for fixed variables and SFR control, indirect addressing for arrays and buffers, and indexed addressing for lookup tables stored in program memory.2

Footnotes

  1. 8051 Microcontroller Addressing Modes | JunctionByte - Explains immediate, register, direct, register indirect, and indexed modes with examples.

  2. 8051 Instruction Set - Silicon Labs - Instruction-set overview including register, direct, indirect, immediate, relative, absolute, long, and indexed addressing.

8. Conclusion

The various addressing modes of the 8051 microcontroller provide flexibility in accessing constants, registers, RAM locations, pointers, and code memory tables. The five principal data-access modes are immediate, register, direct, register indirect, and indexed, while relative, absolute, and long modes are used mainly for program branching.2 For short notes, a good answer should define each mode, give one example instruction, and mention its key application area such as constant loading, register operation, memory access, pointer traversal, or table lookup.2

Footnotes

  1. 8051 Instruction Set - Silicon Labs - Instruction-set overview including register, direct, indirect, immediate, relative, absolute, long, and indexed addressing.

  2. [PDF] UNIT – 4 8051 MICROCONTROLLER Architecture - WordPress.com - Academic notes summarizing the main five 8051 addressing modes and examples.

  3. 8051 Microcontroller Addressing Modes | JunctionByte - Explains immediate, register, direct, register indirect, and indexed modes with examples.

  4. Addressing modes of 8051 - TutorialsPoint - Provides concise descriptions and sample instructions for core 8051 addressing modes.

Knowledge Check

Question 1 of 5
Q1Single choice

Which 8051 addressing mode uses the # symbol before the operand?

Explore Related Topics

1

Overview of the 8051 Microcontroller Family

The 8051 (MCS‑51) family is an 8‑bit Harvard‑architecture, CISC microcontroller still used for low‑cost, low‑power embedded designs. The course covers its core hardware blocks, operation cycle, variant differences, and basic programming in assembly and C.

  • Core blocks: 8‑bit CPU, 4 KB ROM, 128 B internal RAM, four 8‑bit I/O ports, two 16‑bit timers, and a full‑duplex UART.
  • Machine cycle = 12 oscillator periods; fetch, decode, and execute phases are defined step‑by‑step.
  • Variants: 8031 (no ROM), 8051 (standard 4 KB ROM/128 B RAM), 8052 (8 KB ROM/256 B RAM + third timer).
  • Special Function Registers reside at addresses 80H‑FFH and are accessed only via direct addressing.
  • UART baud rate is set by Timer 1 reload value and SMOD bit using the formula Baud = 2^SMOD / 32 × f_osc / 12 × (256‑TH1).
2

8085 Microprocessor Flags: Correct Answer and Conceptual Explanation

The 8085 microprocessor’s flag register contains five active status flags that are automatically set after arithmetic and logical operations.

  • The 8‑bit flag register uses only five bits: Sign (S), Zero (Z), Auxiliary Carry (AC), Parity (P), and Carry (CY).
  • These flags guide conditional branch instructions such as jump‑on‑zero or jump‑on‑carry.
  • Although the register is 8 bits wide, the remaining three bits are unused/reserved, a common source of exam mistakes.
  • The Auxiliary Carry flag is especially important for BCD arithmetic.
3

8051 Serial Communication Compatibility: Can an 8051 in Mode 1 Communicate with an 8051 in Mode 3?

Mode 1 (8‑bit UART) and Mode 3 (9‑bit UART) can share the same baud‑rate generator, but their frame structures differ, making reliable bidirectional communication impossible without special handling.

  • Mode 1 transmits a 10‑bit frame (start + 8 data + stop); Mode 3 transmits an 11‑bit frame (start + 8 data + 9th bit + stop).
  • The receiver’s RB8/TB8 meaning changes: Mode 1 treats the last sampled bit as the stop bit, while Mode 3 treats it as a programmable ninth data bit.
  • Because the expected stop‑bit position shifts, a Mode 1 receiver misinterprets the ninth bit and a Mode 3 receiver misreads the stop bit, causing framing errors.
  • Matching baud rates alone does not ensure compatibility; both ends must use the same serial mode for dependable UART exchange.