The Gateway to Computer Science Excellence
First time here? Checkout the FAQ!
+12 votes

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

  1. Indirect addressing

  2. Indexed addressing

  3. Base register addressing

  4. PC relative addressing

asked in CO & Architecture by Veteran (59.5k points)
retagged by | 1.6k views

3 Answers

+19 votes
Best answer
PC relative addressing is the best option. For Base register addressing, we have to change the address in the base register while in PC relative there is absolutely no change in code needed.
answered by Veteran (355k points)
selected by
What is PC relative addressing can u explain and how it will not change its address on relocation?
@ Arjun Sir I think ans should be C because a PC relative instruction should contain the base address but in base register AM both are present separately in Base Register and Index register.
Please tell me if I am wrong.
Pc relative is position independent .. it means it can be loaded in memory without any need to adjust any address..  search in wikipedia for more info ..

you mentioned "For Base register addressing, we have to change the address in the base register while in PC relative there is absolutely no change in code needed."

Base register will have segment base address,why do we need to change that?
In Base addressing mode we dont change the code (instruction) ... we will only be changing the Base register ... And yes both PC relative and Base register addressing mode are relative addressing modes and they both can do Program relocation without changing even a single line of code (set of instructions) ...
both the options C and D have to be correct as its gate 1998 multiple options may be correct then we have to choose all

even for based addressing mode also we provide the address relative to the base register so we don't need to change the  ASSEMBLY CODE AS ALREADY  ONLY THE OFFSET IS PRESENT IN THE CODE AND WE CALCULATE THE EFFECTIVE ADDRESS
For relocation in base addressing we need to change the content of the base register only..without any change in the code so then why relocation is not possible here ??

Cristine in Base addressing you still need to change the content of base register whereas in relative addressing you just need the offset. PIC is commonly used for shared libraries, so that the same library code can be loaded in a location in each program address space where it will not overlap any other uses of memory. Libraries do not depend on anything outside the code.

+4 votes

Ans: D

Code relocation can be done whenever addresses are not directly specified in the program (absolute), but are relative to some variable or other modifiable source.

For 3), base addressing, a register points to the base of the structure and the effective address is obtained by computing an offset from the base. The base address register can be loaded at run time to point to the base of the structure so the code doesn't have to be modified.

For 4), PC relative, the effective memory address is obtained by computing an offset from the current PC. No matter where the code is loaded in memory, the offsets are always the same so the code needs no modification.


answered by Loyal (7.2k points)
So ,you are supporting both the options,then why the answer is d?
Bcz Option D is more appropriate
+1 vote
C- Base register addressing
answered by Loyal (6.1k points)

Quick search syntax
tags tag:apple
author user:martin
title title:apple
content content:apple
exclude -tag:apple
force match +apple
views views:100
score score:10
answers answers:2
is accepted isaccepted:true
is closed isclosed:true

38,079 questions
45,572 answers
49,043 users