From c1eae2f3212b0725eae53d33b3c171e557750a40 Mon Sep 17 00:00:00 2001 From: Devine Lu Linvega Date: Thu, 11 Jan 2024 21:17:56 -0800 Subject: [PATCH] Bootstrap with assembler --- ref/console.tal | 108 +++++++++++++++++++++++++++++++++++++++++++++++ ref/drifloon.bin | Bin 0 -> 1437 bytes ref/makefile | 5 +-- ref/opc-test.bin | Bin 61188 -> 0 bytes 4 files changed, 110 insertions(+), 3 deletions(-) create mode 100644 ref/console.tal create mode 100644 ref/drifloon.bin delete mode 100644 ref/opc-test.bin 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 0000000000000000000000000000000000000000..2b88239f19cf01685896f4c47ead7c2bb0a08dc3 GIT binary patch literal 1437 zcmY*ZZ){Ul6hHUA_N^NXn5AqbBKN+L=Ln1q+Qn{Yd>frIEN$0zsF=y^pbX;Mx|Gd8 zkZ?u_0b(%5ry(YoyZA+nhLE6%@&%32FGhosXrdD12mhg&1`QF+p68WMet7Tv&UroO z{Lb&5Tg@79*#m(0tS|+Hxq=EPV1VNE;t)sCfOn#{7NSGI0E$Kd_nP=rM8HZDN6AD@ z>>#t&#I6?@0V7VY%25*DM=zHQSq%wl?1H(Z-)W^j#SX$f&!3 zQ6vVV0!B0f9`BYZJqsSTwaW9tzhzmJlcb#FoLnxz)?lPO?2qHhMFQGv9sW=mV*-}w z@VmO8fnu|{s&ZRUEqX&Q2r%6PW1p3m-KdRJhss$a6$1F-33*}&R*!L zGW;%4uf%CUW(Y_s78S68&L$;S30P0{gQRk~2VuS(v*#82Lb0)GO5#rm`Xcdm!ln8C zb^I-4t~&mM*pjHP4!|1%R!~nPML$$5N!y~B73{~4v|YaMwz~>m5bOyDT0A@)oVBGO zSLbt|hjtK<%HOQ~x8|rqhk(X8>9KG)mL#EmaTcyB|C76NQWs2dx)a7-VMv0TYT=@V zzKbwRSBnHXH%DA!DBG|tsza~4_}eB8tk+Zi4YhC^uP5BkE(6$fi%I>U4(GhL(xR*^KuZo z8KW+Ax;^E<``a2Lj`7w2)7E!(ijm2g1C>2}0)~fofs|sfR;$*?P0viZ`*)Y8E0CR; z7^~DEQ<)r}-Uo%s-b$@9xw``C{RgJY0Vp1t7^}Llvr?;ePL; z_;|jME2T&BxgCYU;gRg%@S~-znbOv6+wj)=L-FUxkB-g(m>&{=lG5_eAMClZ0@%6^GEo__58ptesBXn W+R2Y^=FdOGUwoLKmHah}zx^L-U8tS_ literal 0 HcmV?d00001 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 3cb434dee520894bdafb0bf325a79a1ac595491a..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 61188 zcmeI!{cjY<83*v$^X}fh#b<-ThmFJfOsGl9OAIj=FnA3P0SkPN-$H0qoq+=rE|}O3 zaZyDd1vR26O7lb7(5QlGTJ;4dm8zs_S~V%E+O$gLrm3nX`JpNeRBfVGSV>eH2fTe| z*9Wx!L8UM9vd_%Ud}sW*-Sf&rIZ9Xak97D*EF^Q?`9qXT4c+LyaA+rKW@=Yz*G-*y zr%$@y%xj%$-UT6~?#aY+d2P{oks7P7Kj()ZWimr?@7<)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