Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Assume a Machine has a single register and six instructions (Problem 2.3.10 from the LAT text.) LD A ST A AD SB A ML A

image text in transcribed

Assume a Machine has a single register and six instructions (Problem 2.3.10 from the LAT text.) LD A ST A AD SB A ML A DVA places the operand A in the register places the contents of the register into the variable A adds the contents of the variable A to the register subtracts the contents of the variable A from the register multiples the contents of the register by the variable A divides the contents of the register by the variable A Write a program that accepts a postfix expression containing single letter operands and the operators +, -, *, and / and prints a sequence of instructions to evaluate the expression and leaves 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 MLC ST TEMP1 AD ST LD SB ST LD DV ST TEMP1 TEMP2 D E TEMP3 TEMP2 TEMP3 TEMP4 Use the following postfix expressions for input AB+C- ABC+. AB-C+DEF-+$ ABCDE-+$*EF*. ABC+*CBA-+* ABC+/CBA*+ AB-*CBA+-* ABC-/BA+ ABC+$CBA-+* AB0+/CBA+/ Keep in mind that you are NOT evaluating the postfix expression, you are generating the machine language instructions that would perform the evaluation if actually executed. In your analysis, be sure to discuss the implementation you choose and why, why a stack makes sense. Consider a recursive solution (you do not need to implement recursion) and compare it to your iterative solution. Is one better than the other? Why? Tell us what you learned and what you would do differently. Be sure to review the programming assignment guidelines, including the formatting requirements for the analysis. You may not use library functions. You must write your own Assume a Machine has a single register and six instructions (Problem 2.3.10 from the LAT text.) LD A ST A AD SB A ML A DVA places the operand A in the register places the contents of the register into the variable A adds the contents of the variable A to the register subtracts the contents of the variable A from the register multiples the contents of the register by the variable A divides the contents of the register by the variable A Write a program that accepts a postfix expression containing single letter operands and the operators +, -, *, and / and prints a sequence of instructions to evaluate the expression and leaves 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 MLC ST TEMP1 AD ST LD SB ST LD DV ST TEMP1 TEMP2 D E TEMP3 TEMP2 TEMP3 TEMP4 Use the following postfix expressions for input AB+C- ABC+. AB-C+DEF-+$ ABCDE-+$*EF*. ABC+*CBA-+* ABC+/CBA*+ AB-*CBA+-* ABC-/BA+ ABC+$CBA-+* AB0+/CBA+/ Keep in mind that you are NOT evaluating the postfix expression, you are generating the machine language instructions that would perform the evaluation if actually executed. In your analysis, be sure to discuss the implementation you choose and why, why a stack makes sense. Consider a recursive solution (you do not need to implement recursion) and compare it to your iterative solution. Is one better than the other? Why? Tell us what you learned and what you would do differently. Be sure to review the programming assignment guidelines, including the formatting requirements for the analysis. You may not use library functions. You must write your own

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Database Processing

Authors: David J. Auer David M. Kroenke

13th Edition

B01366W6DS, 978-0133058352

More Books

Students also viewed these Databases questions

Question

Compare the different types of employee separation actions.

Answered: 1 week ago

Question

Assess alternative dispute resolution methods.

Answered: 1 week ago

Question

Distinguish between intrinsic and extrinsic rewards.

Answered: 1 week ago