381 views
0 votes
0 votes

A computer which issues instructions in order, has only 2 registers and 3 opcodes ADD, SUB and MOV. Consider 2 different implementations of the following basic block:

Case 1            Case 2
t1 = a + b;      t2 = c + d;
t2 = c + d;      t3 = e – t2;
t3 = e – t2;     t1 = a + b;
t4 = t1 – t2;    t4 = t1 – t2; 

Assume that all operands are initially in memory. Final value of computation also has to reside in memory. Which one is better in terms of memory accesses and by how many MOV instructions ?

(A) Case 2, 2
(B) Case 2, 3
(C) Case 1, 2
(D) Case 1, 3
(E) None of these

 

1 Answer

0 votes
0 votes

answer should be (E) None of these

 

case 1

MOV R1 a

ADD R1 b

MOV R2 c

ADD R2 d

SUB e R2

SUB R2 R1

MOV back to mem

----------------------

case 2

MOV R1 c

ADD R1 d

MOV R2 R1  // question may arise here , why we did so ? the reason is , we need the ...

                   // ...value of c+d near the end of instruction set, if R1 gets subtracted by e,...

                   // ...it will be a problem

SUB R2 e

MOV R2 a

ADD R1 b

SUB R2 R1

MOV back to mem

 

-------------------------

case 1 has 3 mem access

case 2 has 4 mem access

 

edited by

Related questions

7 votes
7 votes
3 answers
2
1 votes
1 votes
1 answer
4
Sai eswar asked Aug 20, 2023
547 views
Given R(ABCD) FD's={A->C,B->D}. Is this in 3NF?If NO why?