Addressing Modes 

The different ways that can be utilized by an instruction to access its operands are called Addressing Modes

As seen before, operands can reside in memory or CPU registers

Accessing operands in memory requires the CPU to compute the effective address of the operand

The computation of the effective address depends on the addressing mode expressed in the instruction

Fig. m300240.1 below summarize some of the commonly used addressing modes and how the effective address is computed for each. These are:

  1. Immediate Addressing:
    The operand itself, not its address, is specified in the instruction (Fig. m300240.1 (a)) hence no address computations are required

    Used to introduce constants into the program

    Can not be used for addressing the result

  2. Direct Addressing:
    The address of the operand is specified in the instruction as a constant (Fig. m300240.1 (b))

    No address computations are required and the operand can be accessed directly

  3. Indirect Addressing:
    The address location that contains the address of the operand is specified in the instruction (Fig. m300240.1 (c)). Hence this address is a pointer to the operand

    Two memory references/accesses are required to access the operand

  4. Register Direct Addressing:
    The operand is contained in a register which is specified by the instruction (Fig. m300240.1 (d))

    Since no memory access is required, operand access is much faster than direct and indirect addressing

    This addressing mode is used to provide access to local variables and intermediate results

  5. Register Indirect Addressing:
    The address of the operand is contained in a register which is specified by the instruction (Fig. m300240.1 (e))

    This addressing mode is usually used to provide sequential access to data arrays that are stored in the memory. By incrementing the register after each access, the next data item in the array can be accessed

    Many computers have instructions that auto-increment (or decrement) the address-holding register after each access to point to the next data item automatically

  6. Indexed, Displacement or Based Addressing:
    The effective address is formed by adding a fixed constant, usually contained in the instruction itself, to an address value (index) contained in a register (Fig. m300240.1 (f))

    Usually used to access arrays, records (such as those in Pascal), or C-language struct. These data structures are usually stored at a fixed offset from a start address

    Because of the index addition, the effective address computation would take more CPU cycles than previous addressing modes

    Modern computers include a separate address calculation unit with its own arithmetic functional blocks to reduce the time required to compute the effective address

  7. Relative Addressing:
    Similar to indexed addressing except that the base address is held in the PC (or IP) register (Fig. m300240.1 (g))

    Hence the operand is stored at a memory location with a fixed offset from the current instruction

Fig. m300240.1 Some of the Commonly used Addressing Modes

 Final Note About Addressing Modes
Addressing modes are selected to reduce the number of instructions per program, allow easy access to complex data structures such as arrays, records, and structures, or reduce the time required to access operands. Direct and fast access is traded off with flexibility in accessing complex data structures. Adding dedicated address calculation units help resolving these tradeoffs at the expense of more design complexity.