0
0
Fork 0
mirror of https://git.sr.ht/~rabbits/uxn synced 2024-11-26 15:53:01 +00:00

(console.tal) Improved example

This commit is contained in:
neauoire 2023-12-05 11:55:46 -08:00
parent 94f6627145
commit 14bf95ba39

View file

@ -10,90 +10,86 @@
@on-reset ( -> )
;on-argument .Console/vector DEO2
.Console/type DEI ?{ ;on-stdin .Console/vector DEO2 }
;dict/hello <print-str>
.Console/type DEI ?&has-arg
BRK
&has-arg ( -> )
;dict/queue <print-str>
BRK
@on-argument ( -> )
.Console/type DEI ?&>no-argend
;on-stdin .Console/vector DEO2
BRK &>no-argend
.Console/read DEI .buf skey ?&eval
.Console/read DEI .buf skey ?{ BRK }
<print-type>
;dict/yousent <print-str>
LIT "" #18 DEO
;buf <print-str>/
LIT "" #18 DEO
#0a18 DEO
;buf sclr/ .Console/type DEI #04 NEQ ?{
;dict/argend <print-str>
;on-stdin .Console/vector DEO2 }
BRK
&eval ( -> )
<print-type>
;dict/yousent <print-str>
LIT "" #18 DEO
;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
@on-stdin ( -> )
.Console/read DEI .buf skey ?&eval
BRK
&eval ( -> )
<print-type>
;buf ;dict/quit scmp ?&quit
;dict/yousaid <print-str>
LIT "" #18 DEO
;buf <print-str>
LIT "" #18 DEO
#0a18 DEO
;buf sclr BRK
.Console/read DEI .buf skey ?{ BRK }
;buf ;dict/quit scmp ?&quit
<print-type>
;dict/yousaid <print-str>
LIT "" #18 DEO
;buf <print-str>/
LIT "" #18 DEO
#0a18 DEO
;buf sclr/ BRK
&quit ( buf* -> )
#010f DEO
#800f DEO
BRK
@<print-type> ( -- )
[ LIT2 00 -Console/type ] DEI #01 GTH DUP ADD ;types ADD2 LDA2 !<print-str>
[ LIT2 00 -Console/type ] DEI #01 GTH DUP ADD ;types ADD2
( ) LDA2 !<print-str>/
(
@|stdlib )
@<print-str> ( str* -- )
!&
&while ( -- )
&w ( -- )
LDAk #18 DEO
INC2 & LDAk ?&while
INC2 & LDAk ?&w
POP2 JMP2r
@sclr ( str* -- )
&w ( -- )
STH2k #00 STH2r STA
INC2 & LDAk ?&w
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
OVR #20 LTH ?{
#00 SWP sput #00 JMP2r }
POP2 #01 JMP2r
@scap ( str* -- end* )
!&
&while ( -- )
INC2 & LDAk ?&while
&w ( -- )
INC2 & LDAk ?&w
JMP2r
@sput ( chr str* -- )
scap INC2k #00 ROT ROT STA
STA
scap/ 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
&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
@<phex> ( short* -- )
SWP <phex>/b
&b ( -- )
DUP #04 SFT <phex>/c
&c ( -- )
#0f AND DUP #09 GTH #27 MUL ADD [ LIT "0 ] ADD #18 DEO
JMP2r
(
@|assets )
@ -109,5 +105,4 @@
&arg "(arg) $1
&quit "quit $1
&argend "(argend) 0a $1
&queue "(queue) 0a $1