Home / Learn Chip Programming / Addressing Modes in Depth

Addressing Modes in Depth

Addressing modes are the different ways an instruction can name its data. They explain pointers, arrays and structs at machine level.

In shortAddressing modes are the different ways an instruction can name its data. They explain pointers, arrays and structs at machine level.

Theory in plain words

Indexed addressingBase register R1 = 0x20+ offset 4Effective address 0x24Read memory[0x24]
Indexed addressing

What it is

Immediate: the value is in the instruction. Register: in a register. Direct: at a fixed address. Indirect: a register holds the address. Indexed: base register plus offset. Auto increment: pointer moves after use.

Why we use it

The mode decides speed and code size. High level features (pointers, arrays, struct fields, stack variables, jumps) map to specific modes.

How it works

The CPU computes an effective address (EA) from the instruction fields and register contents, then reads or writes memory at EA.

Where it is used

  • Reading assembly and compiler output
  • Writing efficient drivers
  • Understanding pointers

Try each mode

Effective address and operandTry it Yourself

Indexed mode with base 8 and offset 4 reads address 12: exactly how arr[4] works when R1 points to the start of the array.

C codeMode used
x = 5;immediate
x = y; (both in registers)register
x = global_var;direct / PC relative
x = *p;indirect (register holds the pointer)
x = arr[i]; or p->fieldindexed / base plus offset
*p++ = c;auto increment
local variablestack pointer plus offset
goto / function callPC relative or absolute

Quick quiz

1. Which mode matches *p in C?

2. Which mode matches arr[i]?

Common questions

Which mode matches *p in C?

Indirect. A register holds the address of the data.

Which mode matches arr[i]?

Indexed (base plus offset). Base address plus scaled index.