Program Memory Addressing Modes
1. Introduction
In microprocessor programming, addressing modes define how the CPU accesses operands
for instructions. Program memory addressing modes describe how the processor fetches
instructions or data stored in memory during program execution.
The Intel 8086 microprocessor and similar CPUs support multiple addressing modes to
provide flexibility, efficiency, and ease of programming. Choosing the appropriate
addressing mode affects execution speed, instruction size, and memory usage.
The main program memory addressing modes include:
1. Immediate Addressing
2. Register Addressing
3. Direct Addressing
4. Register Indirect Addressing
5. Based and Indexed Addressing
6. Relative Addressing
Each mode has specific uses and advantages, enabling efficient memory access and
program flow control.
2. Immediate Addressing Mode
In immediate addressing, the operand is part of the instruction itself. The CPU fetches
the constant value directly from the instruction.
Key Features:
Operand is fixed and specified in the instruction.
Fast execution as no memory access is required.
Commonly used for initializing registers, counters, or constants.
Example:
MOV AX, 1234h ; Load immediate value 1234h into AX
ADD BX, 05h ; Add 5 to BX
Advantages:
Fast and efficient
Reduced memory access
Predictable results
Limitations:
Operand size is limited by instruction length
Not suitable for dynamic data
3. Register Addressing Mode
In register addressing, operands are located inside CPU registers. The CPU performs
operations directly on these registers without accessing memory.
Key Features:
Uses general-purpose registers like AX, BX, CX, DX.
Execution is very fast.
Common for arithmetic, logic, and data transfer operations.
Example:
MOV AX, BX ; Copy BX contents into AX
ADD AX, CX ; Add CX to AX
Advantages:
Fast execution
Short instruction size
Ideal for temporary data
Limitations:
Limited number of registers
Cannot store large datasets
4. Direct Addressing Mode
Direct addressing specifies the exact memory location of the operand within the
instruction.
Key Features:
Operand resides in RAM.
Instruction contains memory address.
Useful for global variables and arrays.
Example:
MOV AX, [2000h] ; Load value from memory location 2000h into AX
MOV [3000h], BX ; Store BX into memory location 3000h
Advantages:
Access to large or global data
Simple to program
Limitations:
Slower due to memory access
Fixed memory location reduces flexibility
5. Register Indirect Addressing
In register indirect addressing, the instruction specifies a register that contains the
memory address of the operand. The CPU accesses memory indirectly through the register.
Key Features:
Uses pointer or index registers (BX, BP, SI, DI).
Supports dynamic memory access.
Common for arrays, stacks, and buffers.
Example:
MOV AX, [BX] ; Load value from memory pointed by BX
MOV [SI], AX ; Store AX in memory pointed by SI
Advantages:
Flexible access to memory
Useful for dynamic data structures
Limitations:
Slightly slower than register addressing
Requires careful register management
6. Based and Indexed Addressing
Based Addressing
Uses a base register (BX or BP) and a displacement to access memory.
Often used for structured data access like arrays and records.
Example:
MOV AX, [BX+04h] ; Load value at address BX + 4 into AX
Indexed Addressing
Uses an index register (SI or DI) and optional displacement.
Ideal for looping through arrays or strings.
Example:
MOV AX, [SI+05h] ; Load value from memory at SI + 5
Advantages:
Supports arrays and complex data structures
Reduces instruction modification
Limitations:
More instruction cycles than direct or register addressing
Complexity increases with multiple registers
7. Relative Addressing Mode
In relative addressing, the operand address is specified as an offset relative to the
instruction pointer (IP). This is commonly used for branching and loop control.
Example:
JMP SHORT LABEL ; Jump to a location relative to IP
Key Features:
Operand is offset from current instruction
Efficient for program control and branching
Supports loops and conditional jumps
Advantages:
Small instruction size
Simplifies program relocation
Limitations:
Limited by offset size
Not suitable for accessing large memory ranges
8. Comparison of Program Memory Addressing Modes
Addressing Mode Operand Location Speed Use Case
Immediate Instruction Fastest Constants, initialization
Register CPU registers Fast Arithmetic, temporary data
Direct Specific memory Moderate Global/static variables
Register Indirect Memory via register Moderate Arrays, stacks, dynamic data
Based/Indexed Memory via base/index Moderate Arrays, strings, records
Relative Offset from IP Fast Branching, loops
Each mode provides trade-offs between speed, flexibility, and memory usage, allowing
efficient program design.
9. Summary
Program memory addressing modes define how the CPU accesses operands during
instruction execution. Immediate, register, direct, register indirect, based/indexed, and
relative addressing modes provide flexibility, efficiency, and structured memory
management.
Choosing the appropriate addressing mode optimizes execution speed, instruction size,
and program readability, making them fundamental for assembly programming and low-
level system design.
Key Points:
Addressing modes control how operands are accessed.
Immediate and register modes are fast, memory-based modes provide flexibility.
Relative addressing is critical for program flow control.
Understanding these modes is essential for efficient and modular programming.