Home » Programming & Data Structure » Programming and data structure miscellaneous » Question

Programming and data structure miscellaneous

Programming & Data Structure

  1. Consider evaluating the following expression tree on a machine with load store architecture in which memory can be accessed only through load and store instructions. The variables a, b, c, d and e are initially stored in memory. The binary operators used in this expression tree can be evaluated by the machine only when the operands are in registers. The instructions produce result only in a register. If no intermediate results can be stored in memory, what is the minimum number of registers needed to evaluate this expression?

    1. 2
    2. 9
    3. 5
    4. 3
Correct Option: D

R1 ← c, R2 ← d, R2 ← R1 + R2, R1 ← e, R2 ← R1-R2 Now to calculate the rest of the expression we must load a and b into the registers but we need the content of R2 later. So we must use another Register. R1 ← a, R3 ← b, R1 ← R1-R3, R1 ← R1 + R2



Your comments will be displayed only after manual approval.