The Gateway to Computer Science Excellence
+3 votes
214 views
In the program scheme given below indicate the instructions containing any operand needing relocation for position independent behaviour. Justify your answer.$$\begin{array}{llll} & Y = 10 &  \\  & \text{MOV} & {X(R_0), R_{1}}  \\ & \text{MOV} & {X, R_0} \\ & \text{MOV} & {2(R_0), R_{1}} \\  & \text{MOV} & {Y(R_0), R_{5}} \\  & \ \cdot &   \\ & \ \cdot &  \\  & \ \cdot & \\ X: & \text{WORD} & 0,0,0  \\ \end{array}$$
in CO and Architecture by Veteran (105k points)
edited by | 214 views
0
Please explain the ques and solution both,

1 Answer

+1 vote
$\text{MOV}$ instructions here are problematic for Position Independent behaviour if they use Indexed addressing mode and the base address is loaded using some Absolute value.

I'm assuming $R_0$ is having some relative address. So, the first two $\text{MOV}$ instructions are fine for Position Independent behaviour.

But $\text{MOV} \quad {2(R_0), R_{1}}$
is not fine for position independent behaviour as the source operand address here is $2+R_0 = 2 + X$ which remains the same even when program is loaded to a new address. So, it should catch invalid content when program is loaded to a new address. Similarly the last $\text{MOV}$ will also cause problem.
by Veteran (425k points)
+1
What is the difference between first and last MOV statements.

Also what does  X : WORD 0,0,0 means ?
0
as Y is given as 10 it will be same as 3rd one

Related questions

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
50,644 questions
56,505 answers
195,557 comments
101,057 users