diff --git a/ref/console.tal b/ref/console.tal new file mode 100644 index 0000000..23ef375 --- /dev/null +++ b/ref/console.tal @@ -0,0 +1,108 @@ +( usage: uxncli console.rom arg1 arg2 arg3 Prints Hello Uxn!, and listens for incoming stdin events on enter. ) + +|10 @Console &vector $2 &read $1 &pad $4 &type $1 &write $1 &error $1 + +|0000 + + @buf + +|0100 + +@on-reset ( -> ) + ;on-argument .Console/vector DEO2 + .Console/type DEI ?{ ;on-stdin .Console/vector DEO2 } + ;dict/hello + BRK + +@on-argument ( -> ) + .Console/read DEI .buf skey ?{ BRK } + + ;dict/yousent + LIT "" #18 DEO + ;buf / + LIT "" #18 DEO + #0a18 DEO + ;buf sclr/ .Console/type DEI #04 NEQ ?{ + ;dict/argend + ;on-stdin .Console/vector DEO2 } + BRK + +@on-stdin ( -> ) + .Console/read DEI .buf skey ?{ BRK } + ;buf ;dict/quit scmp ?&quit + + ;dict/yousaid + LIT "" #18 DEO + ;buf / + LIT "" #18 DEO + #0a18 DEO + ;buf sclr/ BRK + &quit ( buf* -> ) + #800f DEO + BRK + +@ ( -- ) + [ LIT2 00 -Console/type ] DEI #01 GTH DUP ADD ;types ADD2 + ( ) LDA2 !/ + +( +@|stdlib ) + +@ ( str* -- ) + &w ( -- ) + LDAk #18 DEO + INC2 & LDAk ?&w + POP2 JMP2r + +@sclr ( str* -- ) + &w ( -- ) + STH2k #00 STH2r STA + INC2 & LDAk ?&w + POP2 JMP2r + +@skey ( key buf -- proc ) + OVR #20 LTH ?{ + #00 SWP sput #00 JMP2r } + POP2 #01 JMP2r + +@scap ( str* -- end* ) + &w ( -- ) + INC2 & LDAk ?&w + JMP2r + +@sput ( chr str* -- ) + scap/ STA + JMP2r + +@scmp ( a* b* -- f ) + STH2 + &l ( a* b* -- f ) + LDAk LDAkr STHr NEQk ?&d + DUP EOR EQUk ?&d + POP2 INC2 INC2r !&l + &d ( a* c1 c2 b* -- f ) + NIP2 POP2r EQU JMP2r + +@ ( short* -- ) + SWP /b + &b ( -- ) + DUP #04 SFT /c + &c ( -- ) + #0f AND DUP #09 GTH #27 MUL ADD [ LIT "0 ] ADD #18 DEO + JMP2r + +( +@|assets ) + +@types + =dict/std =dict/arg + +@dict ( ) + &hello "Welcome 20 "to 20 "Uxn! 0a $1 + &yousaid "You 20 "said: 20 $1 + &yousent "You 20 "sent: 20 $1 + &std "(std) $1 + &arg "(arg) $1 + &quit "quit $1 + &argend "(argend) 0a $1 + diff --git a/ref/drifloon.bin b/ref/drifloon.bin new file mode 100644 index 0000000..2b88239 Binary files /dev/null and b/ref/drifloon.bin differ diff --git a/ref/makefile b/ref/makefile index 39f4cdb..1ec0e48 100644 --- a/ref/makefile +++ b/ref/makefile @@ -4,9 +4,8 @@ all: bin/uxn run: all @ wc -c bin/uxn - @ bin/uxn test.bin "Text from arg" -test: all - @ bin/uxn opc-test.bin + @ cat console.tal | bin/uxn drifloon.bin > bin/console.rom + @ bin/uxn test.bin "String sent through stdin" format: @ clang-format -i uxn.c clean: diff --git a/ref/opc-test.bin b/ref/opc-test.bin deleted file mode 100644 index 3cb434d..0000000 Binary files a/ref/opc-test.bin and /dev/null differ