The Gateway to Computer Science Excellence
+3 votes
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
edited by | 556 views
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.
What is the difference between first and last MOV statements.

Also what does  X : WORD 0,0,0 means ?
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
52,375 questions
60,585 answers
95,407 users