I'm having trouble displaying any output to my answer buffer after going through the loop even when I put in 2 it doesn't show that as an output. I'm sure my problem is in the for, if, or factor blocks but I have been looking at my code for a while and nothing has helped. Any help is appreciated!
for:
cmp.l D0,D3 *D3-D0
bne if *!= 0
move.l D3,(A2)+
bra done
if:
move.l D0,D7
divu D3,D7
clr.w D7
swap D7
move.w D7,D6
tst.w D6
beq factor
addq #1,D3
bra for
factor:
move.b #'*',(A2)+
move.b D3,(A2)+
bra done
divu D3,D0
swap D0
clr.w D0
swap D0
subq #1,D3
bra for
here:
move.l D3,(A2)+
bra done
writing the value itself and as long won't display anything, since it starts by zero, plus you have to add #'0'
:
move.b D3,(A2)
add.b #'0',(A2)+
bra done
same here:
factor:
move.b #' * ',(A2)+
move.b D3,(A2)+
the first line is suspicious and probably assembler-dependent, since you're storing a 3-byte string in a byte...
the second line misses the 0 ascii code addition. I'd rewrite as:
factor:
move.b #' ',(A2)+
move.b #'*',(A2)+
move.b #' ',(A2)+
move.b D3,(A2)
add.b #'0',(A2)+