Relative mode of addressing is most relevant to writing
1996
Relative mode of addressing is most relevant to writing
- A.
co-routines
- B.
position-independent code
- C.
shareable code
- D.
interrupt handlers
Attempted by 44 students.
Show answer & explanation
Correct answer: B
In Relative Addressing Mode (specifically Program Counter Relative or PC-Relative addressing), the effective address of an operand or instruction is calculated by adding an offset (displacement) to the current content of the Program Counter (PC):
$$\text{Effective Address} = \text{Program Counter (PC)} + \text{Offset}$$
Because the addresses are specified as relative distances (offsets) from the current instruction rather than hardcoded absolute memory locations, the entire block of code can be loaded anywhere in the main memory without breaking internal jumps or references.
This exact property is the defining characteristic of Position-Independent Code (PIC). PIC can execute properly regardless of its absolute physical or logical memory address, making relative addressing essential for compiling dynamic shared libraries (like .so files in Linux or .dll files in Windows) that get mapped to different memory locations at runtime.