CameraIcon
CameraIcon
SearchIcon
MyQuestionIcon
MyQuestionIcon
6
You visited us 6 times! Enjoying our articles? Unlock Full Access!
Question

Consider the grammar rule EE1E2 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 subexpression, in order to get the shortest possible code

A
E2 should be evaluated first
Right on! Give the BNAT exam to get a 100% scholarship for BYJUS courses
B
E1 should be evaluated first
No worries! We‘ve got your back. Try BYJU‘S free classes today!
C
Order of evaluation of E1 and E2 is of no consequence
No worries! We‘ve got your back. Try BYJU‘S free classes today!
D
Evaluation of E1 and E2 should necessarily be interleaved
No worries! We‘ve got your back. Try BYJU‘S free classes today!
Open in App
Solution

The correct option is A E2 should be evaluated first
To optimize the solution evaluate the expression E2. Then we can calculate E1 and finally E1 will be one of operands that will be in register and we can perform subtraction directly. But if we follow the opposite then we have to make move and store operations.

flag
Suggest Corrections
thumbs-up
0
Join BYJU'S Learning Program
similar_icon
Related Videos
thumbnail
lock
Inductive Reasoning
MATHEMATICS
Watch in App
Join BYJU'S Learning Program
CrossIcon