Type a branch, a subject or a topic — “round robin”, “paging”, “civil”.

Addressing Modes

One question — where is the operand? — and each mode is an answer. Indirect addressing is the one that makes arrays, strings and every pointer possible.

Skip to the animation

An addressing mode answers one question — where is the operand? — and the modes trade bytes and cycles against flexibility, with indirect addressing being the one that makes arrays, strings and every pointer in every language possible.

One question

The operand can be in the instruction itself, in a register, or in memory reached in one of two ways. Every mode is an answer to where is the operand, and the trade never changes: fewer bytes and fewer cycles, against more flexibility.

The modes

ModeExample (8085)Operand isCost
ImmediateMVI A, 42HIn the instruction streamFastest; value fixed at assembly
RegisterMOV A, BIn another registerOne cycle, no bus access
DirectLDA 2050HAt an address in the instructionExtra memory cycle; address fixed
Register indirectMOV A, MAt the address in HLAddress computable at run time
ImpliedCMAImplicit in the opcodeShortest of all

Why indirect matters most

Indirect addressing keeps the address in a register, so it can be computed at run time. Increment the register and the same instruction reaches the next location — which is a loop over an array.

Every pointer, string and data structure in every language rests on this one mode. int *p is a register holding an address; *p = 5 is an indirect store; arr[i] is a base plus an index, which is why array access costs about the same as reading a plain variable.

The 8086's additions

The 8085 has five modes. The 8086 adds based, indexed, based-indexed and combinations with displacement — so MOV AX, [BX + SI + 4] computes an address from three parts in one instruction.

That is exactly the shape of a struct field inside an array. The mode was designed for a common pattern, which is the CISC philosophy in one example: add modes to shorten code. RISC goes the other way and computes addresses with explicit arithmetic.

What the choice costs

  • Immediate and register — shortest, fastest, least flexible.
  • Direct — longer instruction, one extra memory cycle, address fixed at assembly time.
  • Indirect and indexed — most flexible, most cycles.

In a tight loop on a small processor the mode chosen can change the running time by a factor of two, which is why hand-written assembly still beats compilers there. On a modern out-of-order CPU with caches, memory locality dominates and addressing-mode cost is nearly invisible — the currency changed, and the reasoning did not.

The numbers you will be asked for

Immediate

operand = the byte(s) following the opcode

Direct

operand = M[address in instruction]

Register indirect

operand = M[register]

Indexed (8086)

address = base + index + displacement

Watch it work

loading visualisation…

Check yourself

question 1 / 4

One question at a time. Pick an answer to see why it is right or wrong, then move on — there is no score to keep and nothing is saved.

Which addressing mode makes arrays and pointers possible?
Why do compilers work so hard at register allocation?
The 8086 adds MOV AX, [BX + SI + 4]. What pattern was that mode designed for?
On a modern out-of-order CPU, how much does the choice of addressing mode cost?

0 / 4

4 still unanswered — the dots above jump straight to them.