recategorized by
3,501 views
12 votes
12 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}$$
recategorized by

1 Answer

9 votes
9 votes
$\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.

Related questions

1 votes
1 votes
0 answers
1
7 votes
7 votes
3 answers
2
27 votes
27 votes
3 answers
4
go_editor asked Dec 11, 2016
3,951 views
Using an expanding opcode encoding for instructions, is it possible to encode all of the following in an instruction format shown in the below figure. Justify your answer...