Addressing Modes¶
A Mega Note and Book-Chapter-Style Guide for Computer Organization and Architecture¶
An addressing mode is the rule that connects an instruction with its operand. This chapter organizes the supplied material from the basic meaning of an operand and Effective Address to individual addressing modes, combined address calculations, numerical problems, architecture examples, performance considerations, exam-ready answers, and revision.
Technical terms are kept in English because they are standard Computer Organization and Architecture jargon. Short Bangla explanations are retained where they remove common confusion.
Table of Contents¶
Part I â Foundations¶
- The basic idea
- Operand, address, and Effective Address
- Why addressing modes are necessary
- Instruction-format connection
- Notation used in this chapter
- Classification
Part II â Fundamental Addressing Modes¶
- Implied addressing
- Immediate addressing
- Register addressing
- Register-indirect addressing
- Auto-increment and auto-decrement
- Direct addressing
- Memory-indirect addressing
Part III â Relative, Base, Index, and Stack Forms¶
- Relative or PC-relative addressing
- Base-register addressing
- Indexed addressing
- Stack addressing
- Modern displacement and scaled-index forms
Part IV â Comparison and Application¶
- Complete comparison table
- Frequently confused pairs
- Worked numerical problems
- How high-level programs use the modes
- Examples from MIPS, ARM, and x86
- Performance and design considerations
- Common mistakes
Part V â Exam Preparation and Revision¶
- Exam-ready answers
- Practice questions with answers
- Final revision sheet
- āϏāĻšāĻ āĻŦāĻžāĻāϞāĻž āϰāĻŋāĻāĻŋāĻļāύ
Part I â Foundations¶
1. The basic idea¶
A machine instruction must answer two main questions:
- What operation will the processor perform?
- Where will the processor obtain the operand?
The opcode answers the first question. The addressing mode answers the second.
Definition: An addressing mode is the rule used by the processor to interpret an instruction's operand field and locate or obtain the required operand.
Consider:
The symbol X could mean different things:
- the number
Xitself; - register number
X; - memory location
X; - a pointer stored at location
X; - an offset to be added to the PC;
- an offset to be added to a base or index register.
The addressing mode removes this ambiguity.
One idea, different interpretations¶
Suppose the instruction field contains 500.
| Interpretation | Meaning |
|---|---|
| Immediate | Use the number 500 |
| Direct | Use the value stored in M[500] |
| Indirect | Read an address from M[500], then read the operand from that address |
| Relative | Add 500 to the PC |
| Base | Add 500 to a base register |
āĻŦāĻžāĻāϞāĻžā§ āϏāĻšāĻ āĻāĻĨāĻž: Instruction-āĻāϰ address/operand field-āĻ āĻāĻāĻāĻŋ āϏāĻāĻā§āϝāĻž āĻĻā§āĻāϞā§āĻ āϏā§āĻāĻŋ data āύāĻžāĻāĻŋ address āĻŦā§āĻāĻž āϝāĻžā§ āύāĻžāĨ¤ Addressing mode āĻŦāϞ⧠āĻĻā§ā§ āϏāĻāĻā§āϝāĻžāĻāĻŋāĻā§ āĻā§āĻāĻžāĻŦā§ āĻŦā§āϝāĻŦāĻšāĻžāϰ āĻāϰāϤ⧠āĻšāĻŦā§āĨ¤
2. Operand, address, and Effective Address¶
These three terms must not be mixed.
Operand¶
The operand is the actual data used by an operation.
For:
the values stored in R1 and R2 are operands.
Address¶
An address identifies a location in memory.
If 1200 is an address, then M[1200] means the value stored at location 1200.
Effective Address¶
The Effective Address (EA) is the final memory address calculated by the processor for a memory operand.
If:
then in base-plus-displacement addressing:
The most important distinction¶
If the instruction only uses a register or an immediate constant, a memory EA may not be required at all.
3. Why addressing modes are necessary¶
3.1 Programming flexibility¶
Programs operate on constants, registers, variables, pointers, arrays, structures, stacks, and branch targets. One addressing rule would make some of these operations difficult or inefficient.
3.2 Shorter instructions¶
A register can be named with only a few bits. For example, selecting one of 32 registers needs only 5 bits. Embedding a full 32-bit or 64-bit address would require a much larger instruction.
3.3 Faster execution¶
Register and immediate operands avoid an extra data-memory read. This usually makes them faster than memory-based operands.
3.4 Relocation¶
Relative and base-register modes let a program or data block move without changing every instruction address.
3.5 Efficient data structures¶
- Arrays need indexing.
- Linked lists need pointers.
- Records need base plus field offset.
- Stacks need automatic pointer adjustment.
- Loops need nearby relative branches.
3.6 Larger address reach¶
An instruction may hold only a small displacement, but a register can hold a full machine address. Combining both provides compact instructions and a large address space.
4. Instruction-format connection¶
A general instruction may be represented as:
+----------+----------+-------------+----------------------+
| Opcode | Mode bit | Register(s) | Address/Displacement |
+----------+----------+-------------+----------------------+
The exact fields depend on the ISA.
Mode field¶
The mode field tells the control unit how to interpret the operand field.
Example:
| Mode bits | Possible interpretation |
|---|---|
00 |
Immediate |
01 |
Register |
10 |
Direct |
11 |
Register indirect |
This is only an illustrative encoding. A real ISA may encode modes through opcode variants rather than a separate mode field.
Trade-off¶
More addressing modes provide flexibility, but their encodings consume instruction bits and can make decoding more complex. RISC architectures usually keep a small, regular set. CISC architectures often support many combinations.
5. Notation used in this chapter¶
| Symbol | Meaning |
|---|---|
A |
Address, constant, or displacement field in the instruction |
R |
A register named by the instruction |
BR |
Base register |
IX |
Index register |
PC |
Program Counter |
SP |
Stack Pointer |
(R) |
Contents of register R |
M[x] |
Contents of memory location x |
EA |
Effective Address |
d |
Size of an accessed item |
â |
Assignment or data transfer |
The parentheses and square brackets have different roles:
6. Classification¶
flowchart TD
A["Addressing Modes"] --> B["No explicit memory address"]
A --> C["Memory address supplied directly or indirectly"]
A --> D["Register plus displacement"]
B --> B1["Implied"]
B --> B2["Immediate"]
B --> B3["Register"]
C --> C1["Direct"]
C --> C2["Memory indirect"]
C --> C3["Register indirect"]
D --> D1["Relative"]
D --> D2["Base register"]
D --> D3["Indexed / scaled index"]
Auto-increment and auto-decrement are normally treated as special register-indirect modes. Stack addressing is often treated as an implied or specialized register-indirect mode.
Part II â Fundamental Addressing Modes¶
7. Implied addressing¶
Definition¶
In implied addressing, the operand is specified implicitly by the opcode or processor architecture. The instruction does not contain an explicit operand address.
Rule¶
Examples¶
CMA ; complement accumulator
CLC ; clear carry flag
STC ; set carry flag
NOP ; no operation
RET ; use the return address through the implied stack mechanism
Internal operation example¶
For CMA:
The accumulator AC is not written in the instruction; the opcode implies it.
Advantages¶
- Very short instruction.
- No operand-address calculation.
- Simple decoding for fixed operations.
Limitations¶
- The programmer cannot choose a different operand.
- It is suitable only when the architecture defines a natural fixed operand.
Typical uses¶
- flag operations;
- accumulator operations;
- stack operations;
- processor-control instructions.
Key warning¶
Implied addressing does not mean that the instruction has no effect on data. It means that the affected data location is already understood.
8. Immediate addressing¶
Definition¶
In immediate addressing, the actual operand is included in the instruction.
Rule¶
No EA is needed for the source constant.
Examples¶
The # symbol commonly indicates a literal constant, though syntax varies by assembler.
Data path¶
flowchart LR
I["Instruction field"] --> S["Sign/zero extension"]
S --> A["ALU input"]
Sign extension and zero extension¶
If the immediate field is shorter than the register width, it must be extended.
Example: an 8-bit immediate 1111 1100.
- Sign-extended to 16 bits:
1111 1111 1111 1100=-4 - Zero-extended to 16 bits:
0000 0000 1111 1100=252
The opcode determines which extension rule is used.
Advantages¶
- No data-memory read for the operand.
- Fast and compact for small constants.
- Useful for initialization and arithmetic with fixed values.
Limitations¶
- The constant range is limited by field width.
- The constant is fixed inside the instruction.
- Large constants may require multiple instructions.
Range example¶
For a 12-bit signed immediate:
For a 12-bit unsigned immediate:
9. Register addressing¶
Definition¶
The instruction names a CPU register containing the operand.
Rule¶
Example¶
In a two-address machine:
In a three-address RISC machine:
Why the encoding is compact¶
If the processor has:
- 8 registers, a register number needs 3 bits;
- 16 registers, it needs 4 bits;
- 32 registers, it needs 5 bits.
This is much smaller than a full memory address.
Advantages¶
- Very fast access.
- No data-memory access for the register operand.
- Small operand field.
- Reduces pressure on the memory bus.
Limitations¶
- Register count is limited.
- Values must first be loaded from memory when not already in registers.
Key warning¶
The register number is not an EA. If the instruction names R5, the operand is the contents of R5, not M[5].
10. Register-indirect addressing¶
Definition¶
The instruction names a register that contains the memory address of the operand.
Formula¶
Worked example¶
Given:
Instruction:
Execution:
Data path¶
flowchart LR
R["Register R"] --> EA["Effective Address"]
EA --> M["Memory"]
M --> O["Operand"]
Advantages¶
- Natural pointer support.
- The register can hold a full-width address.
- The same instruction can access many locations by changing the register.
- Useful for dynamic data structures and sequential traversal.
Limitations¶
- A data-memory access is needed.
- A register must be occupied by the address.
Register versus register indirect¶
Suppose R2 = 1200 and M[1200] = 75.
| Mode | Result |
|---|---|
| Register | Operand = 1200 |
| Register indirect | Operand = 75 |
11. Auto-increment and auto-decrement¶
These modes combine memory access and address-register update.
11.1 Auto-increment¶
Rule¶
Example:
If R2 = 2000, a 32-bit word occupies 4 bytes, and M[2000] = 90:
The old address is used before the register changes.
11.2 Auto-decrement¶
Rule¶
Example:
If R2 = 2004 and d = 4:
The register changes before the access.
Why d matters¶
Address registers usually hold byte addresses.
| Data type | Typical update |
|---|---|
| Byte | 1 |
| Halfword | 2 |
| Word | 4 |
| Doubleword | 8 |
Uses¶
- scanning arrays;
- reading strings;
- block copy;
- stack push/pop;
- processing buffers.
Stack example¶
In a descending stack, push may behave like:
Pop may behave like:
Key warning¶
Auto-increment is commonly post-increment, while auto-decrement is commonly pre-decrement. Check the assembly syntax and ISA definition.
12. Direct addressing¶
Definition¶
The address field of the instruction directly specifies the memory address of the operand.
Formula¶
Example¶
Given:
Instruction:
Result:
Data path¶
flowchart LR
A["Instruction address A"] --> EA["EA = A"]
EA --> M["Memory"]
M --> O["Operand"]
Advantages¶
- Simple EA calculation.
- Easy to understand.
- Useful for fixed variables and memory-mapped I/O addresses.
Limitations¶
- Address range is restricted by the field width.
- The fixed address reduces relocation flexibility.
- Requires a data-memory access.
Address range example¶
If the direct-address field is 16 bits:
This cannot directly identify every location in a larger address space.
13. Memory-indirect addressing¶
Definition¶
The instruction address field identifies a memory location containing the final operand address.
Formula¶
Worked example¶
Given:
Execution:
Data path¶
flowchart LR
A["Instruction field A"] --> P["Memory pointer M[A]"]
P --> EA["EA"]
EA --> M["Memory operand M[EA]"]
Advantages¶
- Supports pointers stored in memory.
- The pointer can change without changing the instruction.
- A memory word can hold a full address.
Limitations¶
- Normally two data-memory reads are required.
- It is slower and increases memory traffic.
Memory-reference count¶
Ignoring instruction fetch:
| Mode | Extra data-memory reads to obtain source operand |
|---|---|
| Immediate | 0 |
| Register | 0 |
| Direct | 1 |
| Register indirect | 1 |
| Memory indirect | 2 |
Key warning¶
In indirect addressing:
Do not treat the first memory value as the final data.
Part III â Relative, Base, Index, and Stack Forms¶
14. Relative or PC-relative addressing¶
Definition¶
A signed displacement is added to the Program Counter to calculate the target address.
Formula¶
The ISA may define (PC) as the current instruction address or, more commonly, the address of the next instruction.
Positive displacement¶
Negative displacement¶
Typical use¶
Why branches use it¶
Branch targets are usually close to the current instruction. A small signed displacement can encode these targets efficiently.
Relocation benefit¶
Suppose code moves from address 1000 to 5000. If the branch source and target move together, their relative distance stays unchanged. Therefore, the encoded displacement may remain valid.
Range calculation¶
For a signed n-bit displacement:
If instructions are 4-byte aligned and the displacement counts instructions:
Example, 16-bit signed word offset:
Common mistake¶
Students often add the displacement to the wrong PC. If the processor has already incremented PC during fetch, use the incremented PC when the ISA specifies it.
15. Base-register addressing¶
Definition¶
A base register contains the starting address of a memory region, and the instruction supplies a displacement.
Formula¶
Worked example¶
Conceptual model¶
Main uses¶
Structure field¶
If a student record begins at 5000 and the roll field is 12 bytes from the beginning:
Stack frame¶
If frame pointer FP = 8000 and a local variable is at offset â16:
Program relocation¶
Instructions may retain the same offsets while the base register changes to the program's new memory region.
Advantages¶
- Compact encoding.
- Full-address reach through the register.
- Supports relocation, structures, and stack frames.
Limitations¶
- The displacement has a limited range.
- A register must hold the base address.
16. Indexed addressing¶
Definition¶
An index register is combined with a fixed address or base to access an element within an array, string, or table.
Classical formula¶
Here, A is often the array's starting address, and (IX) changes during a loop.
Array example¶
An array begins at 2000. Each element is 4 bytes. We need A[6].
If the index register stores the byte offset:
If the architecture supports scaling:
Multidimensional array¶
For a row-major array:
Example:
Base = 1000
Columns = 5
i = 2
j = 3
Element size = 4
EA = 1000 + ((2 Ã 5) + 3) Ã 4
= 1000 + 13 Ã 4
= 1052
Advantages¶
- Efficient array and table access.
- The instruction's fixed part can remain unchanged while the index changes.
- Scaled indexing directly supports element sizes.
Limitations¶
- EA calculation is more complex.
- The programmer/compiler must know whether the index is an element number or byte offset.
17. Stack addressing¶
Definition¶
The operand is at or near the top of a stack, usually identified implicitly by the Stack Pointer.
Basic rule¶
The operation may also update SP.
Examples¶
Why it may be called implied¶
In PUSH R1, the source register is explicit, but the memory destination is implied by SP. In RET, even the return-address source is often implied by the stack mechanism.
Main uses¶
- procedure calls;
- return addresses;
- saved registers;
- parameters;
- local variables;
- expression evaluation.
18. Modern displacement and scaled-index forms¶
Real processors often combine the basic modes.
Base plus displacement¶
Used by MIPS and many RISC load/store instructions.
Base plus index¶
Useful when both an object base and a changing offset are held in registers.
Base plus scaled index plus displacement¶
This is a powerful x86-style form.
Example:
Possible interpretation:
Basepoints to a record or array;Index à 4selects an integer element;12selects a field or subarray offset.
Scale values¶
Common scale factors are 1, 2, 4, and 8, matching common element sizes.
Part IV â Comparison and Application¶
19. Complete comparison table¶
| Mode | EA / operand rule | Operand location | Data-memory reads* | Main use |
|---|---|---|---|---|
| Implied | Fixed by opcode | Implied register/flag/stack | 0 or operation-dependent | Flags, accumulator, control |
| Immediate | Operand = A |
Instruction | 0 | Constants |
| Register | Operand = (R) |
Register | 0 | Fast temporary data |
| Register indirect | EA = (R) |
Memory | 1 | Pointers |
| Auto-increment | EA=(R); then RâR+d |
Memory | 1 | Forward traversal |
| Auto-decrement | RâRâd; then EA=(R) |
Memory | 1 | Stack/reverse traversal |
| Direct | EA = A |
Memory | 1 | Fixed variables |
| Memory indirect | EA = M[A] |
Memory | 2 | Pointer stored in memory |
| Relative | EA = (PC) + A |
Usually target address | 0 for branch target calculation | Branches |
| Base register | EA = (BR) + A |
Memory | 1 | Frames, relocation, structures |
| Indexed | EA = A + (IX) |
Memory | 1 | Arrays, tables |
| Stack | EA = (SP) |
Stack memory | Operation-dependent | Calls, push/pop |
*Instruction fetch is not counted. A store writes memory rather than reading the final operand.
20. Frequently confused pairs¶
20.1 Immediate versus direct¶
If A = 500 and M[500] = 80:
| Mode | Operand |
|---|---|
| Immediate | 500 |
| Direct | 80 |
20.2 Register versus register indirect¶
If R = 1200 and M[1200] = 75:
| Mode | Operand |
|---|---|
| Register | 1200 |
| Register indirect | 75 |
20.3 Direct versus memory indirect¶
If A=500, M[500]=1200, and M[1200]=75:
| Mode | EA | Operand |
|---|---|---|
| Direct | 500 | 1200 |
| Indirect | 1200 | 75 |
20.4 Base versus indexed¶
The arithmetic may be identical:
The intended role differs:
| Base register | Index register |
|---|---|
| Holds the start of a region/object | Holds a changing position |
| Displacement often selects a field | Fixed address often names an array |
| Good for relocation and stack frames | Good for loops and arrays |
In modern architectures, the distinction may be mostly conceptual.
20.5 Relative versus base¶
Relative addressing uses the PC automatically. Base addressing names another register.
21. Worked numerical problems¶
Problem 1: Identify the operand in several modes¶
Given:
Immediate¶
Register¶
Direct¶
Memory indirect¶
Register indirect¶
Relative¶
For a branch, 1400 is the target; the processor does not normally fetch a data operand from M[1400].
Problem 2: Auto-increment¶
Given:
Instruction:
Solution:
Problem 3: Auto-decrement¶
Given:
Instruction:
Solution:
Problem 4: Signed PC-relative branch¶
Given:
Address of branch instruction = 1000
Instruction length = 4 bytes
Encoded displacement = â20 bytes
ISA uses next PC as base
First:
Then:
Problem 5: Indexed array¶
An array A starts at address 3000. Each element is 8 bytes. Find A[9].
Problem 6: Base register and structure¶
A structure starts at address 6000. A 4-byte field begins 28 bytes from the start.
The bytes of the field begin at 6028.
Problem 7: x86-style scaled indexing¶
Given:
22. How high-level programs use the modes¶
Constant¶
C:
Assembly idea:
Mode: immediate.
Local arithmetic¶
C:
After values are loaded:
Mode: register.
Pointer dereference¶
C:
Assembly idea:
Mode: register indirect.
Structure field¶
C:
Assembly idea:
Mode: base plus displacement.
Array element¶
C:
Assembly idea:
Mode: indexed or scaled indexed.
Loop branch¶
C:
Assembly idea:
Mode: PC-relative for the branch target.
23. Examples from MIPS, ARM, and x86¶
23.1 MIPS¶
MIPS has a small, regular set of addressing forms.
Register¶
Immediate¶
Base plus displacement¶
PC-relative branch¶
Pseudo-direct jump¶
Traditional MIPS jump instructions combine an instruction field with upper PC bits. This is commonly discussed separately from the basic data-addressing modes.
23.2 ARM / AArch64¶
ARM supports register, immediate, base-plus-offset, and update forms.
Conceptually:
[X1, #16]: base plus displacement;[X1], #8: post-index/update;[X1, #-8]!: pre-index/update.
23.3 x86¶
x86 supports rich combinations:
This combines base, scaled index, and displacement in one instruction.
Architectural lesson¶
The mathematical ideas are shared, but syntax and exact behavior differ. Always use the ISA manual when exact encoding, PC value, sign extension, or update order matters.
24. Performance and design considerations¶
Register and immediate modes¶
These usually provide the fastest operand supply because they avoid an extra data-cache lookup. They also reduce memory traffic.
Memory modes¶
Direct, register-indirect, base, and indexed modes require a memory access. Actual time depends heavily on the cache hierarchy.
Memory indirect¶
It may create a serial dependency:
The second access cannot begin until the first produces the address.
Complex EA calculation¶
Modern processors usually contain an Address Generation Unit (AGU) that calculates forms such as:
Complex addressing can reduce instruction count, but it consumes hardware resources and may affect scheduling or throughput.
Code density¶
Rich addressing modes can perform more work per instruction and improve code density. Regular RISC modes simplify decoding and pipelining. Modern designs balance these goals differently.
25. Common mistakes¶
- Treating immediate data as a memory address.
- Treating a register number as the operand instead of reading the register.
- Forgetting the final memory access after calculating EA.
- Stopping at
M[A]in memory-indirect mode. - Counting instruction fetch as a data-memory reference when the question excludes it.
- Forgetting sign extension for a negative displacement.
- Using the current PC when the ISA specifies the next PC.
- Incrementing by 1 when the operand occupies 4 or 8 bytes.
- Mixing pre-decrement with post-decrement.
- Multiplying an index by element size twice.
- Claiming base and index modes are mathematically different in every ISA.
- Forgetting that branch EA is a target address, not usually a data operand address.
Part V â Exam Preparation and Revision¶
26. Exam-ready answers¶
Short definition: What is addressing mode?¶
An addressing mode is the method used by a processor to interpret an instruction's operand field and determine where the operand is located. It may provide the operand directly, identify a register, specify a memory address, or calculate an Effective Address using registers and displacement values. Addressing modes improve flexibility, code density, relocation, and support for data structures.
Explain Effective Address¶
The Effective Address is the final memory address calculated by the processor for a memory operand. It is produced according to the selected addressing mode. For example, in direct addressing EA=A; in register-indirect addressing EA=(R); and in base-register addressing EA=(BR)+A. After EA is obtained, the memory operand is normally read as M[EA].
Five-mark comparison¶
| Mode | Formula | One use |
|---|---|---|
| Immediate | Operand=A |
Constants |
| Register | Operand=(R) |
Fast arithmetic |
| Direct | EA=A |
Fixed variable |
| Register indirect | EA=(R) |
Pointer |
| Relative | EA=(PC)+A |
Branch |
| Indexed | EA=A+(IX) |
Array |
Ten-mark descriptive answer structure¶
For a long answer:
- Define addressing mode and EA.
- State why modes are required.
- Explain each requested mode.
- Write its EA/operand formula.
- Give one instruction example.
- Mention one advantage and one use.
- Add a comparison table.
- Finish with a short conclusion.
Conclusion paragraph¶
Addressing modes form the link between an instruction and its data. Simple modes such as immediate and register provide speed, while indirect, base, indexed, relative, and auto-update modes provide pointer support, relocation, arrays, branches, and stack operations. The choice of mode affects instruction size, memory references, execution speed, and programming flexibility.
27. Practice questions with answers¶
Q1. What is the difference between EA and operand?¶
Answer: EA is the final memory address. The operand is the data stored at that address. Thus, for a memory operand, EA is an address and M[EA] is the data.
Q2. Which modes need no data-memory read for a source operand?¶
Answer: Immediate and register modes. Implied mode may also avoid a data-memory read when the implied operand is a register or flag.
Q3. Which mode normally needs two data-memory reads?¶
Answer: Memory-indirect addressing: one read obtains the pointer and the second obtains the operand.
Q4. Why is relative addressing suitable for branches?¶
Answer: Branch targets are usually close to the branch instruction. A small signed offset is enough, and the code remains relocatable if source and target move together.
Q5. Why is register-indirect addressing useful for pointers?¶
Answer: A pointer is an address. When the address is held in a register, register-indirect addressing uses that register value as EA and accesses the pointed memory location.
Q6. If R2=500, M[500]=900, and M[900]=30, find the operand.¶
| Mode | Operand |
|---|---|
| Register | 500 |
| Register indirect | 900 |
If instruction field A=500:
| Mode | Operand |
|---|---|
| Direct | 900 |
| Memory indirect | 30 |
Q7. What is the role of scaling in indexed addressing?¶
Answer: Scaling converts an element index into a byte offset. For 4-byte elements, index i requires offset iÃ4.
Q8. What is the difference between post-increment and pre-decrement?¶
Answer: Post-increment uses the old register value as EA and increments afterward. Pre-decrement reduces the register first and uses the new value as EA.
28. Final revision sheet¶
Formulas¶
Implied Operand is understood from opcode
Immediate Operand = A
Register Operand = (R)
Register indirect EA = (R); Operand = M[(R)]
Auto-increment EA = (R); R â R + d after access
Auto-decrement R â R â d; EA = (R) after update
Direct EA = A; Operand = M[A]
Memory indirect EA = M[A]; Operand = M[M[A]]
Relative EA = (PC) + A
Base register EA = (BR) + A
Indexed EA = A + (IX)
Scaled indexed EA = Base + Index à Scale + Displacement
Stack EA = (SP), with architecture-defined update
One-line memory trick¶
Immediate = value in instruction
Register = value in register
Direct = address in instruction
Register indirect = address in register
Indirect = address in memory
Relative = PC + offset
Base = base + offset
Indexed = array base + changing index
Speed tendency¶
This is a conceptual tendency. Cache behavior and processor implementation determine actual performance.
29. āϏāĻšāĻ āĻŦāĻžāĻāϞāĻž āϰāĻŋāĻāĻŋāĻļāύ¶
Addressing Mode āĻā§?¶
Processor instruction-āĻāϰ operand āĻā§āĻĨāĻžā§ āĻāĻā§ āĻŦāĻž āĻā§āĻāĻžāĻŦā§ operand āĻŦā§āϰ āĻāϰāϤ⧠āĻšāĻŦā§âāĻāĻ āύāĻŋā§āĻŽāĻā§āĻ Addressing Mode āĻŦāϞā§āĨ¤
EA āĻā§?¶
EA āĻŦāĻž Effective Address āĻšāϞ⧠calculation āĻāϰāĻžāϰ āĻĒāϰ āĻĒāĻžāĻā§āĻž operand-āĻāϰ final memory addressāĨ¤
EA = operand-āĻāϰ āĻ āĻŋāĻāĻžāύāĻž
M[EA] = āϏā§āĻ āĻ āĻŋāĻāĻžāύāĻžā§ āĻĨāĻžāĻāĻž āĻāϏāϞ data
āĻā§āĻŦ āϏāĻšāĻā§ āϏāĻŦ mode¶
| Mode | āϏāĻšāĻ āĻŦāĻžāĻāϞāĻž āĻ āϰā§āĻĨ |
|---|---|
| Implied | operand āϞā§āĻāĻž āύā§āĻ; opcode āĻĻā§āĻā§āĻ CPU āĻŦā§āĻā§ āύā§ā§ |
| Immediate | instruction-āĻāϰ āĻŽāϧā§āϝā§āĻ āĻāϏāϞ data āĻĻā§āĻā§āĻž |
| Register | register-āĻāϰ āĻāĻŋāϤāϰ⧠āĻāϏāϞ data |
| Register indirect | register-āĻāϰ āĻāĻŋāϤāϰ⧠data-āĻāϰ memory address |
| Direct | instruction-āĻ āϏāϰāĻžāϏāϰāĻŋ memory address |
| Indirect | instruction āϝ⧠memory location āĻĻā§āĻāĻžā§, āϏā§āĻāĻžāύ⧠āĻāĻŦāĻžāϰ āĻāϏāϞ address āϰāĻžāĻāĻž |
| Relative | PC-āĻāϰ āϏāĻā§āĻā§ offset āϝā§āĻ āĻāϰ⧠address |
| Base | base register-āĻāϰ āϏāĻā§āĻā§ offset āϝā§āĻ |
| Indexed | array-āĻāϰ base-āĻāϰ āϏāĻā§āĻā§ index āϝā§āĻ |
| Auto-increment | access āĻāϰāĻžāϰ āĻĒāϰ pointer āϏāĻžāĻŽāύ⧠āϝāĻžā§ |
| Auto-decrement | pointer āĻāĻā§ āĻĒā§āĻāύ⧠āϝāĻžā§, āϤāĻžāϰāĻĒāϰ access āĻšā§ |
āϏāĻŦāĻā§ā§ā§ āĻā§āϰā§āϤā§āĻŦāĻĒā§āϰā§āĻŖ āĻĒāĻžāϰā§āĻĨāĻā§āϝ¶
āϧāϰāĻŋ:
āϤāĻžāĻšāϞā§:
āĻāĻŦāĻžāϰ instruction field A=500 āĻšāϞā§:
āĻĒāϰā§āĻā§āώāĻžāϰ āĻāĻā§ āĻŽāύ⧠āϰāĻžāĻāĻŦā§āύ¶
- Immediate-āĻ āϏāĻāĻā§āϝāĻž āĻšāϞ⧠dataāĨ¤
- Direct-āĻ āϏāĻāĻā§āϝāĻž āĻšāϞ⧠addressāĨ¤
- Register-āĻ register-āĻāϰ value āĻšāϞ⧠dataāĨ¤
- Register indirect-āĻ register-āĻāϰ value āĻšāϞ⧠addressāĨ¤
- Indirect-āĻ āĻĻā§āĻ āϧāĻžāĻĒā§ memory access āĻšā§āĨ¤
- Relative branch-āĻ PC-āĻāϰ āϏāĻā§āĻā§ signed offset āϝā§āĻ āĻšā§āĨ¤
- Array-āĻāϰ index-āĻā§ element size āĻĻāĻŋā§ā§ āĻā§āĻŖ āĻāϰāϤ⧠āĻšāϤ⧠āĻĒāĻžāϰā§āĨ¤
- Auto-update āϏāĻžāϧāĻžāϰāĻŖāϤ data size āĻ āύā§āϝāĻžā§ā§ āĻšā§, āϏāĻŦāϏāĻŽā§ 1 āĻāϰ⧠āύā§āĨ¤