Concatenative language
Concatenative topics
Concatenative meta
Other languages
Meta
[[https://wiki.xxiivv.com/site/uxntal.html|Tal or Uxntal]] is a stack-based assembly language for the [[https://wiki.xxiivv.com/site/uxn.html|Uxn]] virtual machine designed to work within a 16-bit addressing space. It is a small stack-based computer specialized for building small, low-energy, audio-visual applications with a napkin-size specification and implementation in [[https://wiki.xxiivv.com/etc/uxnmin.c.txt|100 lines of C]]. Finally, it powers the personal computing stack called [[https://wiki.xxiivv.com/site/varvara.html|Varvara]]. [{@fib ( num* -- numfib* ) #0001 GTH2k ?{ POP2 JMP2r } SUB2k fib STH2 INC2 SUB2 fib STH2r ADD2 JMP2r}] The Uxn specification provides Tal with two 256 bytes circular stacks and 64kb of RAM. The language features support for [[Quotations|anonymous functions]], and [[arity checking]]. === FizzBuzz Implementation === [{@on-reset ( -> ) #6400 &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 ( exit ) #800f DEO BRK @<print-dec> ( num -- ) ( x0 ) DUP #0a DIV <print-num> ( 0x ) #0a DIVk MUL SUB ( >> ) @<print-num> ( num -- ) #30 ADD #18 DEO JMP2r @<print-str> ( addr* -- ) LDAk #18 DEO INC2 & LDAk ?<print-str> POP2 JMP2r @dict ( strings ) &fizz "Fizz $1 &buzz "Buzz $1}] == Map Implementation == [tal{{ 01 02 03 04 } { DUP MUL JMP2r } map}] Example implementation of map: [tal{@map ( | arr* f* -- arr* ) SWP2r LITr _&f STR2r SWP2r STH2r DUP2k #0002 SUB2 LDA2 ADD2 SWP2 &>l ( to* from* -- ) STH2k LDAk [ LIT2 &f $2 ] JSR2 STH2r STA INC2 GTH2k ?&>l POP2 POP2 JMP2r}]
Describe this revision:
Save