Q3Computer Architecture
Question
Q.3. What are addressing modes? Explain each in brief with diagram.
Answer
Addressing modes specify how the effective operand address is determined from an instruction; common modes include immediate, direct, indirect, register, register indirect, indexed, and relative addressing.
Addressing modes define the rule by which the effective address of an operand is computed from the address field(s) given in an instruction, providing flexibility in how programs reference data.
Immediate addressing: the operand itself is contained directly within the instruction (no memory reference needed), fastest to access but limited to constant values, e.g. MOV R1, #5.
Direct addressing: the address field of the instruction directly contains the effective address of the operand in memory, e.g. MOV R1, [200] fetches the value stored at memory address 200.
Indirect addressing: the address field contains the address of a memory location which itself holds the effective address of the actual operand (i.e., a pointer), requiring an extra memory access but allowing dynamic addressing.
Register addressing: the operand is held directly in a specified CPU register rather than memory, giving the fastest possible access with no memory reference at all.
Register indirect addressing: the specified register holds the address of the memory location containing the actual operand, combining register speed for address lookup with memory-based data.
Indexed addressing: the effective address is computed by adding the contents of an index register to a constant/base address given in the instruction, useful for accessing array elements.
Relative addressing: the effective address is computed by adding the contents of the Program Counter (PC) to the address field, commonly used for branch/jump instructions to specify a target relative to the current instruction.
The choice of addressing mode directly affects code density, execution speed, and the flexibility of the instruction set. Modes requiring fewer memory references (immediate, register) execute fastest but offer less flexibility for accessing arbitrary or dynamically computed locations, while modes requiring additional memory references (indirect, indexed) trade some speed for the ability to implement pointers, arrays, and position-independent code. A well-designed instruction set typically provides a mix of these modes so the compiler can select the most efficient one for each specific operand access pattern encountered in a program, such as using indexed addressing for array traversal loops and relative addressing for compact, relocatable branch instructions.