Indexed Addressing Mode Example

September 02, 2025

When working with assembly language or low-level programming, the way a processor accesses memory is everything. This is where addressing modes come into play. Simply put, addressing modes are rules that tell the CPU how to locate the operand (data) it needs. Think of them as different “methods of giving directions” to the processor.

Understanding Indexed Addressing Mode

Among the various addressing modes, the indexed addressing mode stands out because it is particularly useful when dealing with arrays, tables, or data stored sequentially in memory. In this mode, the CPU calculates the effective address of data by combining a base address with an index value.

How Indexed Addressing Mode Works

Imagine you have a street address but also need to specify an apartment number. The street address is like the base address, and the apartment number is the index. Together, they tell you exactly where to go.

  • Base address → starting location of memory block
  • Index register → adds an offset to the base address

So, the effective memory address becomes:
Effective Address = Base Address + Index Register (+ Optional Displacement)

Components of Indexed Addressing

  • Base Register – Holds the starting address.
  • Index Register – Contains the offset (like the step in an array).
  • Displacement (Optional) – A constant value added for further adjustment.

Types of Indexed Addressing Mode

  • Simple Indexed Addressing → Only base + index register.
  • Base Indexed Addressing → Uses both base register and index register.
  • Indexed with Displacement → Base + index + constant displacement.

Indexed Addressing Mode Example

Assembly example:


MOV AX, [BX + SI]  ; BX = base register, SI = source index register

If BX = 1000 and SI = 20, then the data is fetched from memory address 1020.

Example with Real-Time Memory Access


MOV AX, ARRAY[SI]  ; ARRAY = base address, SI = position in array

If SI = 2, the CPU fetches the third element (since indexing starts at 0). This makes indexed addressing mode perfect for iterating through arrays and tables.

Indexed Addressing vs Other Addressing Modes

  • Immediate Addressing → Operand is inside the instruction (e.g., MOV AX, 5).
  • Direct Addressing → Operand is at a fixed memory address (e.g., MOV AX, [1000]).
  • Indirect Addressing → Operand address is stored in a register (e.g., MOV AX, [BX]).
  • Indexed Addressing → Adds flexibility by combining a base + index.

Advantages of Indexed Addressing Mode

  • Ideal for arrays, loops, and tables.
  • Flexible because you can combine base, index, and displacement.
  • Reduces repetitive code for sequential data access.

Limitations of Indexed Addressing Mode

  • Can be slightly slower than direct addressing due to extra calculation.
  • More complex to debug, especially when using multiple offsets.

Indexed Addressing in Different Architectures

x86 Assembly Example:


MOV AX, [BX + SI + 10]

ARM Assembly Example:


LDR R0, [R1, R2]

MIPS Assembly Example:


LW $t0, 4($s1)

Each architecture has its own syntax, but the principle remains the same.

Indexed Addressing in Real-World Programming

High-level languages like C use arrays, but when compiled, they often rely on indexed addressing at the assembly level.


int arr[5] = {10, 20, 30, 40, 50};
x = arr[2];  // becomes MOV AX, [BASE + 2*SIZE]

Here, the index is multiplied by element size and added to the base.

Performance Considerations

Indexed addressing may take extra CPU cycles because the processor must perform addition before accessing memory. However, the flexibility and support for arrays outweigh this cost in most cases.

Common Mistakes with Indexed Addressing

  • Forgetting that indexes often start from 0, not 1.
  • Miscalculating displacement for multi-byte data types.
  • Overlapping memory when two registers point to the same region.

Conclusion

Indexed addressing mode is like having a map with a base point and directions to reach your destination. It simplifies working with arrays, loops, and tables, making it one of the most powerful addressing modes in computer architecture. While it adds some complexity, its benefits in flexibility and real-world use cases make it a cornerstone of low-level programming.