recategorized by
1,543 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
recategorized by

3 Answers

Best answer
6 votes
6 votes

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

7 votes
7 votes
1 answer
3
gatecse asked Dec 17, 2017
2,357 views
A two-way set associative cache memory unit with a capacity of $16\, KB$ is built using a block size of$8\, words.$ The word length is $32-bits.$ The physical address spa...