retagged by
11,966 views
41 votes
41 votes

Which of the following addressing modes are suitable for program relocation at run time?

  1. Absolute addressing

  2. Based addressing

  3. Relative addressing

  4. Indirect addressing

  1. I and IV
  2. I and II
  3. II and III
  4. I, II and IV
retagged by

4 Answers

Best answer
42 votes
42 votes

Answer: (C)

A displacement type addressing should be preferred. So, (I) is not the answer.

Indirect Addressing leads to extra memory reference which is not preferable at run time. So, (IV) is not the answer.

edited by
14 votes
14 votes

THE ANSWER IS  C.

Let us consider the following code.
Let the base register be updated with the value 203
address     code
200            ADD B,M[400] // absolute addressing
201            ADD  C,M[M[400]]//  indirect addressing                     
202            ADD C,PC(197)// relative addressing mode
203            ADD  A, 197(base register)   //base register addressing mode.

400               420
                     -
                     -
420               600
421               halt.

 

NOW LET THE CODE BE SHIFTED TO  LOCATION 700.
And let  addresses 200-421 be loaded with some other code
Let the base register be updated with the value 203
address     code
500            ADD B,M[400]    // absolute addressing
501            ADD  C,M[M[400]]     //  indirect addressing                     
502            ADD C,PC(197)   // relative addressing mode
503            ADD  A, 197(base register)   //base register addressing mode.
                     -

700               420
                     -
                     -
720               600
721               halt.

 

Absolute addressing mode.& indirect addressing mode.

When the code at address 700 is executed then we observe that it tries to fetch the operand at  400.But the physical address space of the code does not contain 400.hence it tries to access an invalid address.

Simlilar thing happens when it tries to access  400 for indirect addressing mode.

 

PC Relative.
we see that  we can execute the code  ADD C,PC(197)  and it gives perfectly valid values even when it is shifted.

 

Base Register .
we see that  we can execute the code  ADD A,197(base register)  and it gives perfectly valid values even when it is shifted. We just need to update the base register.
 

Here I am only considering the validity of each individual line and wheather the lines will be executed  when relocated.

Please revert back if u find anything wrong or can give extra information :).

10 votes
10 votes
It should be a displacement type of addressing mode so option c.
0 votes
0 votes
Program relocation at run time transfer complete block to some memory locations. This requires as base address and block should be relatively addressed through this base address .This require both base address and relative address. So( C)  is correct option.

Absolute addressing mode and indirect addressing modes is used for one instruction at one time, not for whole block So both are not suitable for program relocation at run time.
Answer:

Related questions

38 votes
38 votes
4 answers
1
Kathleen asked Sep 18, 2014
8,310 views
The following finite state machine accepts all those binary strings in which the number of $1$’s and $0$’s are respectively: divisible by $3$ and $2$odd and evene...
37 votes
37 votes
7 answers
2
Kathleen asked Sep 18, 2014
12,554 views
The minimum number of colours required to colour the following graph, such that no two adjacent vertices are assigned the same color, is$2$$3$$4$$5$
27 votes
27 votes
5 answers
3
Kathleen asked Sep 18, 2014
18,977 views
Let $A = 1111 1010$ and $B = 0000 1010$ be two $8-bit$ $2’s$ complement numbers. Their product in $2’s$ complement is$1100 0100$$1001 1100$$1010 0101$$1101 0101$
42 votes
42 votes
4 answers
4
Kathleen asked Sep 18, 2014
11,947 views
Two matrices $M_1$ and $M_2$ are to be stored in arrays $A$ and $B$ respectively. Each array can be stored either in row-major or column-major order in contiguous memory ...