1. Gyanastra
  2. Computer Organisation and Architecture
  3. Addressing Modes
  4. Need for Addressing Modes and Reducing Address Field Bits
Free lesson, no account needed 5 min read 1 practice questions after it

Computer Organisation and Architecture · Addressing Modes

Need for Addressing Modes and Reducing Address Field Bits

Overview

An addressing mode is the rule that tells the CPU how to interpret the address field of an instruction, i.e. how to get from the address written in the instruction to the actual operand.
Addressing modes are needed because the operand value often cannot be written directly into the instruction, and they have the key benefit of reducing the number of bits in the instruction's address field.

Key concepts

  • Addressing mode: the rule that tells the CPU how to interpret the address field given in an instruction — how to go from the address written in the instruction to the actual operand.
  • Why addressing modes are needed: the operand value often cannot be written directly into the instruction, because it may not be known until that point in execution is reached.
    A program that obtains a number during execution and then processes it must work with variables, not fixed operand values.
  • Where variables live: a variable is present either in memory or in a register.
    • If the variable is in memory, the instruction must supply the memory address, which can be very large (many bits).
    • If the variable is in a register, only the register number is needed, which is small (few bits).
    • Hence the location of the operand changes the size of the instruction.
  • Main advantage of addressing modes: using an addressing mode reduces the number of bits in the addressing field of the instruction.

How it works

  1. Consider why the operand is not simply written into the instruction, e.g. "ADD 2" (add 2 to the accumulator in an accumulator organization).
    This is not always possible: the operand value may not be known until execution reaches that point, so the program must use variables.
  2. A variable resides either in memory or in a register.
  3. If it is in memory, the instruction must carry the memory address, which needs many bits.
  4. If it is in a register, the instruction carries only the register number, which needs few bits.
  5. An addressing mode exploits this to shrink the address field of the instruction.

Formulas

  • address bits=log⁡2(number of memory locations)\text{address bits} = \log_2(\text{number of memory locations})
  • register bits=log⁡2(number of registers)\text{register bits} = \log_2(\text{number of registers})

Worked examples

Memory address field vs register number field

Step 1 — Memory specification: memory size = 1K words, word size = 16 bits. Number of locations = 1024 (1K). Each location holds 16 bits, and one address is assigned to every 16 bits.

Step 2 — Address numbering:

  • First 16 bits → address 0
  • Second 16 bits → address 1
  • ...
  • Last 16 bits → address 1023

Step 3 — Bits needed for a memory address: addresses run from 0 to 1023, i.e. 1024=2101024 = 2^{10} distinct addresses, so a memory address needs 10 bits. If the operand is in memory, 10 bits must be placed in the instruction.

Step 4 — Bits needed for a register number: assume the CPU has 16 registers. Since 16=2416 = 2^{4}, 4 bits are needed. With 4 bits all combinations from all 0s to all 1s are encoded, i.e. register numbers 0 to 15.

Step 5 — Comparison of the address field: memory operand needs 10 bits in the instruction; register operand needs 4 bits. The addressing field shrinks from 10 bits to 4 bits — a saving of 6 bits per instruction.

Comparison

Where the operand (variable) residesWhat the instruction must supplyBits required (example)
MemoryMemory address10 bits (for 1K × 16-bit memory)
RegisterRegister number4 bits (for 16 registers)

Revision summary

  • The operand value is often unknown at instruction-fetch time (it is computed during execution), so programs work with variables, not fixed operand values.
  • Variables live either in memory or in registers; this choice determines how many bits the address field needs.
  • Main advantage of addressing modes: the number of bits in the addressing field of the instruction is reduced (in the example, from 10 bits to 4 bits).
  • Number of address bits = log⁡2(number of locations)\log_2(\text{number of locations});
    number of register bits = log⁡2(number of registers)\log_2(\text{number of registers}).
  • 1 KB memory with 16-bit words = 1024 locations, addressed 0 to 1023, requiring 10 address bits.
  • 16 registers are numbered 0 to 15 and need 4 bits to identify one of them.

Previous-year exam insights

  • Common addressing modes are immediate (operand in instruction), direct (EA = address field), indirect (EA = M[address field]), register (operand in register), register indirect (EA = contents of register), indexed (EA = index register + address field), base-register (EA = base register + displacement), PC-relative (EA = updated PC + signed displacement), and stack/implied (operand at top of stack or implicit).
  • Operand-fetch memory references: immediate and register modes need 0 data-memory accesses; direct, register-indirect, indexed, base-register, and PC-relative need 1 data-memory access; indirect needs at least 2 (one to fetch the effective address, one to fetch the operand), not counting instruction fetch.
  • Displacement addressing uses EA = (base or index register) + address field;
    indexed mode suits array access (address field = base of array, register = index), while base-register mode suits relocation (register = base, address field = offset).
  • PC-relative addressing computes EA from the updated PC (address of the next instruction) plus a signed displacement; it supports position-independent code and short branches, with displacement range limited by the field size.
  • An n-bit address field directly addresses 2n2^{n} locations; M locations need ceil(log⁡2M\log_{2} M) bits and R registers need ceil(log⁡2R\log_{2} R) bits, with unused codes when the count is not a power of two.
  • Shorter address fields reduce instruction length but may require indirection or register setup and extra memory accesses; direct addressing is limited to 2n2^{n} locations by its n-bit address field, while indirect addressing can reach larger memory at the cost of extra access.
Pages 1–2 of 2