A 4-byte instruction is stored in memory at address 1000. The address field of…
A 4-byte instruction is stored in memory at address 1000. The address field of the instruction is at location 1002. The operand used during the execution of the instruction is stored at location X. Choose the correct expression to find X if PC relative addressing mode is used.
(For ex: M [10] represents accessing the value at memory location 10).
Answer: C. X = 1004 + M[1002] — X is the effective address of the operand. Since it is PC relative addressing mode, offset will be added to the latest PC value to get the effective address.…
- A.
X = 1000 + M[1002]
- B.
X = 1002 + M[1004]
- C.
X = 1004 + M[1002]
- D.
X = 1000 + M[1004]
Attempted by 18 students.
Show answer & explanation
Correct answer: C
X is the effective address of the operand.
Since it is PC relative addressing mode, offset will be added to the latest PC value to get the effective address.
Here the address field of the instruction is at 1002. The offset value will be stored at the address field of the instruction at 1002.
X = PC + M[1002]
The given instruction is at address 1000. Each instruction is 4 bytes long. So the latest value of PC will be = 1000+4 = 1004.
X = 1004 + M[1002]