Compiler-Design
February 13, 2024Question 2914 – 2014 December UGC NET Paper 1
February 13, 2024Question 9498 – Compiler-Design
Consider the grammar rule E → E1 – E2 for arithmetic expressions. The code generated is targeted to a CPU having a single user register. The subtraction operation requires the first operand to be in the register. If E1 and E2 do not have any common sub expression, in order to get the shortest possible code
Correct Answer: B
Question 50 Explanation:
After evaluating E2 first and then E1, we will have E2 in the register and then we can simply do SUB operation with E2 which will be in memory. And if we do E1 first and then E2, then we must move E2 to memory and again bring back E1 to the register before doing SUB operation, which will increase load.
E1 should be evaluated first
E2 should be evaluated first
Evaluation of E1 and E2 should necessarily be interleaved
Order to evaluation of E1 and E2 is of no consequence
