G3orgeLuc4s
Programmer
So I wrote these simple multiplication and devision assembly programs.. I'm getting some errors I don't really understand... my multiplication program always outputs 0... and the division one I'm not even sure what it's doing...
Anyways here's the code:
Multiplication:
.BEGIN
IN A
IN B
CLEAR COUNT
CLEAR SUM
LOOP: LOAD B
COMPARE COUNT
JUMPGT PRINT
LOAD SUM
ADD A
INCREMENT COUNT
JUMP LOOP
PRINT: OUT SUM
HALT
A: .DATA 0
B: .DATA 0
COUNT: .DATA 0
SUM: .DATA 0
.END
Division:
.BEGIN
IN A
IN B
CLEAR Q
LOAD A
STORE R
LOOP: LOAD B
COMPARE R
JUMPLT PRINT
LOAD R
SUBTRACT B
INCREMENT Q
JUMP LOOP
PRINT: OUT Q
OUT R
HALT
A: .DATA 0
B: .DATA 0
Q: .DATA 0
R: .DATA 0
.END
Thanks for your time.
Anyways here's the code:
Multiplication:
.BEGIN
IN A
IN B
CLEAR COUNT
CLEAR SUM
LOOP: LOAD B
COMPARE COUNT
JUMPGT PRINT
LOAD SUM
ADD A
INCREMENT COUNT
JUMP LOOP
PRINT: OUT SUM
HALT
A: .DATA 0
B: .DATA 0
COUNT: .DATA 0
SUM: .DATA 0
.END
Division:
.BEGIN
IN A
IN B
CLEAR Q
LOAD A
STORE R
LOOP: LOAD B
COMPARE R
JUMPLT PRINT
LOAD R
SUBTRACT B
INCREMENT Q
JUMP LOOP
PRINT: OUT Q
OUT R
HALT
A: .DATA 0
B: .DATA 0
Q: .DATA 0
R: .DATA 0
.END
Thanks for your time.