Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Create a simple integer calculator using the MARIE computer. The program should execute as follows: 1 . Using the INPUT instruction wait for the user

Create a simple integer calculator using the MARIE computer.
The program should execute as follows:
1. Using the INPUT instruction wait for the user to enter a decimal number.
2. Using the INPUT instruction wait for the user to enter the operator as the ASCII character +,- or *.
3. Using the INPUT instruction wait for the user to enter a second decimal number.
4. Perform the desired addition, subtraction, or multiplication operation.
5. Store the result in a variable in memory.
6. Display the result via the OUTPUT instruction.
7. If an invalid operation is requested, display a zero as the result.
8. The code should be clearly commented.
The multiply can be done by repeated additions. For example, 12*3 would be calculated as 12+12+12. You need to support a negative multiplier and negative multiplicand (12*-3).
Implement divide by allowing the user to enter /. Only positive numbers need to be supported. Both the resulting quotient and remainder need to be displayed. The divide can be done by repeated subtractions
my program shows syntax errot as shown in the screenshot. how can i fix it?
/ Addition, Subtraction, Multiplication, and Division Calculator
/ Main Program
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)
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 400
Jump ADD
Load Operator
Subt MinusOp
Skipcond 400
Jump SUBTRACT
Load Operator
Subt MultOp
Skipcond 400
Jump MULTIPLY
Load Operator
Subt DivOp
Skipcond 400
Jump DIVIDE
/ Invalid operator entered
InvalidOp, Clear
Output / Output 0 if invalid operator
Halt
/ 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
Skipcond 000/ If Y is zero, skip multiplication
Jump MULTIPLY_END
MULTIPLY_LOOP,
Load X
Add Result
Store Result
Load Y
Subt One
Store Y
Skipcond 400
Jump MULTIPLY_LOOP
MULTIPLY_END,
Jump DISPLAY
/ Division Subroutine
DIVIDE, Clear
Store Quotient
Load X
Store Remainder
DIVIDE_LOOP,
Load Remainder
Subt Y
Skipcond 800
Jump DIV_EXIT
Store Remainder
Load Quotient
Add One
Store Quotient
Jump DIVIDE_LOOP
DIV_EXIT, Load Quotient
Store Result
Jump DISPLAY
/ Display the result
DISPLAY, Load Result
Output
Halt
/ Define variables
X, DEC 0
Y, DEC 0
Operator, DEC 0
Result, DEC 0
Quotient, DEC 0
Remainder, DEC 0
PlusOp, HEX 2B / ASCII code for '+'
MinusOp, HEX 2D / ASCII code for '-'
MultOp, HEX 2A / ASCII code for '*'
DivOp, HEX 2F / ASCII code for '/'
One, DEC 1
image text in transcribed

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 Application Development And Design

Authors: Michael V. Mannino

1st Edition

0072463678, 978-0072463675

More Books

Students also viewed these Databases questions