2023-07-16 17:04:40 +00:00
|
|
|
( usage: uxncli console.rom arg1 arg2 arg3 Prints Hello Uxn!, and listens for incoming stdin events on enter. )
|
2021-02-20 23:00:34 +00:00
|
|
|
|
2023-04-17 05:03:44 +00:00
|
|
|
|10 @Console &vector $2 &read $1 &pad $4 &type $1 &write $1 &error $1
|
2021-04-21 12:45:17 +00:00
|
|
|
|
2023-07-16 17:04:40 +00:00
|
|
|
|0000
|
2023-04-05 23:50:06 +00:00
|
|
|
|
|
|
|
@buf
|
|
|
|
|
2023-07-16 17:04:40 +00:00
|
|
|
|0100
|
2021-02-20 23:00:34 +00:00
|
|
|
|
2023-07-16 17:04:40 +00:00
|
|
|
@on-reset ( -> )
|
2023-04-17 05:03:44 +00:00
|
|
|
;on-argument .Console/vector DEO2
|
2023-07-16 17:04:40 +00:00
|
|
|
;dict/hello <print-str>
|
|
|
|
.Console/type DEI ?&has-arg
|
|
|
|
BRK
|
|
|
|
&has-arg ( -> )
|
|
|
|
;dict/queue <print-str>
|
|
|
|
BRK
|
2021-02-20 23:00:34 +00:00
|
|
|
|
2023-04-17 05:03:44 +00:00
|
|
|
@on-argument ( -> )
|
2023-07-16 17:04:40 +00:00
|
|
|
.Console/type DEI ?&>no-argend
|
2023-04-17 05:03:44 +00:00
|
|
|
;on-stdin .Console/vector DEO2
|
2023-07-16 17:04:40 +00:00
|
|
|
BRK &>no-argend
|
2023-04-17 05:03:44 +00:00
|
|
|
.Console/read DEI .buf skey ?&eval
|
2023-07-16 17:04:40 +00:00
|
|
|
BRK
|
|
|
|
&eval ( -> )
|
|
|
|
<print-type>
|
|
|
|
;dict/yousent <print-str>
|
2023-04-17 05:03:44 +00:00
|
|
|
LIT "" #18 DEO
|
2023-07-16 17:04:40 +00:00
|
|
|
;buf <print-str>
|
|
|
|
LIT "" #18 DEO
|
|
|
|
#0a18 DEO
|
|
|
|
;buf sclr .Console/type DEI #04 NEQ ?&>no-close
|
|
|
|
;dict/argend <print-str>
|
|
|
|
;on-stdin .Console/vector DEO2 &>no-close
|
|
|
|
BRK
|
2023-04-17 05:03:44 +00:00
|
|
|
|
|
|
|
@on-stdin ( -> )
|
|
|
|
.Console/read DEI .buf skey ?&eval
|
2023-07-16 17:04:40 +00:00
|
|
|
BRK
|
|
|
|
&eval ( -> )
|
|
|
|
<print-type>
|
|
|
|
;buf ;dict/quit scmp ?&quit
|
|
|
|
;dict/yousaid <print-str>
|
2023-04-06 00:18:03 +00:00
|
|
|
LIT "" #18 DEO
|
2023-07-16 17:04:40 +00:00
|
|
|
;buf <print-str>
|
|
|
|
LIT "" #18 DEO
|
|
|
|
#0a18 DEO
|
|
|
|
;buf sclr BRK
|
|
|
|
&quit ( buf* -> )
|
|
|
|
#010f DEO
|
|
|
|
BRK
|
2022-03-27 18:53:24 +00:00
|
|
|
|
2023-07-16 17:04:40 +00:00
|
|
|
@<print-type> ( -- )
|
|
|
|
[ LIT2 00 -Console/type ] DEI #01 GTH DUP ADD ;types ADD2 LDA2 !<print-str>
|
2022-03-27 18:53:24 +00:00
|
|
|
|
2023-04-17 05:03:44 +00:00
|
|
|
(
|
|
|
|
@|stdlib )
|
|
|
|
|
2023-07-16 17:04:40 +00:00
|
|
|
@<print-str> ( str* -- )
|
|
|
|
!&
|
|
|
|
&while ( -- )
|
2022-03-27 18:53:24 +00:00
|
|
|
LDAk #18 DEO
|
2023-07-16 17:04:40 +00:00
|
|
|
INC2 & LDAk ?&while
|
|
|
|
POP2 JMP2r
|
|
|
|
|
|
|
|
@skey ( key buf -- proc )
|
|
|
|
OVR #20 LTH ?&eval
|
|
|
|
#00 SWP sput #00 JMP2r
|
|
|
|
&eval POP2 #01 JMP2r
|
|
|
|
|
|
|
|
@sclr ( str* -- )
|
|
|
|
!&
|
|
|
|
&while ( -- )
|
|
|
|
STH2k #00 STH2r STA
|
|
|
|
INC2 & LDAk ?&while
|
|
|
|
POP2 JMP2r
|
|
|
|
|
|
|
|
@scap ( str* -- end* )
|
|
|
|
!&
|
|
|
|
&while ( -- )
|
|
|
|
INC2 & LDAk ?&while
|
|
|
|
JMP2r
|
|
|
|
|
|
|
|
@sput ( chr str* -- )
|
|
|
|
scap INC2k #00 ROT ROT STA
|
|
|
|
STA
|
|
|
|
JMP2r
|
|
|
|
|
|
|
|
@scmp ( a* b* -- f )
|
|
|
|
STH2
|
|
|
|
&loop ( -- )
|
|
|
|
LDAk LDAkr STHr ANDk #00 EQU ?&e
|
|
|
|
NEQk ?&e
|
|
|
|
POP2 INC2 INC2r !&loop
|
|
|
|
&e NIP2 POP2r EQU JMP2r
|
2023-04-17 05:03:44 +00:00
|
|
|
|
|
|
|
(
|
|
|
|
@|assets )
|
|
|
|
|
|
|
|
@types
|
2023-07-16 17:04:40 +00:00
|
|
|
=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
|
|
|
|
&queue "(queue) 0a $1
|
2023-04-05 23:50:06 +00:00
|
|
|
|