Which of the following addressing modes are suitable for program relocation at…
2004
Which of the following addressing modes are suitable for program relocation at run time ?
(i) Absolute addressing
(ii) Based addressing
(iii) Relative addressing
(iv) Indirect addressingAnswer: C. (ii) and (iii) — Answer: Based addressing and Relative addressing. Why these modes are suitable for runtime relocation: Based addressing: The effective address is computed by…
- A.
(i) and (iv)
- B.
(i) and (ii)
- C.
(ii) and (iii)
- D.
(i), (ii) and (iv)
Attempted by 128 students.
Show answer & explanation
Correct answer: C
Answer: Based addressing and Relative addressing.
Why these modes are suitable for runtime relocation:
Based addressing: The effective address is computed by adding an offset to a base register. The loader or runtime can set the base register to the program's actual memory location, so instructions need not be modified when the program is moved.
Relative addressing: Addresses are given as offsets from the program counter (PC) or another register. Because addresses are expressed as offsets, the same code works at different load addresses without changing instruction contents.
Why the other modes are not suitable:
Absolute addressing: Encodes fixed physical addresses in instructions. To relocate the program these addresses must be rewritten, so this mode is not suitable for runtime relocation without modification.
Indirect addressing: Uses an address stored in memory to locate the operand. Relocatability depends on whether the stored pointer values were adjusted; the addressing mode itself does not ensure safe runtime relocation.
Summary: Based addressing and Relative addressing allow the effective address to be computed using a runtime-updated register or PC-relative offset, so they are suitable for program relocation at run time.