Relative mode of addressing is most relevant to writing

2016

Relative mode of addressing is most relevant to writing

  1. A.

    Co-routines

  2. B.

    Position – independent code

  3. C.

    Shareable code

  4. D.

    Interrupt Handlers

Attempted by 458 students.

Show answer & explanation

Correct answer: B

Concept: PC-relative (relative-mode) addressing computes the effective address by adding a signed displacement, encoded in the instruction itself, to the current value of the program counter (PC): EA = PC + displacement. No absolute memory address is ever stored in the instruction.

Application: Because a PC-relative reference is expressed relative to the instruction's own current location rather than to a fixed absolute address, code built using PC-relative addressing keeps its effective addresses correct when the whole program is relocated to a different base address — exactly the relocation-without-modification property required of position-independent code (PIC): code that can be loaded and executed at different base addresses without being modified or re-linked.

  • Co-routines describe two or more routines that explicitly resume each other via control transfers; this is a control-flow/scheduling concept, unrelated to how an instruction computes its address.

  • Shareable code refers to a single reentrant copy of a program being used concurrently by multiple processes, a protection/reentrancy guarantee enforced by the operating system's memory manager — a different property from how the effective address is calculated.

  • In the common vectored-interrupt mechanism, interrupt handling routes through a fixed interrupt-vector table whose entries point to the handler at a predetermined table location; this fixed vector lookup, not PC-relative computation, is what locates the handler.

Cross-check: If the whole program is relocated by adding a constant offset to every load address, PC-relative references remain correct without any change to the code, since each is expressed relative to the (also-shifted) PC rather than to a fixed absolute location. This relocation-without-modification behaviour is exactly what position-independent code requires.

A video solution is available for this question — log in and enroll to watch it.

Explore the full course: Isro

Loading lesson…