In: Computer Science
Im having issues with this project, I keep geting errors and idk why.
here are the instructions for the project:
"Create "simple integer calculator using the MARIE computer.
The program should execute as follows:
Using the INPUT instruction wait for the user to enter a decimal number.
Using the INPUT instruction wait for the user to enter a second decimal number.
Using the INPUT instruction wait for the user to enter the character +, - or *.
Perform the desired addition, subtraction or multiplication operation.
Store the result in a variable in memory.
Display the result via the OUTPUT instruction.
The multiply can be done by repeated additions. For example, 12 * 3 would be calculated as 12 + 12 + 12."
What I have so far:
INPUT
Store X
INPUT
Store Y
INPUT
Store c
Subt 43
/ Skipcond can be used here if c<0 then its Multiplication , if c=0 then its Addition , if c>0 then its substraction
loop,Load num
Add X
Store num
Load Y
Subt one
Store Y
Skipcond 400
Jump loop /no
Load num
Output
Halt/Declarelabelshere
X, DEC 0
Y, DEC 0
one, DEC 1
num, DEC 0
c, DEC 0
A, DEC 42
B, DEC 43
C, DEC 45
what I get when I run:
Assembly listing for: Calc project.mas
Assembled: Tue Oct 13 17:14:46 CDT 2020
000 5000 | INPUT
001 2012 | STORE X
002 5000 | INPUT
003 2013 | STORE Y
004 5000 | INPUT
005 2016 | STORE c
006 4043 | SUBT 043
| / Skipcond can be used here if c0 then its Multiplication , if c=0 then its Addition , if c>0 then its substraction
007 ???? | loop NUM
**** Instruction not recognized.
**** Missing operand.
008 3012 | ADD X
009 2015 | STORE num
00A 1013 | LOAD Y
00B 4014 | SUBT one
00C 2013 | STORE Y
00D 8400 | SKIPCOND 400
00E 9007 | JUMP loop /no
00F 1015 | LOAD num
010 6000 | OUTPUT
011 7000 | HALT /Declarelabelshere
012 0000 | X DEC 0
013 0000 | Y DEC 0
014 0001 | one DEC 1
015 0000 | num DEC 0
016 0000 | c DEC 0
017 002A | A DEC 42
018 002B | B DEC 43
019 002D | C DEC 45
2 errors found. Assembly unsuccessful.
SYMBOL TABLE
--------------------------------------------------
Symbol | Defined | References
--------+---------+-------------------------------
A | 017 |
B | 018 |
C | 019 |
X | 012 | 001, 008
Y | 013 | 003, 00A, 00C
c | 016 | 005
loop | 007 | 00E
num | 015 | 009, 00F
one | 014 | 00B
Greetings!!
Code:
INPUT /READ X
STORE X /STORE X
INPUT /READ Y
STORE Y /STORE Y
INPUT /READ DECIMAL VALUE OF OPERATOR
STORE C /STORE OPERATOR
SUBT OP /SUBTRACT 43
SKIPCOND 800 /CHECK AC>0, THEN MUL
JUMP ADSUB /ELSE ADSUB
JUMP MUL
ADSUB, SKIPCOND 000/AC<0, THEN SUB
JUMP ADD /ELSE ADD
JUMP SUB
ADD, LOAD X /ADDITION
ADD Y
STORE ANS /STORE ANSWER
JUMP OUT /DISPLAY
SUB, LOAD X /SUBTRACTION
SUBT Y
STORE ANS /STORE ANSWER
JUMP OUT /DISPLAY
MUL, LOAD Y /LOAD MULTIPLIER
SUBT ONE /MULTIPLIER - 1
STORE Y /SAVE
LOAD ANS /LOAD ANS
ADD X /REPEATED ADDITION
STORE ANS
LOAD Y /LOAD MULTIPLIER
SKIPCOND 400 /IF MULTIPLIER IS 0,THEN LOAD ANSWER
JUMP MUL /ELSE REPEAT ADDITION
LOAD ANS /LOAD ANS OR DISPLAY
OUT, OUTPUT
HALT
X, DEC 0
Y, DEC 0
C, DEC 0
OP, DEC 43
ONE, DEC 1
ANS, DEC 0
Output screenshots:
Addition:34+45=79

Subtraction: 78-67=11

Multiplication: 23 x 15 = 345

Hope this helps