Skip to content
Official PYQ · 1998

GATE CS 1998 Q1.19 — Machine Instructions and Addressing Modes

Explain with AI

Which of the following addressing modes permits relocation without any change whatsoever in the code?

Choose one option
View worked solution

Answer: D

A program is said to be position-independent (or relocatable without any change in the code) if it can be loaded at any memory location and executed without modifying any of its instructions.

Let's analyze the options:

  • PC-Relative Addressing: The effective address is calculated as: Effective Address=Program Counter (PC)+Offset\text{Effective Address} = \text{Program Counter (PC)} + \text{Offset} When the entire code block is relocated to a different memory address, the relative distance (offset) between the instruction and the target operand or branch destination remains exactly the same. Thus, the offset encoded in the instruction does not need to be modified at all. This makes PC-relative addressing ideal for position-independent code.
  • Base Register Addressing: While it helps in relocation, it requires the base register to be explicitly loaded with the new starting address of the program before execution, which requires an external change or setup.
  • Indirect and Indexed Addressing: These modes typically rely on absolute memory addresses or pointers stored in memory, which must be updated (relocated) when the program's location changes.

Therefore, PC-relative addressing permits relocation without any change whatsoever in the code.

Free practice · Your answers on this page are not saved.

Published
Report a correction
Keep exploringMore Machine Instructions and Addressing Modes questions