How Do Classical Addressing Modes Calculate Memory Addresses?

Classical computer architectures use addressing modes to determine where an instruction finds its operands. Immediate, direct, indirect, and indexed addressing each compute the effective address differently, trading off instruction size, memory accesses, and flexibility. Understanding these calculations clarifies how CPUs access constants, variables, pointers, and arrays in memory.

Immediate Addressing

In immediate addressing, the operand is embedded directly inside the instruction's address field rather than stored elsewhere in memory. Because the data itself is part of the instruction, no memory lookup is needed to fetch the operand, and no effective address calculation is performed.

If the instruction specifies a value \(V\), the operand is simply \(V\). This mode is fast and commonly used for constants, such as loading a fixed number into a register, though the value's size is limited by the width of the instruction's operand field.

Direct Addressing

In direct addressing (also called absolute addressing), the instruction's address field contains the exact memory location of the operand. The effective address \(EA\) is equal to the address \(A\) specified in the instruction:

\[EA = A\]

To retrieve the operand, the CPU performs one memory read at location \(A\). Direct addressing is simple and fast, but the range of reachable memory addresses is constrained by the number of bits available in the instruction's address field.

Indirect Addressing

In indirect addressing, the instruction's address field points to a memory location that holds the actual address of the operand, functioning like a pointer. The CPU must first read memory at address \(A\) to obtain the effective address, and then read memory again at that resulting address to fetch the operand:

\[EA = (A)\]

Here, \((A)\) denotes the contents of memory at address \(A\). This mode allows access to the full memory space regardless of the instruction's address field width, at the cost of an extra memory reference.

Indexed Addressing

In indexed addressing, the effective address is calculated by adding a base address \(A\) from the instruction to the contents of an index register \(R\):

\[EA = A + (R)\]

By incrementing or modifying the value in \(R\), a program can step through consecutive elements of an array or data structure using the same instruction. Some architectures also support variations such as pre-indexed or post-indexed addressing, where the index register is updated before or after the effective address is used.