The Gateway to Computer Science Excellence
First time here? Checkout the FAQ!
x
+14 votes
1.7k views

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.6k points)
retagged by | 1.7k views

3 Answers

+20 votes
Best answer

(D) 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 (358k points)
edited by
0
What is PC relative addressing can u explain and how it will not change its address on relocation?
–1
@ 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.
+1
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 ..
0
Sir,

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?
0
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) ...
+2
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
0
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 ??
0

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.

0

Arjun

Sir what if multiple Answers are Correct ?

Why not Base Register Addressing ? We aren't modifying the code right?

Answer should be Both, but the Answer is PC - Relative only because we are modifying something in Base Register (but the modification is not in code)

+6 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.

ref: https://cs.stackexchange.com/questions/48730/which-addressing-modes-permits-relocation-without-any-change-whatsoever-in-the-c

answered by Loyal (7.4k points)
0
So ,you are supporting both the options,then why the answer is d?
0
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

40,775 questions
47,479 answers
145,679 comments
62,242 users