3a. Convert the following formula from postfix (Reverse Polish Notation) to infi
ID: 3689050 • Letter: 3
Question
3a. Convert the following formula from postfix (Reverse Polish Notation) to infix:
AB+C+D*
3 b. Convert the following formula from infix to postfix (Reverse Polish Notation):
( A + B * C) / ( D + E * F)
Write code that performs the computation in problem 3b
( A + B * C) / ( D + E * F)
using CPUs that have the following instruction formats:
You may only use registers A through F, plus X and T.
Registers A through F may not be changed, i.e. their values are fixed.
Register T may be used as a temporary register, and Register X must contain the final answer.
4 a. Three-operand instructions
4 b. Stack instructions
Explanation / Answer
Answer for Question:
AB+C+D * = > (A+B) * (C+D)
(A+B*C) / (D+E*F) => BC*A+ EF*D+/
Three-operand instructions
SUB X, B, C
ADD X, X, A
MUL Z, E, F
ADD Z, Z, D
DIV X, X, Z
Stack instructions
PUSH / A
PUSH / B
ADD
PUSH /C
MUL
PUSH / D
PUSH E
ADD
PUSH F
MUL
DIV
POP / X
off the stack
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.