What is addressing mode?


Addressing mode is a way that tells the CPU how to choose or access the operand (data) for an instruction in computer architecture. It gives the CPU directions on where to find the data.

Memory

Program Counter


  • Program Counter (PC) = Next Instruction.
  • It keeps track of which instruction the computer will execute next.


Categories of addressing mode?


The most well known addressing mode are:

  • Implied Addressing Mode
  • Immediate Addressing Mode
  • Register Addressing Mode
  • Register Indirect Addressing Mode
  • Auto-increment or Auto-decrement Addressing Mode
  • Direct Addressing Mode · Indirect Addressing Mode
  • Displacement Address Addressing Mode
  • Relative Addressing Mode · Index Addressing Mode

Example problem


Find out the effective address of operand and operand value by considering different addressing modes.

Problem Example


The solution is presented in a table format to show how different addressing modes determine the effective address and operand value.

Addressing Mode Effective Address Operand Notes
Immediate Addressing Mode 201 500
  • As instruction contains immediate number 500
  • It is stored as address 201
Register Addressing Mode - 400
  • Register R1 contains 400
  • As operand is in register so no any memory location
Register Indirect Addressing Mode 400 700
  • Register R1 contains 400. So effective address of operand is 400.
  • The data stored at 400 is 700
Direct Addressing Mode 500 800
  • Instruction contains the address 500. So effective address of operand is 500.
  • The data stored at 500 is 800.
Indirect Addressing Mode 800 300
  • Instruction contains the address 500. Address at 500 is 800. So effective address of operand is 800.
  • The data stored at 800 is 300.
Relative Addressing Mode 702 325
  • PC = 200, Offset = 500, Instruction is of 2 bytes. So effective address = PC + 2 + offset = 200 + 500 +2 =702
  • The data stored at 702 is 325
Index Addressing Mode 600 900
  • XR = 100, Base = 500. So effective address = Base + XR = 500 + 100 = 600.
  • The data stored at 600 is 900.
Auto-increment Addressing Mode 400 700
  • It is same as register indirect addressing mode except the contents of R1 are incremented after the execution. R1 contains 400. So effective address of operand is 400.
  • The data stored at 400 is 700
Auto-decrement Addressing Mode 399 450
  • t is same as register indirect addressing mode except the contents of R1 are decremented before the execution. R1 contains 400. R1 is first decremented to 399. So effective address of operand is 399.
  • The data stored at 399 is 450.