Problem background: A stack can be used to solve postfix equation or notation; a user can write a program that uses a st

Business, Finance, Economics, Accounting, Operations Management, Computer Science, Electrical Engineering, Mechanical Engineering, Civil Engineering, Chemical Engineering, Algebra, Precalculus, Statistics and Probabilty, Advanced Math, Physics, Chemistry, Biology, Nursing, Psychology, Certifications, Tests, Prep, and more.
Post Reply
answerhappygod
Site Admin
Posts: 899604
Joined: Mon Aug 02, 2021 8:13 am

Problem background: A stack can be used to solve postfix equation or notation; a user can write a program that uses a st

Post by answerhappygod »

Problem background:
A stack can be used to solve postfix equation or notation; a
user can write a program that uses a stack to evaluate a certain
expression or equation. You may refer to the lesson concerning this
part in both theoretical (Zero operand Operation) and practical
(Stack).
Problem Statement:
You are requested to write an assembly program using the
assembler of 8086/8088 to do the following:
a) Enter a string from the keyboard that represents a postfix
expression.
b) Recognize the expression operands and operators.
c) Check the expression correctness (show proper massage if not
correct).
d) Prompt use to enter the value of each operand.
e) Evaluate the expression using stack
f) Show the corresponding code being followed to evaluate the
expression to user, considering a zero operand organization; which
is an organization that uses stack.
g) Show the final result of the expression evaluated
Input Constraints:
To make it easy to the student; the following constraints on the
inserted expression should be considered:
a) The operand should consist of 1 character only and it should
be an alphabet.
b) The operator can be one of the four basic arithmetic
operations only (+ , - , * , / ).
c) A space to be inserted between the characters of the
expression.
d) Maximum number of different operands should not exceed 4
operands.
e) The value of the operand should be one decimal digit number
only.
f) The constraints above should be investigated by the user not
the program.
Sample outputs:
Example1:
Please Enter The Postfix Expression
W Z * X Y + +
Enter the value of W
1
Enter the value of Z
3
Enter the value of X
2
Enter the value of Y
4
Corresponding Code to evaluate the expression
is:
PUSH W
PUSH Z
MUL
PUSH X
PUSH Y
ADD
ADD
The value of the expression evaluated is: 9
Example2:
Please Enter The Postfix Expression
W Z * X Y +
Error: Expression not correct; number of operands
greater than number of operators
Example3:
Please Enter The Postfix Expression
W Z * X + +
Error: Expression not correct; number of operators
greater than number of operands
Example4:
Please Enter The Postfix Expression
W Z * X + + Y
Error: Expression not correct; Not a postfix
form
using C++ language
Join a community of subject matter experts. Register for FREE to view solutions, replies, and use search function. Request answer by replying!
Post Reply