(format-c) Cleanup

This commit is contained in:
neauoire 2023-11-30 20:04:09 -08:00
parent 5d380107e4
commit 251c2bf6a0
1 changed files with 51 additions and 43 deletions

View File

@ -7,62 +7,70 @@
@src $40 @src $40
|0100 @on-reset ( -> ) |0100
@on-reset ( -> )
;on-console .Console/vector DEO2 ;on-console .Console/vector DEO2
BRK
BRK
@on-console ( -> ) @on-console ( -> )
.Console/read DEI .src skey ?{ BRK }
[ LIT2r =src ] <print-program>
( read input ) #800f DEO
.Console/read DEI BRK
DUP #20 LTH OVR #7f GTH ORA ?&>end
STH2kr slen #003f GTH2 ?&>end
STH2kr scap STA POP2r BRK
&>end
POP
STH2r <print-program>
#010f DEO
BRK
@<print-program> ( src* -- ) @<print-program> ( src* -- )
;src .File/name DEO2
.File/name DEO2
#0001 .File/length DEO2 #0001 .File/length DEO2
;dict/header pstr ;dict/header <pstr>
LIT2r 0000 [ LIT2r 0000 ]
&stream ( -- ) &stream ( -- )
#00 ,&buf STR ;&buf feof ?&end
;&buf .File/read DEO2 [ LIT2 "0 18 ] DEO
.File/success DEI2 #0000 EQU2 ?&end [ LIT2 "x 18 ] DEO
[ LIT2 "0 18 ] DEO [ LIT2 "x 18 ] DEO [ LIT &buf $1 ] <phex>/b
[ LIT &buf $1 ] phex/b [ LIT2 ", 18 ] DEO
[ LIT2 ", 18 ] DEO #2018 DEO #2018 DEO
INC2r INC2r
( linebreak ) ( lb ) STHkr #0f AND ?{
STH2kr #000f AND2 ORA ?&no-lb #0a18 DEO
#0a18 DEO #0918 DEO #0918 DEO }
&no-lb !&stream
.File/success DEI2 ORA ?&stream &end POP2r #0a18 DEO
&end ;dict/footer !<pstr>
POP2r
#0a18 DEO
;dict/footer
!pstr
( (
@|stdlib ) @|stdlib )
@slen ( str* -- len* ) DUP2 scap SWP2 SUB2 JMP2r @skey ( key buf -- proc )
@scap ( str* -- end* ) LDAk #00 NEQ [ JMP JMP2r ] &w INC2 LDAk ?&w JMP2r OVR #21 LTH ?{
@phex ( short* -- ) SWP phex/b &b DUP #04 SFT phex/c &c #0f AND DUP #09 GTH #27 MUL ADD #30 ADD #18 DEO JMP2r #00 SWP scap/ STA
@pstr ( str* -- ) &while LDAk #18 DEO INC2 LDAk ?&while POP2 JMP2r #00 JMP2r }
POP2 #01 JMP2r
@dict @scap ( str* -- end* )
&header "unsigned 20 "char 20 "rom[] 20 "= 20 "{ 0a 09 $1 &w ( -- )
INC2 & LDAk ?&w
JMP2r
@feof ( buf* -- f )
.File/read DEO2
.File/success DEI2 #0000 EQU2 JMP2r
@<phex> ( short* -- )
SWP <phex>/b
&b ( -- )
DUP #04 SFT <phex>/c
&c ( -- )
#0f AND DUP #09 GTH #27 MUL ADD #30 ADD #18 DEO
JMP2r
@<pstr> ( str* -- )
&w ( -- )
LDAk #18 DEO
INC2 & LDAk ?&w
POP2 JMP2r
@dict &header "unsigned 20 "char 20 "rom[] 20 "= 20 "{ 0a 09 $1
&footer "}; 0a 00 &footer "}; 0a 00