Modernized format-js
This commit is contained in:
parent
f541b11aa7
commit
6303e2cb9a
|
@ -7,76 +7,65 @@
|
||||||
|
|
||||||
@src $40
|
@src $40
|
||||||
|
|
||||||
|0100 ( -> )
|
|0100
|
||||||
|
|
||||||
|
@on-reset ( -> )
|
||||||
;on-console .Console/vector DEO2
|
;on-console .Console/vector DEO2
|
||||||
|
|
||||||
BRK
|
BRK
|
||||||
|
|
||||||
@on-console ( -> )
|
@on-console ( -> )
|
||||||
|
|
||||||
;src STH2
|
;src STH2
|
||||||
( read input )
|
( | read input )
|
||||||
.Console/read DEI
|
.Console/read DEI DUP #20 LTH OVR #7f GTH ORA ?&end
|
||||||
DUP #20 LTH OVR #7f GTH ORA ,&end JCN
|
STH2kr slen #003f GTH2 ?&end
|
||||||
STH2kr ,slen JSR #003f GTH2 ,&end JCN
|
STH2kr scap/ STA
|
||||||
STH2kr ,scap JSR STA POP2r BRK
|
POP2r BRK
|
||||||
&end
|
&end ( c -- )
|
||||||
POP
|
POP STH2r .File/name DEO2
|
||||||
STH2r .File/name DEO2
|
|
||||||
#0001 .File/length DEO2
|
#0001 .File/length DEO2
|
||||||
;header-txt ;print-str JSR2
|
;header-txt <pstr>
|
||||||
LIT2r 0000
|
LIT2r 0000
|
||||||
&stream
|
&stream ( -- )
|
||||||
#00 ,&buf STR
|
#00 ,&buf STR
|
||||||
;&buf
|
;&buf DUP2 .File/read DEO2
|
||||||
DUP2 .File/read DEO2
|
LIT "0 #18 DEO
|
||||||
LIT "0 #18 DEO LIT "x #18 DEO
|
LIT "x #18 DEO
|
||||||
LDA ,print/byte JSR LIT ", #18 DEO #2018 DEO
|
LDA <phex>/byte
|
||||||
|
LIT ", #18 DEO
|
||||||
|
#2018 DEO
|
||||||
INC2r
|
INC2r
|
||||||
( linebreak )
|
( linebreak ) STH2kr #0007 AND2 ORA ?{
|
||||||
STH2kr #0007 AND2 ORA ,&no-lb JCN
|
#0a18 DEO
|
||||||
#0a18 DEO #0918 DEO
|
#0918 DEO }
|
||||||
&no-lb
|
.File/success DEI2 ORA ?&stream
|
||||||
.File/success DEI2 ORA ,&stream JCN
|
POP2r ;footer-txt <pstr>
|
||||||
POP2r
|
|
||||||
;footer-txt ;print-str JSR2
|
|
||||||
#0a18 DEO
|
#0a18 DEO
|
||||||
#010f DEO
|
#010f DEO
|
||||||
|
BRK &buf $1
|
||||||
BRK
|
|
||||||
&buf $1
|
|
||||||
|
|
||||||
@slen ( str* -- len* )
|
@slen ( str* -- len* )
|
||||||
|
DUP2 scap/ SWP2 SUB2 JMP2r
|
||||||
DUP2 ,scap JSR SWP2 SUB2
|
|
||||||
|
|
||||||
JMP2r
|
|
||||||
|
|
||||||
@scap ( str* -- end* )
|
@scap ( str* -- end* )
|
||||||
|
INC2 & LDAk ?scap
|
||||||
LDAk #00 NEQ JMP JMP2r
|
|
||||||
&while
|
|
||||||
INC2 LDAk ,&while JCN
|
|
||||||
|
|
||||||
JMP2r
|
JMP2r
|
||||||
|
|
||||||
@print ( short* -- )
|
@<phex> ( short* -- )
|
||||||
|
SWP <phex>/byte
|
||||||
SWP ,&byte JSR
|
&byte ( byte -- )
|
||||||
&byte ( byte -- ) DUP #04 SFT ,&char JSR
|
DUP #04 SFT <phex>/char
|
||||||
&char ( char -- ) #0f AND DUP #09 GTH #27 MUL ADD #30 ADD #18 DEO
|
&char ( char -- )
|
||||||
|
#0f AND DUP #09 GTH #27 MUL ADD #30 ADD #18 DEO
|
||||||
JMP2r
|
JMP2r
|
||||||
|
|
||||||
@print-str ( str* -- )
|
@<pstr> ( str* -- )
|
||||||
|
LDAk DUP ?{ POP2 JMP2r }
|
||||||
|
#18 DEO
|
||||||
|
INC2 !<pstr>
|
||||||
|
|
||||||
&while
|
@header-txt
|
||||||
LDAk #18 DEO
|
"const 20 "assembler 20 "= 20 "new 20 "Uint8Array([ 0a 09 00
|
||||||
INC2 LDAk ,&while JCN
|
|
||||||
POP2
|
|
||||||
|
|
||||||
JMP2r
|
@footer-txt
|
||||||
|
"0x00]) 00
|
||||||
|
|
||||||
@header-txt "const 20 "assembler 20 "= 20 "new 20 "Uint8Array([ 0a 09 00
|
|
||||||
@footer-txt "0x00]) 00
|
|
||||||
|
|
Loading…
Reference in New Issue