Skip to content

Addressing Modes

Definition: Addressing mode specifies how to interpret the operand in an instruction (where the operand is located or how to get it).

  1. Immediate Addressing Mode ⭐
    • Operand is given directly in the instruction.

    • Advantage: Fast, no memory access for operand.
    • Application: Constants.
    • Example: MOV A, #5 β†’ Load 5 into A.
  2. Direct (Absolute) Addressing Mode ⭐
    • Address field contains the actual memory address of the operand.

    • Application: Access fixed memory location.
    • Example: MOV A, 2000H β†’ Load from memory 2000H.
  3. Indirect Addressing Mode ⭐
    • Address field contains a register/memory location holding the effective address of the operand.
    • Application: Pointers, linked lists.

    • Example: MOV A, @R0 β†’ Effective address from R0.
  4. Register Addressing Mode
    • Operand is in a CPU register.
    • Application: Very fast access.
    • Example: MOV A, R1.
  5. Register Indirect Addressing Mode
    • Register contains the address of operand in memory.
    • Application: Table lookups.
    • Example: MOV A, @R2.
  6. Base Addressing Mode ⭐
    • Effective Address (EA) = Base Register + Displacement.
    • Application: Relocatable programs.

    • Example: MOV A, 1000(RB).
  7. Index Addressing Mode ⭐
    • EA = Index Register + Base Address.
    • Application: Arrays.
    • Example: MOV A, ARR(RI).
  8. Relative Addressing Mode ⭐
    • EA = Program Counter (PC) + Displacement.
    • Application: Branching instructions.
    • Example: BEQ LABEL.
  9. Autoincrement / Autodecrement Addressing
    • Register points to operand and is incremented/decremented automatically after/before use.
    • Application: Stack operations, sequential data.
    • Example: MOV A, (R1)+.

Quick Match for PSU-type Questions:

  • Immediate β†’ Constants
  • Direct β†’ Fixed data
  • Indirect β†’ Pointers
  • Register β†’ Fast data access
  • Base β†’ Relocatable programs
  • Index β†’ Arrays
  • Relative β†’ Branching
  • Auto inc/dec β†’ Stack or sequential access

Difference between Base, Index, and Relative Addressing Modes.

  1. Base Addressing
    • Base β†’ relocation flexibility.
    • Base comes from a base register that can be changed at runtime.

    • Useful for relocatable programs: move the whole program in memory, just update the base register.
    • Example: OS loads a process at a new memory location without changing its instructions.
  2. Index Addressing
    • Index β†’ array element access.
    • Base is a constant in the instruction (start of an array), displacement_ is an index register that changes.

    • Perfect for arrays/tables: just increment the index register to access the next element.
    • Example: Loop accessing array elements sequentially.
  3. Relative Addressing
    • Relative β†’ branching within a short distance.
    • Base is the PC, displacement_ is a constant offset in instruction.

    • Used for branching/jumps: target is always relative to the current instruction, making code position-independent.
    • Example: BEQ LABEL works even if program is loaded at a different address.
ModeBase SourceDisplacement SourceMain Use
Base AddressingBase RegisterConstantRelocatable programs
Index AddressingConstant (Base Address)Index RegisterArrays, tables
Relative AddressingProgram CounterConstantBranching, position-independent code

A. Non-Computable Addressing Modes

Effective address is obtained without arithmetic computation

  1. Implied Mode: Operand is implicitly defined by opcode (no address field required).

  2. Immediate Mode: itself** (constant data).
  3. Direct Mode: Address field contains the effective address (E.A) of operand. Operand = M[Address]

  4. Indirect Mode: Address field points to a memory location that contains E.A. E.A = M[Address], Operand = M[E.A]

  5. Register Mode: Address field specifies a register which contains operand. Operand = R

  6. Register Indirect Mode: Address field specifies a register which contains E.A of operand. E.A = R, Operand = M[E.A]

B. Computable Addressing Modes

