console.tal (1862B)
1 ( usage: uxncli console.rom arg1 arg2 arg3 Prints Hello Uxn!, and listens for incoming stdin events on enter. ) 2 3 |10 @Console &vector $2 &read $1 &pad $4 &type $1 &write $1 &error $1 4 5 |0000 6 7 @buf 8 9 |0100 10 11 @on-reset ( -> ) 12 ;on-argument .Console/vector DEO2 13 .Console/type DEI ?{ ;on-stdin .Console/vector DEO2 } 14 ;dict/hello <print-str> 15 BRK 16 17 @on-argument ( -> ) 18 .Console/read DEI .buf skey ?{ BRK } 19 <print-type> 20 ;dict/yousent <print-str> 21 LIT "" #18 DEO 22 ;buf <print-str>/ 23 LIT "" #18 DEO 24 #0a18 DEO 25 ;buf sclr/ .Console/type DEI #04 NEQ ?{ 26 ;dict/argend <print-str> 27 ;on-stdin .Console/vector DEO2 } 28 BRK 29 30 @on-stdin ( -> ) 31 .Console/read DEI .buf skey ?{ BRK } 32 ;buf ;dict/quit scmp ?&quit 33 <print-type> 34 ;dict/yousaid <print-str> 35 LIT "" #18 DEO 36 ;buf <print-str>/ 37 LIT "" #18 DEO 38 #0a18 DEO 39 ;buf sclr/ BRK 40 &quit ( buf* -> ) 41 #800f DEO 42 BRK 43 44 @<print-type> ( -- ) 45 [ LIT2 00 -Console/type ] DEI #01 GTH DUP ADD ;types ADD2 46 ( ) LDA2 !<print-str>/ 47 48 ( 49 @|stdlib ) 50 51 @<print-str> ( str* -- ) 52 &w ( -- ) 53 LDAk #18 DEO 54 INC2 & LDAk ?&w 55 POP2 JMP2r 56 57 @sclr ( str* -- ) 58 &w ( -- ) 59 STH2k #00 STH2r STA 60 INC2 & LDAk ?&w 61 POP2 JMP2r 62 63 @skey ( key buf -- proc ) 64 OVR #20 LTH ?{ 65 #00 SWP sput #00 JMP2r } 66 POP2 #01 JMP2r 67 68 @scap ( str* -- end* ) 69 &w ( -- ) 70 INC2 & LDAk ?&w 71 JMP2r 72 73 @sput ( chr str* -- ) 74 scap/ STA 75 JMP2r 76 77 @scmp ( a* b* -- f ) 78 STH2 79 &l ( a* b* -- f ) 80 LDAk LDAkr STHr NEQk ?&d 81 DUP EOR EQUk ?&d 82 POP2 INC2 INC2r !&l 83 &d ( a* c1 c2 b* -- f ) 84 NIP2 POP2r EQU JMP2r 85 86 @<phex> ( short* -- ) 87 SWP <phex>/b 88 &b ( -- ) 89 DUP #04 SFT <phex>/c 90 &c ( -- ) 91 #0f AND DUP #09 GTH #27 MUL ADD [ LIT "0 ] ADD #18 DEO 92 JMP2r 93 94 ( 95 @|assets ) 96 97 @types 98 =dict/std =dict/arg 99 100 @dict ( ) 101 &hello "Welcome 20 "to 20 "Uxn! 0a $1 102 &yousaid "You 20 "said: 20 $1 103 &yousent "You 20 "sent: 20 $1 104 &std "(std) $1 105 &arg "(arg) $1 106 &quit "quit $1 107 &argend "(argend) 0a $1 108