In a simplified computer the instructions are:
The computer has only two registers, and OP is either ADD or SUB. Consider the following basic block:
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?
For Instructions of t2 and t3
1. MOV c, t2
2. OP d, t2(OP=ADD)
3. OP e, t2(OP=SUB)
For Instructions of t1 and t4
4. MOV a, t1
5. OP b, t1(OP=ADD)
6. OP t1, t2(OP=SUB)
7. MOV t2, a(AS END Value has To be in the MEMORY)
Step 6 should have been enough, if the question hadn’t asked for final value in memory and rather be in register. The final step require another MOV, thus a total of 3.
Quiz of this Question