Effective Address Calculation for 20(R1) and -(R2) Addressing Modes
To find an effective address (EA), you apply the rule for each addressing mode to the contents of the specified register.
Key idea: the displacement (e.g., 20) is added to (or used with) a base register, while pre-decrement (e.g., -(R2)) first modifies the register and then uses the updated value as the EA.
We’ll compute:
- (i)
Load 20(R1), R5 - (ii)
Add –(R2), R5
Let:
Addressing modes involved:
- Register-Relative Addressing
d(Rbase) - Displacement
d - Predecrement Addressing
-(R) - Effective Address EA
Effective Addressing Modes (Displacement and Predecrement) — Example Walkthrough
(i) Load 20(R1), R5 → EA calculation
For register-relative (base + displacement) addressing of the form d(R1), the effective address is:
Here, d = 20 and R1 = 1200, so:
Therefore, the memory operand in (i) is located at effective address 1220.
Register-Relative Addressing is exactly what this form represents: base register value plus displacement.
(ii) Add –(R2), R5 → EA calculation
The notation -(R2) indicates pre-decrement addressing:
So the effective address depends on the decrement amount, which is typically the size of the operand (e.g., 1, 2, 4 bytes) in the target architecture / instruction set.
Most textbook problems implicitly assume a decrement of 1 memory unit when the operand-size detail is not provided. Under that common assumption:
- Decrement first:
- Use the updated as the effective address: EA = 4599 $$
Therefore, under the standard assumption of decrement-by-1: the memory operand in (ii) is located at effective address 4599.
If your course specifies operand size (e.g., byte/word/long), replace the “1” with the architecture’s unit decrement (e.g., 2 or 4). The process stays the same; only the decrement amount changes.
Step-by-step: Compute EA for each instruction
- 1Step 1
For (i) use register-relative EA rule . For (ii) use predecrement: decrement first, then equals the updated register.
- 2Step 2
Apply .
- 3Step 3
Predecrement first: (assuming decrement-by-1), then .
Most common assumption in problems like this
When the instruction set’s operand size (byte/word/long) isn’t specified, many architecture homework problems assume predecrement decrements by 1 memory unit. If your course states otherwise, adjust the decrement amount accordingly.
Predecrement requires the decrement amount
The EA for -(R2) is not a single numeric value unless you know how much R2 is decremented (operand size/unit). The base rule is fixed: decrement then use the new register value as EA.
Effective addresses for the two instructions
Computed using R1=1200, R2=4600; (ii) assumes decrement-by-1.
Quick checks & common variants
EA Computation Flashcards
Knowledge Check
For Load 20(R1), R5 with , what is the effective address?