Evening Rich,
I would do something like the following, equally untested - assumes the
channel to the screen is open, etc.
Is it elegant? I don't know, probably not. Is it simple, yes. And no
messing with the arithmetic stack etc either, all done in integers.
begin equ 1
exit equ 101
io_sbyte equ ...
ut_mint equ ...
ut_mtext equ ...
start open channel, id in A0 etc.
moveq #begin,D6 ; Counter is .L but value is .B.
loop bsr.s print_d6 ; Print the digit
bsr.s fizbuz ; Fizz or buzz or both
bsr.s newline ; Print a newline
addq.l #1,d6 ; Next value
cmpi.b #exit,d6 ; > 100?
bne.s loop ; Nope, keep going
done close channels etc
rts
newline moveq #10,d1 ; Newline
moveq #-1,d3 ; Timeout
moveq #io_sbyte,d0
trap #3
rts
printd6 move.w d6,d1 ; Get value in D1.W
movea.w ut_mint,a2
jsr (a2) ; Print D1.W as ASCII
rts
fizbuz move.l d6,d7 ; Copy to D7.L
divu #3,d7 ; Divide by 3
swap d7 ; Remainder
tst.w d7 ; Zero?
bne.s buz ; No fizz
bsr.s p_fizz ; print FIZZ
buz move.l d6,d7
divu #5,d7 ; Divide by 5
swap d7 ; Remainder
tst.w d7 ; Zero?
bne.s fz_done ; No buzz
bsr.s p_buzz ; print BUZZ
rts
fizz DC.W #4
DC.B 'FIZZ'
buzz DC.W #4
DC.B 'BUZZ'
p_fizz lea fizz,a1 ; String to print
bra.s p_f_b ; print it
p_buzz lea buzz,a1 ; String to print
p_f_b movea.w ut_mtext,a2
jsr (a2)
rts
Cheers,
Norman.
--
Norman Dunbar
Dunbar IT Consultants Ltd
Registered address:
Thorpe House
61 Richardshaw Lane
Pudsey
West Yorkshire
United Kingdom
LS28 7EL
Company Number: 05132767
_______________________________________________
QL-Users Mailing List
http://www.q-v-d.demon.co.uk/smsqe.htm