2023-04-17 01:03:44 -04:00
|
|
|
( usage: uxncli console.rom arg1 arg2 arg3
|
2022-03-27 14:53:24 -04:00
|
|
|
Prints Hello Uxn!, and listens for incoming stdin events on enter. )
|
2021-02-20 18:00:34 -05:00
|
|
|
|
2023-04-17 01:03:44 -04:00
|
|
|
|10 @Console &vector $2 &read $1 &pad $4 &type $1 &write $1 &error $1
|
2021-04-21 08:45:17 -04:00
|
|
|
|
2023-04-05 19:50:06 -04:00
|
|
|
|00
|
|
|
|
|
|
|
|
@buf
|
|
|
|
|
2021-04-21 12:48:04 -04:00
|
|
|
|0100 ( -> )
|
2021-02-20 18:00:34 -05:00
|
|
|
|
2022-03-27 14:53:24 -04:00
|
|
|
( set vector )
|
2023-04-17 01:03:44 -04:00
|
|
|
;on-argument .Console/vector DEO2
|
2022-03-27 14:53:24 -04:00
|
|
|
( print hello )
|
2023-04-17 01:03:44 -04:00
|
|
|
;hello-txt pstr
|
2021-07-28 18:41:07 -04:00
|
|
|
|
2021-05-13 11:47:18 -04:00
|
|
|
BRK
|
2021-02-20 18:00:34 -05:00
|
|
|
|
2023-04-17 01:03:44 -04:00
|
|
|
@on-argument ( -> )
|
2022-03-27 14:53:24 -04:00
|
|
|
|
2023-04-17 01:03:44 -04:00
|
|
|
.Console/type DEI ?&no-argend
|
|
|
|
;on-stdin .Console/vector DEO2
|
|
|
|
BRK
|
|
|
|
&no-argend
|
|
|
|
.Console/read DEI .buf skey ?&eval
|
2023-04-05 19:50:06 -04:00
|
|
|
|
|
|
|
BRK
|
|
|
|
|
2023-04-17 01:03:44 -04:00
|
|
|
&eval ( -> )
|
2023-04-05 19:50:06 -04:00
|
|
|
|
2023-04-17 01:03:44 -04:00
|
|
|
print-type
|
|
|
|
;yousent-txt pstr
|
|
|
|
LIT "" #18 DEO
|
|
|
|
;buf pstr
|
|
|
|
LIT "" #18 DEO #0a18 DEO
|
|
|
|
;buf sclr
|
|
|
|
|
|
|
|
.Console/type DEI #04 NEQ ?&no-close
|
|
|
|
;argend-txt pstr
|
|
|
|
;on-stdin .Console/vector DEO2
|
|
|
|
&no-close
|
|
|
|
|
|
|
|
BRK
|
|
|
|
|
|
|
|
@on-stdin ( -> )
|
|
|
|
|
|
|
|
.Console/read DEI .buf skey ?&eval
|
|
|
|
|
|
|
|
BRK
|
|
|
|
|
|
|
|
&eval ( -> )
|
2023-04-05 20:18:03 -04:00
|
|
|
|
2023-04-17 01:03:44 -04:00
|
|
|
print-type
|
|
|
|
;buf ;quit-txt scmp ?quit
|
|
|
|
;yousaid-txt pstr
|
2023-04-05 20:18:03 -04:00
|
|
|
LIT "" #18 DEO
|
2023-04-17 01:03:44 -04:00
|
|
|
;buf pstr
|
2023-04-05 20:18:03 -04:00
|
|
|
LIT "" #18 DEO #0a18 DEO
|
2023-04-17 01:03:44 -04:00
|
|
|
;buf sclr
|
2023-04-05 19:50:06 -04:00
|
|
|
|
|
|
|
BRK
|
|
|
|
|
2023-04-17 01:03:44 -04:00
|
|
|
@print-type ( -- )
|
|
|
|
|
|
|
|
[ LIT2 00 -Console/type ] DEI #01 GTH DUP ADD ;types ADD2 LDA2
|
|
|
|
|
|
|
|
!pstr
|
|
|
|
|
2023-04-05 19:50:06 -04:00
|
|
|
@quit ( buf* -> )
|
|
|
|
|
|
|
|
POP2 #010f DEO
|
2022-03-27 14:53:24 -04:00
|
|
|
|
|
|
|
BRK
|
|
|
|
|
2023-04-17 01:03:44 -04:00
|
|
|
(
|
|
|
|
@|stdlib )
|
|
|
|
|
|
|
|
@pstr ( str* -- )
|
2022-03-27 14:53:24 -04:00
|
|
|
|
|
|
|
&while
|
|
|
|
LDAk #18 DEO
|
2023-04-05 19:50:06 -04:00
|
|
|
INC2 LDAk ?&while
|
2022-03-27 14:53:24 -04:00
|
|
|
POP2
|
|
|
|
|
|
|
|
JMP2r
|
|
|
|
|
2023-04-05 20:18:03 -04:00
|
|
|
@skey ( key buf -- proc ) OVR #20 LTH ?&eval #00 SWP sput #00 JMP2r &eval POP2 #01 JMP2r
|
2023-04-05 19:50:06 -04:00
|
|
|
@sclr ( str* -- ) LDAk ?&w POP2 JMP2r &w STH2k #00 STH2r STA INC2 LDAk ?&w POP2 JMP2r
|
|
|
|
@scap ( str* -- end* ) LDAk ?&w JMP2r &w INC2 LDAk ?&w JMP2r
|
|
|
|
@sput ( chr str* -- ) scap INC2k #00 ROT ROT STA STA JMP2r
|
|
|
|
@scmp ( a* b* -- f ) STH2 &l LDAk LDAkr STHr ANDk #00 EQU ?&e NEQk ?&e POP2 INC2 INC2r !&l &e NIP2 POP2r EQU JMP2r
|
2023-04-17 01:03:44 -04:00
|
|
|
@phex ( short* -- ) SWP phex/b &b ( byte -- ) DUP #04 SFT phex/c &c ( char -- ) #0f AND DUP #09 GTH #27 MUL ADD #30 ADD #18 DEO JMP2r
|
|
|
|
|
|
|
|
(
|
|
|
|
@|assets )
|
|
|
|
|
|
|
|
@types
|
|
|
|
=std-txt
|
|
|
|
=arg-txt
|
2023-04-05 19:50:06 -04:00
|
|
|
|
|
|
|
@hello-txt "Welcome 20 "to 20 "Uxn! 0a $1
|
2022-03-27 14:53:24 -04:00
|
|
|
@yousaid-txt "You 20 "said: 20 $1
|
2023-04-17 01:03:44 -04:00
|
|
|
@yousent-txt "You 20 "sent: 20 $1
|
|
|
|
@std-txt "(std) $1
|
|
|
|
@arg-txt "(arg) $1
|
2023-04-05 19:50:06 -04:00
|
|
|
@quit-txt "quit $1
|
2023-04-17 01:03:44 -04:00
|
|
|
@argend-txt "(argend) 0a $1
|
2023-04-05 19:50:06 -04:00
|
|
|
|