Answered step by step
Verified Expert Solution
Question
1 Approved Answer
my program does not perform the desired operation correctly. For addition it performs subtraction and for the other operations it just performs addition. / Addition,
my program does not perform the desired operation correctly. For addition it performs subtraction and for the other operations it just performs addition.
Addition, Subtraction, Multiplication, and Division Calculator
Main Loop
MainLoop, CLEAR Clear the result
STORE Result Store zero in Result
INPUT Prompt user to enter the first integer
STORE X Store the input in variable X
INPUT Prompt user to enter the operator enter ASCII value in decimal
STORE Operator Store the operator in variable Operator
INPUT Prompt user to enter the second integer
STORE Y Store the input in variable Y
Determine which operation to perform
LOAD Operator
SUBT PlusOp
SKIPCOND
JUMP ADD
LOAD Operator
SUBT MinusOp
SKIPCOND
JUMP SUBTRACT
LOAD Operator
SUBT MultOp
SKIPCOND
JUMP MULTIPLY
LOAD Operator
SUBT DivOp
SKIPCOND
JUMP DIVIDE
Invalid operator entered
JUMP InvalidOp
Addition Subroutine
ADD, LOAD X
ADD Y
STORE Result
JUMP DISPLAY
Subtraction Subroutine
SUBTRACT, LOAD X
SUBT Y
STORE Result
JUMP DISPLAY
Multiplication Subroutine
MULTIPLY, CLEAR
STORE Result
LOAD Y
STORE TempY
MULTIPLYLOOP, LOAD TempY
SKIPCOND
JUMP MULTIPLYEND
LOAD X
ADD Result
STORE Result
LOAD TempY
SUBT One
STORE TempY
JUMP MULTIPLYLOOP
MULTIPLYEND, JUMP DISPLAY
Division Subroutine
DIVIDE, CLEAR
STORE Quotient
LOAD X
STORE Remainder
DIVIDELOOP, LOAD Remainder
SUBT Y
SKIPCOND
JUMP DIVEXIT
STORE Remainder
LOAD Quotient
ADD One
STORE Quotient
JUMP DIVIDELOOP
DIVEXIT, LOAD Quotient
STORE Result
JUMP DISPLAY
Invalid operator handling
InvalidOp, CLEAR
STORE Result
JUMP DISPLAY
Display the result
DISPLAY, LOAD Result
OUTPUT
JUMP MainLoop Go back to main loop
Define variables
X DEC
Y DEC
Operator, DEC
Result, DEC
Quotient, DEC
Remainder, DEC
TempY, DEC
PlusOp, DEC ASCII code for
MinusOp, DEC ASCII code for
MultOp, DEC ASCII code for
DivOp, DEC ASCII code for
One, DEC
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started