in CO and Architecture recategorized by
1,522 views
4 votes
4 votes

Consider an instruction of the type $\text{LW R1, 20(R2)}$ which during execution reads a $32$-$bit$ word from memory and stores it in a $32$-$bit$ register $R1.$ The effective address of the memory location is obtained by adding a constant $20$ and contents of $R2.$ Which one best reflects the source operand?

  1. Immediate addressing 
  2. Register addressing 
  3. Register Indirect addressing 
  4. Indexed addressing
in CO and Architecture recategorized by
by
1.5k views

1 comment

Why is (C) wrong?
0
0

3 Answers

6 votes
6 votes
Best answer

Answer must be D) Indexed addressing

  • Address field stores starting address and Index register stores a signed number (displacement )
  • Suitable for iterative operations, array implementation .
  • Register R2 acts as index register and 20 is  the Base address.

Edit: ISRO has corrected the answer in revised key :)

selected by
by
1 vote
1 vote

The given answer key of this question is also wrong. It is given as C) Register Indirect addressing but answer should be D) Indexed addressing.

https://gateoverflow.in/2123/gate2011_21

0 votes
0 votes

 

LW R1, 20(R2)

Addressing modes essentially deal with the question — "Where is the operand?"

  1. Option A would give a constant value in the instruction, which is supposed to be our operand. Not the case here.
     
  2. Option B would say that the operand is in the register. Not the case here.
     
  3. Option C would say that the operand is in the address specified by the register. Not the case here.
     
  4. Option D would say that the operand is given by an indexed address. Now see LW R1, 20(R2).

    LW R1, 20(R2) — 20 is the base.

    LW R1, 20(R2) — Contents of R2 act as index. R2 is essentially the index register.

Hence, Option D is the answer.



Bonus:-

  • For relocatable/position-independent code: Base Register mode, PC relative mode.
  • Accumulator uses: Implied mode.
  • To implement parameter-passing and pointers: Indirect mode.
  • Loops: Auto inc/dec mode.
Answer:

Related questions