Addressing Modes
Addressing Modes
the instruction itself. Each mode provides a different way for the processor to locate and handle data,
which is crucial for instruction execution. Here are some common types of addressing modes:
Usage: Quick access to constants or values that do not change, without needing memory access.
Example: LOAD R1, 5000 (here, 5000 is the memory address where the operand is stored).
Usage: Accesses data stored in a specific memory location; requires memory access.
Description: The instruction contains a pointer to the address of the operand. This pointer is stored in a
register or memory.
Example: LOAD R1, (R2) (here, R2 contains the memory address where the operand is stored).
Usage: Allows dynamic memory access, useful for accessing data structures like arrays or linked lists.
4. Register Addressing Mode
Description: The operand is stored in a register, and the instruction specifies the register where it’s
located.
Example: ADD R1, R2 (here, both operands are stored in registers R1 and R2).
Usage: Fast access to data within CPU registers, no memory access needed.
Description: The register contains the address of the operand in memory, indirectly accessing memory
through a register.
Example: LOAD R1, (R2) (where R2 holds the memory address of the operand).
Usage: Commonly used for accessing data structures where addresses change dynamically.
Description: The final address of the operand is determined by adding a constant value (index) to a base
address in a register.
Example: LOAD R1, 100(R2) (here, R2 holds a base address, and 100 is the offset).
Usage: Useful for accessing arrays, where each element is a fixed offset from a base address.
7. Base-Register Addressing Mode
Description: Similar to indexed addressing, but the base address is stored in a register and can be
dynamically adjusted.
Example: MOV A, B(R0) (here, R0 holds the base address, and B is the offset).
Description: The address of the operand is determined by adding an offset to the current program
counter (PC) value.
Example: JMP LABEL (where LABEL is a relative address based on the PC).
Usage: Primarily used for branching or jumping within code, as it allows code to be position-
independent.
Description: The operand’s address is implied by the instruction, and no specific operand is mentioned.
Example: CMA (Complement Accumulator) — the instruction inherently refers to the accumulator
register.
Usage: Simplifies instructions, often used in stack-based or accumulator-based architectures.
Description: The register holding the address is automatically incremented or decremented after
accessing the operand.
Example: LOAD R1, (R2)+ (where R2 is incremented after accessing its address).
Usage: Efficient for accessing consecutive elements in arrays, often used in looping constructs.
Each addressing mode serves specific use cases in programming and computer architecture, optimizing
speed, memory efficiency, and flexibility in accessing data and executing instructions.