In a simplified computer the instructions are: [code] OP R j, Ri − Performs Rj OP Ri and stores the result in register Ri OP m, Ri −

In a simplified computer the instructions are:
Code:
OP R j, Ri − Performs Rj OP Ri and stores the result in register Ri 
OP m, Ri − Performs val OP Ri abd stores the result in Ri. value denotes the content of memory location m. 
MCVm, Ri −Moves the content off memory loction m to register Ri.
MCVm, Ri, m −Moves the content of register Ri to memory location m.
The computer has only two registers, and OP is either ADD or SUB. Consider the following basic block:
Code:
t1 = a + b 
t2 = c + d 
t3 = e − t2
t4 = t 1 − t2
Assume that all operands are initially in memory. The final value of the computation should be in memory. What is the minimum number of MOV instructions in the code generated for this basic block?
A. 2
B. 3
C. 5
D. 6
 
Answer: b
Explanation: The operation sequence would be
MOV a, R1
ADD b , R1 {R 1 = t1
MOV c , R2
ADD d, R2 {R 2 = t2
SUB e , R2 {t 3 = e − R 2 = R2
SUB R 1, R2 {R 2 = t4
MOV R 2, t4 {finally in memory
Totally no. of move operation is 3.
 

Tìm kiếm

Back
Top