Past exam question: 2082 Kartik (Back), Q4(b)
Open in the Padhaiko appQuestion
Explain briefly about different types of addressing mode used in 8086 with suitable example.
Solution
Classification of 8086 Addressing Modes: The Intel 8086 features versatile addressing modes classified according to how the operand is referenced:
- Immediate Addressing Mode: The operand is an 8-bit or 16-bit constant contained directly within the instruction following the opcode.
- Example:
MOV AX, 1234H(loads 16-bit constant 1234H into AX). - Example:
MOV AL, 50H(loads 8-bit constant 50H into AL).
- Example:
- Register Addressing Mode: The operand resides in one of the 8-bit or 16-bit internal registers of the CPU; no bus memory access is required.
- Example:
MOV AX, BX(copies contents of BX into AX). - Example:
ADD CL, DL(adds DL to CL).
- Example:
- Direct Addressing Mode: The effective offset address (EA) of the memory operand is explicitly specified as a 16-bit value within the instruction. Default segment is DS.
- Example:
MOV AX, [2050H](loads 16-bit word from DS:2050H into AX).
- Example:
Memory Addressing Modes Using Pointers & Index Registers:
- Register Indirect Addressing Mode: The effective address of the memory operand is contained in a base register (
BX,BP) or index register (SI,DI). Default segment is DS (or SS if BP is used).- Example:
MOV AX, [BX](operand EA = [BX]). - Example:
MOV [DI], CL(stores CL at EA = [DI]).
- Example:
- Based Addressing Mode: The effective address is the sum of a base register (
BXorBP) and an 8-bit or 16-bit displacement value.- Formula:
EA = [BX or BP] + Displacement - Example:
MOV AX, [BX + 08H](EA = BX + 8).
- Formula:
- Indexed Addressing Mode: The effective address is the sum of an index register (
SIorDI) and an 8-bit or 16-bit displacement.- Formula:
EA = [SI or DI] + Displacement - Example:
MOV CX, [SI + 10H](EA = SI + 10H).
- Formula:
- Based Indexed Addressing Mode: The effective address is the sum of a base register and an index register.
- Formula:
EA = [BX or BP] + [SI or DI] - Example:
MOV AX, [BX + SI](EA = BX + SI).
- Formula:
- Based Indexed with Displacement Addressing Mode: The effective address is the sum of a base register, an index register, and an 8-bit or 16-bit displacement.
- Formula:
EA = [BX or BP] + [SI or DI] + Displacement - Example:
MOV AX, [BX + DI + 20H](EA = BX + DI + 20H). Useful for accessing 2D arrays and records.
- Formula:
Summary Reference Table:
| Addressing Mode | Effective Address (EA) Formula | Default Segment | Example |
|---|---|---|---|
| Immediate | Stored in instruction | CS | MOV AX, 00FFH |
| Register | Register contents | Internal | MOV DX, CX |
| Direct | Direct 16-bit offset | DS | MOV AX, [1000H] |
| Register Indirect | [BX] / [BP] / [SI] / [DI] | DS (or SS for BP) | MOV AX, [SI] |
| Based | [BX/BP] + Disp | DS (or SS for BP) | MOV AX, [BX + 4] |
| Indexed | [SI/DI] + Disp | DS | MOV DX, [DI + 6] |
| Based Indexed | [BX/BP] + [SI/DI] | DS (or SS for BP) | MOV AX, [BX + DI] |
| Based Indexed Disp | [BX/BP] + [SI/DI] + Disp | DS (or SS for BP) | MOV AX, [BP + SI + 10H] |
Answer:
8086 provides Immediate, Register, Direct, Register Indirect ([BX]/[BP]/[SI]/[DI]), Based ([BX/BP]+disp), Indexed ([SI/DI]+disp), Based-Indexed ([BX/BP]+[SI/DI]), and Based-Indexed-with-Displacement addressing modes.