0
0
Fork 0
mirror of https://git.sr.ht/~rabbits/uxn synced 2024-12-03 11:07:25 +00:00
uxn/projects/examples/exercises/fib.tal

24 lines
388 B
Tal
Raw Normal View History

2022-03-25 17:29:45 +00:00
( Fibonacci:
A series of numbers where the next number
is made of the two numbers before it )
2022-02-23 23:23:38 +00:00
2022-03-25 17:29:45 +00:00
|0100 ( -> ) @reset
2022-02-23 23:23:38 +00:00
2022-03-25 17:29:45 +00:00
#0000 INC2k ADD2k
&loop
2022-11-10 17:08:21 +00:00
DUP2 ,print-hex JSR #0a18 DEO
2022-03-25 17:29:45 +00:00
ADD2k LTH2k ,&loop JCN
2022-11-10 17:08:21 +00:00
( halt )
#010f DEO
2022-02-23 23:23:38 +00:00
BRK
2022-11-10 17:08:21 +00:00
@print-hex ( short* -- )
2022-02-23 23:23:38 +00:00
SWP ,&byte JSR
2022-02-23 23:23:38 +00:00
&byte ( byte -- ) DUP #04 SFT ,&char JSR
2022-03-25 17:29:45 +00:00
&char ( char -- ) #0f AND DUP #09 GTH #27 MUL ADD #30 ADD #18 DEO
2022-02-23 23:23:38 +00:00
JMP2r