556 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}$$

edited | 556 views
0
Please explain the ques and solution both,

+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
+2
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

+1 vote