Which of the following addressing modes are suitable for program reloc...
Answer: C
A displacement type addressing should be preferred. So, I is not the answer.
Indirect Addressing leads to extra memory reference which is not preferable at run time. So, IV is not the answer.
View all questions of this test
Which of the following addressing modes are suitable for program reloc...
Program Relocation at Run Time
Program relocation at run time refers to the ability of a program to be loaded into different memory locations when executed. This is often required in operating systems and virtual memory systems to allow multiple programs to run concurrently without interfering with each other's memory space.
Addressing Modes for Program Relocation
There are several addressing modes that can be used to achieve program relocation at run time. These modes allow the program to specify memory addresses in a flexible manner, making it possible to load the program into different memory locations. The suitable addressing modes for program relocation at run time are:
I. Absolute Addressing:
- Absolute addressing refers to specifying a fixed memory address directly in the instruction.
- This addressing mode is not suitable for program relocation at run time because the program is tied to a specific memory location.
- If the program is loaded into a different memory location, the absolute addresses in the program will be incorrect.
II. Based Addressing:
- Based addressing, also known as base-relative addressing, involves specifying a base address and an offset.
- The base address is typically stored in a register or memory location and is added to the offset to calculate the final memory address.
- This addressing mode is suitable for program relocation at run time because the base address can be adjusted to reflect the program's current memory location.
- By changing the base address, the program can be loaded into different memory locations without affecting the correctness of the addresses.
III. Relative Addressing:
- Relative addressing involves specifying a memory address relative to the program counter or some other reference point.
- This addressing mode is suitable for program relocation at run time because the relative addresses can be adjusted based on the program's current memory location.
- By adjusting the reference point, the program can be loaded into different memory locations without affecting the correctness of the addresses.
IV. Indirect Addressing:
- Indirect addressing involves specifying a memory address indirectly through a pointer or index.
- This addressing mode is suitable for program relocation at run time because the pointer or index can be adjusted to reflect the program's current memory location.
- By changing the pointer or index, the program can be loaded into different memory locations without affecting the correctness of the addresses.
Conclusion
In summary, the suitable addressing modes for program relocation at run time are based addressing, relative addressing, and indirect addressing. These addressing modes allow the program to specify memory addresses in a flexible manner, making it possible to load the program into different memory locations without affecting the correctness of the addresses. Absolute addressing, on the other hand, is not suitable for program relocation at run time as it ties the program to a specific memory location.