I am getting stuck on writing a program for the following:
a2 + (b x c).
There appears to be a problem with my loops, but I cannot solve it.
I can get a2 and a multiplication, but when I try to combine the two, it just keeps asking for inputs over and over again.
Multiply:
INP
STA b
INP STA c
LOOP LDA c
BRZ ENDTHIS
SUB ONE1
STA c
LDA ANS1
ADD b
STA ANS1
BRA LOOP
ENDTHIS LDA ANS1
OUT
SUB ANS1
STA ANS1
HLT
b DAT
c DAT
ONE1 DAT 1
ANS1 DAT 0
Square:
INP
STA a
LDA a
STA y
LOOP LDA y
BRZ END
SUB ONE2
STA y
LDA ANS2
ADD a
STA ANS2
BRA LOOP
END LDA ANS2
OUT
SUB ANS2
STA ANS2
HLT
a DAT
y DAT
ONE2 DAT 1
ANS2 DAT 0
But can't get them to work together