Addressing Modes

Addressing modes define how a CPU locates operands (data) for instructions, enabling efficient access to registers, memory, or immediate values. It is important specially for operations like loops and array access.

Common Addressing Modes

Addressing ModeDescriptionExample
ImmediateOperand is embedded in the instruction, fast but fixed.MOV R1, #5 (Loads 5 into R1)
RegisterOperand is in a CPU register, quick access.ADD R1, R2 (Adds R2 to R1)
DirectInstruction specifies a memory address.MOV R1, [5000] (Loads value at address 5000 into R1)
IndirectRegister holds the memory address.MOV R1, [R2] (Loads value at address in R2 into R1)
IndexedCombines a base register with an offset, ideal for arrays.MOV R1, [R2 + 4] (Loads value at address R2+4 into R1)
RelativeAddress is relative to the Program Counter, used for jumps.JMP PC + 3 (Jumps to PC + 3 bytes)