Effective address is computed using arithmetic like + / -

  1. Autoincrement / Autodecrement Mode
    Register indirect mode where register is automatically updated after/before access. Operand = M[R], then R = R Β± d
  2. Indexed Mode
    Effective address = Base address (instruction) + Index register. E.A = Address + IndexReg
  3. PC-Relative Mode
    Effective address = PC (next instruction address) + Offset (instruction). E.A = PC + Offset
  4. Base Register Mode
    Effective address = Base register + Offset (instruction). E.A = BaseReg + Offset

EA = Register + Displacement/Offset

1. Indexed Mode ⭐

Effective address = Base address (from instruction) + Index (from index register)

E.A = Address + (IndexReg)

  • Fixed / Not changeable: Address field (Base Address)

  • Changeable: IndexReg value

  • Use: Arrays / tables / strings
  • Why: Base points to start of array, index selects element number
Instruction
β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚ Opcode β”‚ Mode β”‚ Address β”‚ = Base Address (constant in instruction)
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”΄β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”΄β”€β”€β”€β¬‡β”€β”€β”€β”€β”€β”˜
Base Address
β”‚
β”Œβ”€β”€β”€β”€β”€β”€β”΄β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚ ADD ( + ) β”‚
β””β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
β”‚
β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β” β”‚
β”‚ IndexReg β”‚β”€β”€β”€β”˜ (changes during execution)
β””β”€β”€β”€β”€β¬‡β”€β”€β”€β”€β”€β”˜
Index
β”‚
E.A
β”‚
β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚ Operand β”‚ = M[E.A]
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜

Example (Array):

  • Address = Base of A[0]
  • IndexReg = i * size
  • Access A[i]

2. PC-Relative Mode (Position Independent Mode) ⭐

Effective address = PC (next instruction address) + Offset (from instruction)

E.A = PC + Offset

  • Fixed / Not changeable: Offset field (in instruction)
  • Changeable: PC value (keeps changing automatically)
  • Use: Branch / jump inside code segment (loops, if-else)

  • Why: Code can be loaded anywhere β†’ jump still works (Position Independent Code)
Instruction
β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚ Opcode β”‚ Mode β”‚ Address β”‚ = Offset (constant in instruction)
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”΄β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”΄β”€β”€β”€β¬‡β”€β”€β”€β”€β”€β”˜
Offset
β”‚
β”Œβ”€β”€β”€β”€β”€β”€β”΄β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚ ADD ( + ) β”‚
β””β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
β”‚
β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
β”‚
β”Œβ”€β”€β”΄β”€β”€β”€β”
β”‚ PC β”‚ (changes every instruction)
β””β”€β”€β¬‡β”€β”€β”€β”˜
Addr of NEXT instruction
β”‚
E.A
β”‚
β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚ Target Instr β”‚ = M[E.A]
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜

Notes:

  • PC contains address of next instruction, not current.
  • Forward jump: Offset +ve
  • Backward jump: Offset -ve

Example:

  • BEQ label
  • Offset = label - (PC of next instr)

Base Register Mode (Inter-Segment Branch)

Effective address = Base Register + Offset (from instruction)

E.A = (BaseReg) + Offset

  • Fixed / Not changeable: Offset field
  • Changeable: BaseReg value
  • Use: Segment based addressing, relocation, dynamic memory blocks, inter-segment jump

  • Why: Base register selects the memory region/segment, offset selects inside it
Instruction
β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚ Opcode β”‚ Mode β”‚ Address β”‚ = Offset (constant in instruction)
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”΄β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”΄β”€β”€β”€β¬‡β”€β”€β”€β”€β”€β”˜
Offset
β”‚
β”Œβ”€β”€β”€β”€β”€β”€β”΄β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚ ADD ( + ) β”‚
β””β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
β”‚
β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β” β”‚
β”‚ BaseReg β”‚β”€β”€β”€β”˜ (changeable by program)
β””β”€β”€β”€β”€β¬‡β”€β”€β”€β”€β”€β”˜
Base
β”‚
E.A
β”‚
β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚ Target/Opnd β”‚ = M[E.A]
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜

