edited by
33,875 views
97 votes
97 votes

Consider a three word machine instruction

$\text{ADD} A[R_0], @B$

The first operand (destination) $“A[R_0]”$ uses indexed addressing mode with $R_0$ as the index register. The second operand (source) $“@B”$ uses indirect addressing mode. $A$ and $B$ are memory addresses residing at the second and third words, respectively. The first word of the instruction specifies the opcode, the index register designation and the source and destination addressing modes. During execution of $\text{ADD}$ instruction, the two operands are added and stored in the destination (first operand).

The number of memory cycles needed during the execution cycle of the instruction is:

  1. $3$
  2. $4$
  3. $5$
  4. $6$
edited by

8 Answers

Best answer
144 votes
144 votes

$1\;\text{memory read}$ to get the first operand from memory address $A+R_0\; (A$ is given as part of instruction)
$1\;\text{memory read}$ to get the address of the second operand (since second uses indirect addressing)
$1\;\text{memory read}$ to get the second operand from the address given by the previous memory read
$1\;\text{memory write}$ to store to first operand (which is the destination)

So, total of $4$ memory cycles once the instruction is fetched.

The second and third words of the instruction are loaded as part of the Instruction fetch and not during the execute stage.
Reference: http://www.cs.iit.edu/~cs561/cs350/fetch/fetch.html

Correct Answer: B

edited by
9 votes
9 votes
indirect addressing mode will take 2 memory cycles and A[R0] will take 1  memory cycles... Total 4 memory cycles .. Here equation is  A[R0] = A[R0] + @B ...  where A and B are memory addresses ...  A[R0] will be interpreted as A+M[R0] which will produce a memory address ... so 1 memory cycle for it .. So Total 1+1+2 = 4 ...
6 votes
6 votes
B) as Memory[ A+R0 ]<--Memory[ A+R0 ] + Memory[memory[B]]
edited by
6 votes
6 votes

 

ADD A[R0], @B;

 

ANSWER : 6

 

A TOTAL OF 6 MEMORY ADDRESS NEED TO BE ACCESSED TIN ORDER TO PERFORM THE INSTRUCTION.

 

 

THE ABOVE CODE CONTAINS 3 PARTS:

1. DISPLACEMENT ADDRESSING  A[R0] 

2. INDIRECT ADDRESSING @B  

3. ARITHMETIC OPERATION / STORE RESULT ADD

 

 

1. A[R0] RESULTS IN 3 MEMORY ACCESS

EFFECTIVE ADDRESS IS CALCULATED AS

A[R0] = A + (R0)

A[R0] IS  A TYPE OF DISPLACEMENT ADDRESSING MODE IN WHICH THE FINAL MEMORY [A+R0] IS ACCESSED BY ADDING THE BASE ADDRESS "R0" TO THE DISPLACEMENT ADDRESS "A"

  

2. @B FETCHED THE OPERAND IN 2 MEMORY ACCESS SINCE IT IS AN INDIRECT ADDRESSING MODE.

3. ONE MORE MEMORY ACCESS IS REQUIRED IN ORDER TO STORE THE FINAL ADD RESULT IN THE DESTINATION ADDRESS.

 

A TOTAL OF 6 MEMORY ADDRESS NEED TO BE ACCESSED TIN ORDER TO PERFORM THE INSTRUCTION.

  

1 flag:
✌ Low quality (DhruvaKashyap “Wrong answer”)
Answer:

Related questions

27 votes
27 votes
1 answer
1
Kathleen asked Sep 22, 2014
6,749 views
Match each of the high level language statements given on the left hand side with the most natural addressing mode from those listed on the right hand side.$$\begin{array...
55 votes
55 votes
12 answers
2
47 votes
47 votes
6 answers
3