08 Addressing Modes
đ§ The 10-Mode Mnemonic
If Dhaka Is Really Raining, I Rather Always Stay Bed!
(Meaningful & Relatable: If it's pouring rain outside in Dhaka's traffic, the best decision is to just stay in bed!)
đ The 10-Mode Breakdown
âĸ đ§ī¸ If â Immediate Mode
âĸ đ Dhaka â Direct Mode
âĸ đ§ī¸ Is â Indirect Mode
âĸ đĻ Really â Register Mode
âĸ âī¸ Raining, â Register Indirect Mode
âĸ đ I â Indexed Mode
âĸ đ´ Rather â Relative Mode
âĸ đ Always â Auto-increment/decrement Mode
âĸ đ¤ Stay â Stack Mode
âĸ đī¸ Bed! â Base Register Mode
The Complete 10-Mode Breakdown
- I â Immediate: The operand value is directly hardcoded into the instruction (e.g., MOV R1, #5).
- D â Direct (Absolute): The instruction gives the exact memory address of the data.
- I â Indirect: The instruction points to a memory address, which holds another address where the data is actually stored.
- R â Register: The operand is stored inside a CPU register rather than memory.
- R â Register Indirect: A CPU register holds the memory address of the data.
- I â Indexed: Calculates the final address by adding a constant offset to an index register.
- R â Relative (PC-Relative): The address is calculated as an offset relative to the Program Counter (used for jumps/branches).
⨠The 3 Added Modes:
8. A â Auto-Increment / Auto-Decrement: Similar to register indirect, but automatically changes the register pointer value after (or before) accessing the memoryâgreat for stepping through arrays.
9. S â Stack: The operand is implicitly located at the top of the system stack (e.g., PUSH and POP operations).
10. B â Base Register (Implied/Displacement): The address is calculated by adding a displacement to a base register, allowing programs to relocate smoothly in memory.
Why the difference?
Different CPU architectures (like RISC vs. CISC) implement varying numbers of modes. While RISC architectures use fewer, simpler modes, comprehensive Computer Organization courses list all 10 unique configurations to cover everything from basic constants to complex data structure lookups.
Addressing Mode: ā§§ā§ĻāĻāĻŋāϰ Mnemonic¶
ā§§ā§ĻāĻāĻŋ Mode (āϏāĻŋāϰāĻŋāϝāĻŧāĻžāϞ)¶
- Implied
- Immediate
- Register
- Register Indirect
- Direct
- Indirect
- Relative
- Indexed
- Base Register
- Auto Increment/Decrement
Mnemonic (āĻĒā§āϰāĻĨāĻŽ āĻ āĻā§āώāϰ: I I R R D I R I B A)¶
"I Imagine Rabbits Run Down In Rainy Isolated Bushes, Always"
| āĻ āĻā§āώāϰ | Mode |
|---|---|
| I | Implied |
| Imagine | Immediate |
| Rabbits | Register |
| Run | Register indirect |
| Down | Direct |
| In | Indirect |
| Rainy | Relative |
| Isolated | Indexed |
| Bushes | Base register |
| Always | Auto inc/dec |
āĻŦāĻžāĻāϞāĻžāϝāĻŧ āĻŽāύ⧠āϰāĻžāĻāĻžāϰ āϏāĻšāĻ āĻāĻĒāĻžāϝāĻŧ: "Operand āĻā§āĻĨāĻžāϝāĻŧ āĻāĻā§?"¶
āϧāĻžāĻĒ ā§§: Operand instruction-āĻāϰ āĻā§āϤāϰā§āĻ (Memory āϞāĻžāĻā§ āύāĻž)
- Implied: Operand āĻŦāϞāĻžāϰ āĻĻāϰāĻāĻžāϰāĻ āύā§āĻ (āϝā§āĻŽāύ CLA, HLT)
- Immediate: Operand āύāĻŋāĻā§āĻ instruction-āĻ āĻāĻā§ (MOV A, 5)
āϧāĻžāĻĒ ā§¨: Operand Register-āĻ
- Register: Register-āĻ āϏāϰāĻžāϏāϰāĻŋ āĻĄāĻžāĻāĻž (MOV A, B)
- Register Indirect: Register-āĻ āĻĄāĻžāĻāĻž āύā§āĻ, āĻĄāĻžāĻāĻžāϰ address āĻāĻā§ (MOV A, [BX])
āϧāĻžāĻĒ ā§Š: Operand Memory-āϤā§
- Direct: Instruction-āĻ memory address āĻĻā§āĻāϝāĻŧāĻž āĻāĻā§ (LDA 2000H)
- Indirect: Address-āĻāϰ āĻā§āϤāϰ⧠āĻāϰā§āĻāĻāĻž address āĻāĻā§ (āĻĻā§āĻāĻŦāĻžāϰ memory āϝā§āϤ⧠āĻšāϝāĻŧ)
āϧāĻžāĻĒ ā§Ē: Address āĻšāĻŋāϏāĻžāĻŦ āĻāϰ⧠āĻŦā§āϰ āĻāϰāϤ⧠āĻšāϝāĻŧ
- Relative: PC + offset (branch/jump-āĻ āĻŦā§āϝāĻŦāĻšāĻžāϰ āĻšāϝāĻŧ)
- Indexed: Index register + address (array-āϰ āĻāύā§āϝ)
- Base Register: Base register + offset (relocation/segment-āĻāϰ āĻāύā§āϝ)
- Auto inc/dec: Access-āĻāϰ āĻāĻā§/āĻĒāϰ⧠register āύāĻŋāĻā§ +1 āĻŦāĻž -1 āĻšāϝāĻŧ (stack, loop)
āĻŽāύ⧠āϰāĻžāĻāĻžāϰ āĻā§āϰāĻŋā϶
- Indexed āĻŦāύāĻžāĻŽ Base: Index = array-āϰ index āĻŦāĻĻāϞāĻžāϝāĻŧ, address fixedāĨ¤ Base = base āĻŦāĻĻāϞāĻžāϝāĻŧ, offset fixedāĨ¤
- Direct āĻŦāύāĻžāĻŽ Indirect: Direct = āϏā§āĻāĻž āϝāĻžāĻāĨ¤ Indirect = āĻĒāĻĨā§ āĻāϰā§āĻāĻāύāĻā§ āĻāĻŋāĻā§āĻā§āϏ āĻāϰ⧠āϝāĻžāĻ (extra memory access)āĨ¤
- Relative: āϏāĻŦāϏāĻŽāϝāĻŧ PC-āĻāϰ āϏāĻžāĻĨā§ āϏāĻŽā§āĻĒāϰā§āĻāĻŋāϤ, "relative" āĻŽāĻžāύ⧠āĻāϤā§āĻŽā§āϝāĻŧ, PC-āϰ āĻāϤā§āĻŽā§āϝāĻŧāĨ¤
āĻŦāĻāĻā§āĻĻā§ āĻŽā§āĻĄ āϏāĻāĻā§āϝāĻž ⧝ āĻŦāĻž ā§§ā§Ļ āĻšāϤ⧠āĻĒāĻžāϰ⧠(āĻāĻŋāĻā§ āĻŦāĻ Auto increment āĻ Auto decrement āĻāϞāĻžāĻĻāĻž āϧāϰā§, āĻāĻŋāĻā§ āĻŦāĻ Implied āĻ Immediate-āĻā§ āĻāĻāϏāĻžāĻĨā§ āϰāĻžāĻā§)āĨ¤ āϤā§āĻŽāĻžāϰ āĻŦāĻāϝāĻŧā§ āĻā§āύ āĻā§āύāĻāĻž āĻāĻā§ āĻŦāϞāϞ⧠āĻŽāĻŋāϞāĻŋāϝāĻŧā§ mnemonic āĻ āĻŋāĻ āĻāϰ⧠āĻĻā§āĻŦāĨ¤