GATE / CS ARCHIVE

SIMILAR QUESTIONS / COMPUTER ORGANIZATION & ARCHITECTURE

Recognize relocation through relative addressing

2 questions solved the same way, newest first. Back to Computer Organization & Architecture

How these are solved

Determine whether effective addresses can follow a relocated program through PC-relative or supplied-base values, without rewriting absolute addresses. The later variant chooses among multiple modes; the earlier asks the application of relative addressing.

1 mark · MCQ
Report issue

Relocation-friendly addressing modes

Instructions & Addressing Modes

Question 20, GATE 2004: Which addressing modes support program relocation at runtime? (i) Absolute; (ii) Based; (iii) Relative; (iv) Indirect.
Options:
(A) i and iv
(B) i and ii
(C) ii and iii
(D) i,ii and iv
Question 20, GATE 2004: Which addressing modes support program relocation at runtime? (i) Absolute; (ii) Based; (iii) Relative; (iv) Indirect.
Options:
(A) i and iv
(B) i and ii
(C) ii and iii
(D) i,ii and iv
Tap to enlarge
Your answer
Answer & solution

Answer: C (no official key was published)

1. Base addressing forms an address as relocation base plus displacement, while PC-relative addressing uses a displacement from the moving instruction location. Both preserve relative positions when code is relocated, so ii and iii, C.

2. Absolute embedded addresses require adjustment; indirection alone does not guarantee that stored pointer values relocate correctly.

3. Teaching check: If relocation shifts all code by Δ, a PC-relative target shifts with the PC while its displacement stays fixed. A base-addressed target shifts when the base register is updated. An arbitrary indirect pointer can still contain an obsolete absolute address, so indirection alone is not a relocation guarantee.

Original paper, page 3

1 mark · MCQ
Report issue

Position-independent addressing

Instructions & Addressing Modes

Question 1.16, GATE 1996: Relative addressing is most relevant to writing which application: (A) coroutines, (B) position-independent code, (C) shareable code, or (D) interrupt handlers?
Question 1.16, GATE 1996: Relative addressing is most relevant to writing which application: (A) coroutines, (B) position-independent code, (C) shareable code, or (D) interrupt handlers?
Tap to enlarge
Your answer
Answer & solution

Answer: B: position-independent code (no official key was published)

A PC-relative instruction stores an offset rather than an absolute target address. Its effective target is PC plus that offset. If both instruction and target move by the same relocation amount, the difference between them is unchanged, so the stored offset still works. Absolute addressing instead embeds a location that generally needs relocation. This is why relative addressing is associated with position-independent control transfers, subject to the architecture’s offset range and exact PC convention.

Original paper, page 2