Example:

  • BaseReg = start address of segment (code/data/stack)
  • Offset = location inside that segment

Key Differences (Most Important)

Indexed Mode: E.A = Address + IndexReg
PC-Relative Mode: E.A = PC + Offset
Base Reg Mode: E.A = BaseReg + Offset
PointIndexed ModePC-Relative ModeBase Register Mode
EA formulaEA = Address + IndexRegEA = PC + OffsetEA = BaseReg + Offset
Constant part comes fromInstruction Address field (Base Address)Instruction Address field (Offset)Instruction Address field (Offset)
Variable part comes fromIndex RegisterPC registerBase Register
Which register is usedSpecial/general Index RegPC only (fixed register)Special/general Base Reg
What changes frequentlyIndexReg changesPC changes automatically every instructionBaseReg changes when segment/region changes
What stays same mostlyBase address (array start)Offset for that branch instructionOffset inside segment
Main purposeArray/Table accessBranch/Jump (control flow)Relocation/Segmentation
Typical operandData (A[i])Instruction address (label target)Data/Instruction inside a segment
Best use-caseStrings, arrays, lookup tablesLoops, if-else, function local jumpsMemory segments, modules, dynamic blocks
Why neededEfficient element selectionPosition independent codeSegment relocation with single register update
Example meaningA[i]goto labelaccess segment_base + k

Similarity

E.A = (Some Register) + (Some Constant from instruction)

  • Instruction (Fixed)
    • Address (in Indexed Register Mode)
    • Offset (in PC-Relative and Base Register Mode)
  • Register (Changeable)
    • IndexReg (in Indexed Register Mode)
    • PC (in PC-Relative Mode)
    • BaseReg (in Base Register Mode)

What changes?

  • Indexed: Index changes β†’ moving across array elements
  • PC-relative: PC changes β†’ branch depends on current location
  • Base reg: BaseReg changes β†’ switch segment / memory region

Best use:

  • Indexed: arrays/tables
  • PC-relative: short/near jumps, loops, position-independent code
  • Base register: segment relocation, far addressing, inter-segment jumps

Similarity & Difference (Indexed vs PC-Relative vs Base Register Modes)

Section titled β€œSimilarity & Difference (Indexed vs PC-Relative vs Base Register Modes)”
  • Instruction provides a constant displacement
    • Indexed: constant = Base Address
    • PC-relative/Base: constant = Offset
  • One register provides a variable part
  • CPU does addition to get E.A

1) Indexed Mode

E.A = Address + IndexReg

  • Register is IndexReg== (a normal register ==chosen by programmer)

  • It changes because you change it (loop variable i)
  • Purpose: Data access pattern
    • arrays, tables, strings

Meaning:
β€œBase is fixed, index moves element-to-element”

2) PC-Relative Mode

E.A = PC + Offset

  • Register is PC (not selectable)
  • It changes automatically every instruction

  • Purpose: Control flow
    • branch/jump target

Meaning:
β€œTarget is near current instruction”

Main benefit: Position Independent Code (PIC) (load program anywhere, jumps still work)

3) Base Register Mode

E.A = BaseReg + Offset

  • Register is BaseReg (chosen/maintained by system/program)
  • It changes when segment/region changes

  • Purpose: Relocation / segmentation
    • move whole block by changing base

Meaning: β€œOffset stays same, but base shifts entire region”

Why 3 types if formula same?

Because they solve 3 different problems:

  • Indexed β†’ where is A[i]? (data traversal)
  • PC-relative β†’ where is next code label? (branch target)
  • BaseReg β†’ where is my segment/block currently located? (relocation)

Best 3-line exam difference

  • Indexed: for arrays/tables ($IndexReg$ changes)
  • PC-relative: for branches/jumps ($PC$ changes automatically)
  • Base register: for relocation/segments ($BaseReg$ changes when region shifts)