I am trying to make a program that first takes n inputs from the user, and then calculates the sum of those numbers. Then I want the program to print if the sum is an even or an odd number.
For example if the user types in 3, he/she will have to type in 3 numbers (for example 3, 2, 5): then the program will calculate the sum of those (3 + 2 + 5) and print out if the answer (10) is an odd or an even number.
I thought I coded it right, but it doesn't run in the LMC simulator, can someone please help me finding the error?
My code:
INP
STA b
ab INP
STA a
LDA total
ADD a
STA total
STA count
LDA b
SUB one
STA b
BRZ number
BRP loop
bc LDA count
SUB two
STA count
BRZ evennumber
BRP number
LDA total
OUT
LDA space
OTC
OTC
LDA o
OTC
LDA d
OTC
OTC
LDA e
OTC
HLT
cd LDA total
OUT
LDA space
OTC
OTC
LDA p
OTC
LDA A
OTC
LDA r
OTC
HLT
a DAT 0
b DAT 0
total DAT 0
one DAT 1
two DAT 2
count DAT 0
o DAT 111
space DAT 32
d DAT 100
e DAT 101
p DAT 112
A DAT 97
r DAT 114