uxn

Varvara Ordinator, written in ANSI C(SDL2)
git clone https://git.eamoncaddigan.net/uxn.git
Log | Files | Refs | README | LICENSE

commit d7f96acb93742744fec32ba667a4b4438dcf90cf
parent 5d39dcdbdcdd98457936625bdde1b9282a228af1
Author: neauoire <aliceffekt@gmail.com>
Date:   Tue,  5 Sep 2023 20:05:14 -0700

(fizzbuzz.tal) Housekeeping

Diffstat:
Mprojects/examples/exercises/fizzbuzz.tal | 33+++++++++++++++------------------
1 file changed, 15 insertions(+), 18 deletions(-)

diff --git a/projects/examples/exercises/fizzbuzz.tal b/projects/examples/exercises/fizzbuzz.tal @@ -1,33 +1,30 @@ ( FizzBuzz: From 1 to 100, for multiples of 3 print "Fizz", of 5 "Buzz" and for both "FizzBuzz" ) -|0100 - @on-reset ( -> ) #6400 - &loop ( integer ) - DUP print-dec #2018 DEO - DUP #03 mod ?&>no-3 - ;dict/fizz print-str &>no-3 - DUP #05 mod ?&>no-5 - ;dict/buzz print-str &>no-5 + &loop ( -- ) + DUP <print-dec> + #2018 DEO + DUP #03 DIVk MUL SUB ?{ ;dict/fizz <print-str>/ } + DUP #05 DIVk MUL SUB ?{ ;dict/buzz <print-str>/ } #0a18 DEO INC GTHk ?&loop POP2 - ( halt ) #010f DEO + ( exit ) #800f DEO BRK -@mod ( a b -- c ) - DIVk MUL SUB JMP2r +@<print-dec> ( num -- ) + ( x0 ) DUP #0a DIV <print-num> + ( 0x ) #0a DIVk MUL SUB + ( >> ) -@print-dec ( num -- ) - ( x0 ) DUP #0a DIV print-dec/num - ( 0x ) #0a DIVk MUL SUB &num #30 ADD #18 DEO +@<print-num> ( num -- ) + #30 ADD #18 DEO JMP2r -@print-str ( addr* -- ) - &while ( -- ) - LDAk #18 DEO - INC2 LDAk ?&while +@<print-str> ( addr* -- ) + LDAk #18 DEO + INC2 & LDAk ?<print-str> POP2 JMP2r @dict ( strings )