2023-08-02 11:35:28 -04:00
|
|
|
( usage: uxncli format-js.rom file.bin )
|
2023-08-02 11:29:11 -04:00
|
|
|
|
|
|
|
|10 @Console &vector $2 &read $1 &pad $5 &write $1 &error $1
|
|
|
|
|a0 @File &vector $2 &success $2 &stat $2 &delete $1 &append $1 &name $2 &length $2 &read $2 &write $2
|
|
|
|
|
|
|
|
|0000
|
|
|
|
|
|
|
|
@src $40
|
|
|
|
|
2023-08-02 11:35:28 -04:00
|
|
|
|0100 ( -> )
|
2023-08-02 11:29:11 -04:00
|
|
|
|
|
|
|
;on-console .Console/vector DEO2
|
|
|
|
|
|
|
|
BRK
|
|
|
|
|
|
|
|
@on-console ( -> )
|
|
|
|
|
2023-08-02 11:35:28 -04:00
|
|
|
;src STH2
|
2023-08-02 11:29:11 -04:00
|
|
|
( read input )
|
|
|
|
.Console/read DEI
|
2023-08-02 11:35:28 -04:00
|
|
|
DUP #20 LTH OVR #7f GTH ORA ,&end JCN
|
|
|
|
STH2kr ,slen JSR #003f GTH2 ,&end JCN
|
|
|
|
STH2kr ,scap JSR STA POP2r BRK
|
|
|
|
&end
|
2023-08-02 11:29:11 -04:00
|
|
|
POP
|
2023-08-02 11:35:28 -04:00
|
|
|
STH2r .File/name DEO2
|
2023-08-02 11:29:11 -04:00
|
|
|
#0001 .File/length DEO2
|
2023-08-02 11:35:28 -04:00
|
|
|
;header-txt ;print-str JSR2
|
2023-08-02 11:29:11 -04:00
|
|
|
LIT2r 0000
|
2023-08-02 11:35:28 -04:00
|
|
|
&stream
|
2023-08-02 11:29:11 -04:00
|
|
|
#00 ,&buf STR
|
2023-08-02 11:35:28 -04:00
|
|
|
;&buf
|
|
|
|
DUP2 .File/read DEO2
|
|
|
|
LIT "0 #18 DEO LIT "x #18 DEO
|
|
|
|
LDA ,print/byte JSR LIT ", #18 DEO #2018 DEO
|
2023-08-02 11:29:11 -04:00
|
|
|
INC2r
|
|
|
|
( linebreak )
|
2023-08-02 11:35:28 -04:00
|
|
|
STH2kr #0007 AND2 ORA ,&no-lb JCN
|
2023-08-02 11:29:11 -04:00
|
|
|
#0a18 DEO #0918 DEO
|
|
|
|
&no-lb
|
2023-08-02 11:35:28 -04:00
|
|
|
.File/success DEI2 ORA ,&stream JCN
|
2023-08-02 11:29:11 -04:00
|
|
|
POP2r
|
2023-08-02 11:35:28 -04:00
|
|
|
;footer-txt ;print-str JSR2
|
2023-08-02 11:29:11 -04:00
|
|
|
#0a18 DEO
|
2023-08-02 11:35:28 -04:00
|
|
|
#010f DEO
|
|
|
|
|
|
|
|
BRK
|
|
|
|
&buf $1
|
|
|
|
|
|
|
|
@slen ( str* -- len* )
|
|
|
|
|
|
|
|
DUP2 ,scap JSR SWP2 SUB2
|
|
|
|
|
|
|
|
JMP2r
|
|
|
|
|
|
|
|
@scap ( str* -- end* )
|
|
|
|
|
|
|
|
LDAk #00 NEQ JMP JMP2r
|
|
|
|
&while
|
|
|
|
INC2 LDAk ,&while JCN
|
|
|
|
|
|
|
|
JMP2r
|
|
|
|
|
|
|
|
@print ( short* -- )
|
|
|
|
|
|
|
|
SWP ,&byte JSR
|
|
|
|
&byte ( byte -- ) DUP #04 SFT ,&char JSR
|
|
|
|
&char ( char -- ) #0f AND DUP #09 GTH #27 MUL ADD #30 ADD #18 DEO
|
2023-08-02 11:29:11 -04:00
|
|
|
|
2023-08-02 11:35:28 -04:00
|
|
|
JMP2r
|
2023-08-02 11:29:11 -04:00
|
|
|
|
2023-08-02 11:35:28 -04:00
|
|
|
@print-str ( str* -- )
|
2023-08-02 11:29:11 -04:00
|
|
|
|
2023-08-02 11:35:28 -04:00
|
|
|
&while
|
|
|
|
LDAk #18 DEO
|
|
|
|
INC2 LDAk ,&while JCN
|
|
|
|
POP2
|
2023-08-02 11:29:11 -04:00
|
|
|
|
2023-08-02 11:35:28 -04:00
|
|
|
JMP2r
|
2023-08-02 11:29:11 -04:00
|
|
|
|
2023-08-02 11:35:28 -04:00
|
|
|
@header-txt "const 20 "assembler 20 "= 20 "new 20 "Uint8Array([ 0a 09 00
|
|
|
|
@footer-txt "0x00]) 00
|