Skip to main content

Addressing modes with examples

Short answer

An addressing mode defines how the instruction's address field yields the effective address. Modes include immediate (fast, constant), register (short, limited), direct (simple), indirect (large space, slow), indexed (arrays), relative (position-independent), and base register (relocation), each trading speed for flexibility.

Define addressing mode. Explain the different types of addressing modes with examples, comparing them (advantages and disadvantages).

An addressing mode is the rule by which the address field of an instruction is interpreted to find the operand (the effective address, EA). Addressing modes let an instruction reach a large memory with a short address field, and they support pointers, loops, arrays and relocation.

Types with examples

ModeOperand location / EAExample
ImpliedOperand is implicit in the opcodeCMA (complement accumulator); ADD in a stack (zero-address) machine
ImmediateOperand is in the instructionMVI B, 32H (B = 32H)
RegisterOperand is in a register named in the instructionMOV A, B
Register indirectRegister holds the address of the operandLDAX B; MOV A, M; EA = (R)
Direct (absolute)Address field is the EALDA 2000H; EA = 2000H
IndirectAddress field points to a word that holds the EALOAD @500; EA = M[500]
Autoincrement / autodecrementRegister is used as a pointer, then incremented/decrementedLOAD (R1)+ ; EA = (R1), R1 = R1 + 1
RelativeEA = PC + address fieldJR offset; EA = PC + offset
IndexedEA = index register + address fieldLOAD 100(X); EA = 100 + (X)
Base registerEA = base register + address fieldLOAD 20(BR); EA = (BR) + 20

Worked values

Take address field = 500, R1 = 400, M[500] = 800, M[400] = 300, PC = 200 (the updated PC value), XR = 100.

  • Immediate: operand = 500.
  • Direct: EA = 500, operand = M[500] = 800.
  • Indirect: EA = M[500] = 800, operand = M[800].
  • Register indirect: EA = R1 = 400, operand = M[400] = 300.
  • Relative: EA = 200 + 500 = 700.
  • Indexed: EA = 500 + 100 = 600, operand = M[600].

Advantages and disadvantages

ModeAdvantageDisadvantage
ImmediateNo memory access for the operand; fastOperand range is small and is a constant
RegisterVery fast, short fieldFew registers
DirectSimple; one memory accessLimited address space; fixed address
IndirectLarge address space; easy pointersTwo or more memory accesses; slow
Register indirectLarge space, only one access, short fieldExtra instruction to set the register
IndexedEfficient for arrays and loopsExtra addition; needs an index register
RelativePosition-independent code; short branchesLimited branch range
Base registerEasy relocation of programsExtra addition and register
ImpliedShortest instructionOnly for fixed operands

✓ Answer checked by Claude Opus 5.5 (high effort)

All Computer Organization and Architecture chapter 2 questions →