0
0
Fork 0
mirror of https://git.sr.ht/~rabbits/uxn synced 2024-11-05 22:05:04 +00:00
uxn/projects/examples/exercises/fib.tal

24 lines
441 B
Tal
Raw Normal View History

2022-02-23 23:23:38 +00:00
( The Fibonacci Sequence
A series of numbers where the next number is made of the two numbers before it )
%HALT { #010f DEO }
%EMIT { #18 DEO }
%PRINT { DUP2 ,print JSR #0a EMIT }
|0100 ( -> )
2022-02-23 23:37:29 +00:00
#0000 INC2k ADD2k
&loop
PRINT ADD2k LTH2k ,&loop JCN
2022-02-23 23:23:38 +00:00
HALT
BRK
@print ( short* -- )
&short ( short* -- ) SWP ,&byte JSR
&byte ( byte -- ) DUP #04 SFT ,&char JSR
&char ( char -- ) #0f AND DUP #09 GTH #27 MUL ADD #30 ADD EMIT
JMP2r