Question: Program Using Stacks CISP 1020- Advanced C+ + Assume that a machine has a single register and six instructions as follows: LD A Places the

 Program Using Stacks CISP 1020- Advanced C+ + Assume that a

Program Using Stacks CISP 1020- Advanced C+ + Assume that a machine has a single register and six instructions as follows: LD A Places the operand A into the register ST A Places the contents of the register into the variable A AD A Adds the contents of the variable A to the register SB A Subtracts the contents of the variable A from the register ML A Multiplies the contents of the register by the variable A DV A Divides the contents of the register by the variable A You are to write a program that accepts a postfix expression containing single letter operands and the operators +, -, *, / and prints a sequence of instructions to evaluate the expression and leave the result in the register. Use variables of the form TEMPn as temporary variables. For example, using the postfix expression ABC*+DE-/ should print the following: LD B ML C ST TEMP1 LD A AD TEMP1 ST TEMP2 LD D SB E ST TEMP3 LD TEMP2 DV TEMP3 ST TEMP4

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Programming Questions!