Wondering what exactly is wrong with this MARIE assembly code? (Calculator)

770 Views Asked by At
ORG 100 /Start Here

INPUT

Store X /Store 1st input value in X

INPUT

Store Y / Store 2nd input value in Y

choice, INPUT

Store C /Store choice in C

if, Load C

Subt A

Skipcond 400

Jump elseif1

JnS ADDITION /Call subroutine

Jump end

elseif1, Load C

Subt S

Skipcond 400

Jump elseif2

JnS SUBTRACT /Call subroutine

Jump end

elseif2, Load C

Subt M

Skipcond 400

Jump elseif3

JnS MULTIPLY /Call subroutine

Jump end

elseif3, Load C

Subt D

Skipcond 400

Jump elseif4

JnS DIVISION /Call subroutine

Jump end

elseif4, Load C

Subt Q

Skipcond 400

Jump choice /re-enter choice

Halt /stop the program

end, Output /Display the value

Halt /Stop

X, DEC 0

Y, DEC 0

C, DEC 0

/add two numbers

ADDITION Load X   

Add Y

JumpI ADDITION / Indirect jump to return.

/subtract two numbers

SUBTRACT Load X   

Subt Y

JumpI SUBTRACT / Indirect jump to return.

/multiply two numbers using continuous add loop

MULTIPLY loop, Load num

Add X

Store num

Load Y

Subt one

Store Y

Skipcond 400

Jump loop

Load num

JumpI MULTIPLY / Indirect jump to return.

/divide two numbers and return the quotient

DIVIDE If, Load X

Subt Y

Skipcond 800  

Jump EndIf   

Store X

Load quo

Add one

Store quo

Jump If

EndIf, Load quo

JumpI DIVIDE / Indirect jump to return.

/constants values

one, DEC 1

num, DEC 0

rem, DEC 0

quo, DEC 0

A, DEC 97 /a

M, DEC 109 /m

S, DEC 115 /s

D, DEC 100 /d

Q, DEC 113 /q

This is a calculator that is supposed to add, subtract, multiply, and divide. Once the user is done with an operand it is supposed to directly go to the next one as well, but it is giving me errors and I can't seem to fix them. Everything looks fine to me but it keeps saying "Operand undefined." I'm sure this is an obvious error to others but I can't seem to fix it. Was hoping someone can help me with this! Thanks!

0

There are 0 best solutions below