8086 Addressing Modes
Based, Indexed, Based-Indexed, Relative.
An addressing mode defines how the processor calculates the memory address (or identifies the operand) for an instruction. The 8086 supports a rich set of addressing modes that provide flexibility for accessing arrays, stacks, data structures, and code. Understanding the effective address calculation for each mode is essential for both programming and GATE problem solving.
Immediate and Register Addressing
In immediate addressing mode, the operand is embedded directly in the instruction. No memory access is needed to fetch the operand. Example: MOV AL, 25H. The value 25H is the operand, stored as part of the instruction bytes in the code segment.
In register addressing mode, both operands are processor registers. No memory access is needed for the operand. Example: MOV AX, BX. This is the fastest mode because registers are internal to the CPU and can be accessed in zero bus cycles.
Direct Addressing Mode
In direct addressing mode, the instruction contains the 16-bit offset address (displacement) of the operand directly. The effective address (EA) equals this displacement. The physical address is computed as DS x 10H + displacement. Example: MOV AL, [2500H] fetches the byte at offset 2500H in the data segment.
Register Indirect Addressing
In register indirect addressing, the EA is the content of a base or index register (BX, BP, SI, or DI). The register holds the offset of the operand in memory. Example: MOV AX, [BX] fetches the word at the address DS:BX. If BP is used, the default segment is SS (stack segment), not DS. This distinction is critical in exam questions.
Based, Indexed, and Based-Indexed Modes
In based addressing mode, the EA is computed as the contents of a base register (BX or BP) plus an 8-bit or 16-bit signed displacement. Example: MOV AX, [BX+04H]. This is useful for accessing fields within a data structure where BX points to the base of the structure.
In indexed addressing mode, the EA is computed as the content of an index register (SI or DI) plus a displacement. Example: MOV CL, [SI+10H]. This is ideal for sequential array traversal, where SI or DI is updated after each element access.
In based-indexed addressing mode, the EA combines a base register, an index register, and optionally a displacement: EA = Base + Index + Displacement. Example: MOV AX, [BX+SI+02H]. This mode supports 2D array access and complex data structure navigation. Adding a displacement on top of this is called based-indexed with displacement.
Relative Addressing Mode
In relative addressing mode, the target address for a branch instruction is specified as a signed displacement relative to the current value of the instruction pointer (IP). The processor computes the target as IP + displacement. This mode is used by conditional jump instructions (JZ, JNZ, JC, etc.) and keeps code position-independent, which is important for relocatable programs.
Numerical Example
The effective address calculation is straightforward once you know which components are present. Consider a based-indexed addressing instruction, which is the most complex form. The physical address is then derived from the EA and the default segment.
Given:
DS = 3000H
BX = 0200H
SI = 0050H
Displacement = 0010H
Instruction: MOV AX, [BX+SI+0010H]
Why this formula applies:
Based-indexed with displacement: EA = BX + SI + displacement
Formula:
EA = BX + SI + Displacement
Physical Address (PA) = DS x 10H + EA
Substitution:
EA = 0200H + 0050H + 0010H = 0260H
PA = 3000H x 10H + 0260H = 30000H + 0260H
Calculation:
PA = 30260H
Final Answer: Physical Address = 30260H. AX is loaded from memory location 30260H.Exam Tip: BP register defaults to SS (stack segment), not DS. All other base/index registers (BX, SI, DI) default to DS. In relative addressing, the displacement is added to IP after it has already been incremented past the current instruction. This is frequently tested in GATE branch target calculation problems.
Mechanism: EA Calculation Summary
- Immediate and register modes need no memory access for the operand and are the fastest.
- Direct mode: EA is a fixed 16-bit displacement. One memory access for the operand.
- Register indirect: EA = content of BX, SI, DI, or BP. One memory access.
- Based mode adds a displacement to BX or BP. Indexed mode adds a displacement to SI or DI.
- Based-indexed mode: EA = Base + Index + optional displacement. Most flexible, used for 2D arrays.
- Relative mode computes branch target as IP + signed displacement. Used by conditional jumps.
Quick Revision
- EA = Base + Index + Displacement (general formula; components present depend on mode).
- BP always defaults to SS; BX, SI, DI default to DS.
- Physical Address = Segment x 10H + EA (always 20-bit result).
- Relative addressing: branch target = IP + signed displacement (IP is already past current instruction).
- Immediate mode: operand in instruction itself. Register mode: operand in CPU register. Both are fast.
- Based-indexed with displacement supports 2D array and structure field access.
- Segment override prefix (CS:, ES:, SS:) can change the default segment for any memory access.
Processor Addressing Modes
Determine correct operand retrieval mechanisms.
Q1.Which addressing mode is demonstrated by the instruction MOV AX, [BX+SI]?
Related Articles
Addressing Modes
Immediate, Register, Direct, Indirect, Implied.
11 min read
Interrupts
Hardware vs Software, IVT structure, INT n instruction.
6 min read
8086 Architecture
BIU and EU, 16-bit data bus.
9 min read
8086 Pin Diagram
Min/Max mode, lock, ready signals.
12 min read
BIOS Interrupts
INT 10h video services, INT 16h keyboard.
10 min read