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 animationAn 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
| Mode | Example (8085) | Operand is | Cost |
|---|---|---|---|
| Immediate | MVI A, 42H | In the instruction stream | Fastest; value fixed at assembly |
| Register | MOV A, B | In another register | One cycle, no bus access |
| Direct | LDA 2050H | At an address in the instruction | Extra memory cycle; address fixed |
| Register indirect | MOV A, M | At the address in HL | Address computable at run time |
| Implied | CMA | Implicit in the opcode | Shortest 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
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.