Which of the following addressing modes are suitable for program relocation at run time?
-
Absolute addressing
-
Based addressing
-
Relative addressing
-
Indirect addressing
View worked solution
Answer: C
For a program to be easily relocatable at run time, its instructions should not contain hardcoded absolute memory addresses. Instead, addresses should be computed dynamically relative to a base reference point.
- I. Absolute addressing: Specifies the exact physical memory address directly in the instruction. If the program is relocated to a different memory segment, these addresses become invalid, making run-time relocation difficult.
- II. Base register addressing: The effective address is calculated as: When the program is moved to a new memory location, only the Base Register needs to be updated with the new starting address. The offset within the instructions remains the same, making this mode highly suitable for relocation.
- III. Relative addressing (PC-relative): The effective address is calculated relative to the Program Counter (PC): Since the relative distance between the instruction and the target address remains constant regardless of where the program is loaded in memory, no modifications are needed during relocation.
- IV. Indirect addressing: The instruction contains the address of a memory location (or register) that holds the actual operand address. This does not inherently assist in program relocation.
Thus, II (Based addressing) and III (Relative addressing) are suitable for program relocation at run time.
Free practice · Your answers on this page are not saved.
