The Gateway to Computer Science Excellence
First time here? Checkout the FAQ!
x
+21 votes
3.4k views

Consider a hypothetical processor with an instruction of type $\text{LW  R1, 20(R2)}$, which during execution reads a $32-bit$ word from memory and stores it in a $32-bit$ register $\text{R1}$. The effective address of the memory location is obtained by the addition of a constant $20$ and the contents of register $\text{R2}$. Which of the following best reflects the addressing mode implemented by this instruction for the operand in memory?

  1. Immediate addressing
  2. Register addressing
  3. Register Indirect Scaled Addressing
  4. Base Indexed Addressing
asked in CO & Architecture by Veteran (101k points)
edited by | 3.4k views
+1
Answer can never be A or B.
+1
Plz correct me if wrong:

"The reason it cannot be register mode is because it is reading the address from memory, while, in register mode, address is never read from memory"?
+1
Index Mode

The address of the operand is obtained by adding to the contents of the general register (called index register) a constant value. The number of the index register and the constant value are included in the instruction code. Index Mode is used to access an array whose elements are in successive memory locations. The content of the instruction code, represents the starting address of the array and the value of the index register, and the index value of the current element. By incrementing or decrementing index register different element of the array can be accessed.
0
Why is it not register addressing?
0
Why not option C ?
+3

Some related additional information -->

After reading this question some terms are coming in my mind for calculating effective address -->

  1. Addressing mode for Data (Used in sequential control flow)  -
    1. Immediate AM(addressing mode)  # 
    2. Register AM 
    3. Direct AM []
    4. Indirect AM(Register indirect AM and Memory Indirect AM)  @ or ()
    5. Indexed AM -
      1. Base Indexed Addressing - Base address is available in the address field of the instruction and index value is fetched from Index reg.
      2. In some processor we have designated register for both Base and Index value. 
      3. Auto indexed AM( [Base reg] + Step Size)
        • Auto increment and Auto Decrement  
    6. Implied (or Implicit) AM. (Ex - CLC, STC etc.)
  2. Addressing mode for Instruction(Used in transfer of Control) - 
    1. PC Relative AM (For accessing within segment) PC $\leftarrow$ PC + IR[Address Field].
    2. Base register AM or Based AM(For accessing instruction outside of the current segment) PC $\leftarrow$ [Base Reg.] + IR[Address Field]

PS: If something is missing or not proper please notify. It will be really helpful.

0
why not register indirect?
0
@sushmita in register indirect we hold the effective address in the register here we calculate it with additional index here the register is only the base
0
same question appeared in ISRO 2017 dec..

4 Answers

+25 votes
Best answer

Answer is (D).

Base Index Addressing, as the content of register $R2$ will serve as the index and $20$ will be the Base address.

answered by Boss (34k points)
edited by
0
why are we not considering c as there is additive scaling
+14

Hope, this will help!

0
why not immediate mode?
+1

Why not reasoning for the answer be like,

Answer: D.

Base index addressing, as the content of the register, R2 will serve as the BASE and 20 will be the INDEX.

+1
@Hemant . By standard we assume that the constant in the address field represent then Base address  and the index register contains index value.
0
Isnt based indexed addressing mode required to use base registers (BX and BP) and index registers (SI and DI)? If yes, then how is this based indexed addressing mode? Is it just conceptual, like we should have some fixed base address and indexing offset?
+2 votes

The answer has to be option D.

Reason:It is mentioned in the question that the constant value 20 is added to the contents of Register R2(the word "CONSTANT" has got a significance here).The base address is something that remains CONSTANT under normal circumstances.The content of R2 is added to 20(constant base address) to get the effective address and this process resembles the way how we access an element of an array randomly.As we know that accessing of array elements is best done using INDEXED ADDRESSING hence the answer.

answered by Junior (789 points)
–1 vote
option d
answered by (33 points)
–2 votes
Ans: D

Index     X(Ri)    EA=[Ri]+X  

Where  x=displacement

So here R2 is Index or Base register and 20 is displacement
answered by (281 points)


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

39,848 questions
46,815 answers
141,153 comments
59,066 users