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