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?

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? Correct Answer <p>3</p>

Answer: Option 4

Explanation:

Exp –    Load R1, a ; R1   ← M
Load R2, b ; R2   ← M

Sub R1, R2 ;  R1    ←  R1 - R2

Load R2, c  ; R2      ←  M

Load R3, d  ; R3     ←  M

Add R2, R3 ; R2   ←  R2 + R3

Load R3, e  ; R3      ←  M

Sub R3, R2  ; R3   ←  R3 - R2

Add  R1, R3  ; R1   ←  R1 + R3

Total 3 Registers are required minimum.

Related Questions