The Gateway to Computer Science Excellence
First time here? Checkout the FAQ!
+3 votes
How many memory accesses required by the following instructions?
SUB r1, r2, r3
MUL r1, r2, (r3)
DIV r1, r2, @(r4)

Suppose every instruction is one word long, as well as every address.

(A) 4

(B) 6

(C) 8

(D) 9
asked in CO and Architecture by Boss (13.7k points) | 299 views
6 memory access

3 instruction fetch +1 for direct addressing +2 for indirect addressing
Got it..  Thanks!

Please elaborate.

Explanation will be in this way...

First of all, we have to fetch the instructions one by one, so for fetching, we will have to access main memory, for 3 instructions, 3 memory accesses will be there.

According to usual conventions, in the first instruction, there will be no other extra memory access because everything that is needed to execute the instruction is present in registers, we need not go to the Main memory.

In the second instruction, (r3) means this represents direct addressing mode, which means effective memory address will be directly available in a register, so we have to go to the main memory to access that one. So one memory access will be required...

In the third instruction, @(r4) means this represents indirect addressing mode which means the actual effective address is not directly present in the register, there will be some address, so we have to go to that particular address (1 memory access) and then on reaching that address, we will get some other address(actual effective address), so again we need to access it(2 memory access)..

So total memory access= 3 + 1 + 2 =6



@akash. Nice Explanation. Thank you :)
welcome bhai:)

1 Answer

+2 votes
Best answer

Total mem refrence = 6


answered by Boss (34.1k points)
selected by

Related questions

+1 vote
2 answers
asked May 10, 2018 in CO and Architecture by Sanjay Sharma Boss (48.1k points) | 183 views
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
49,808 questions
54,481 answers
74,530 users