( usage: uxncli format-js.rom file.bin ) |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 |0100 @on-reset ( -> ) ;on-console .Console/vector DEO2 BRK @on-console ( -> ) ;src STH2 ( | read input ) .Console/read DEI DUP #20 LTH OVR #7f GTH ORA ?&end STH2kr slen #003f GTH2 ?&end STH2kr scap/ STA POP2r BRK &end ( c -- ) POP STH2r .File/name DEO2 #0001 .File/length DEO2 ;header-txt LIT2r 0000 &stream ( -- ) #00 ,&buf STR ;&buf DUP2 .File/read DEO2 LIT "0 #18 DEO LIT "x #18 DEO LDA /byte LIT ", #18 DEO #2018 DEO INC2r ( linebreak ) STH2kr #0007 AND2 ORA ?{ #0a18 DEO #0918 DEO } .File/success DEI2 ORA ?&stream POP2r ;footer-txt #0a18 DEO #010f DEO BRK &buf $1 @slen ( str* -- len* ) DUP2 scap/ SWP2 SUB2 JMP2r @scap ( str* -- end* ) INC2 & LDAk ?scap JMP2r @ ( short* -- ) SWP /byte &byte ( byte -- ) DUP #04 SFT /char &char ( char -- ) #0f AND DUP #09 GTH #27 MUL ADD #30 ADD #18 DEO JMP2r @ ( str* -- ) LDAk DUP ?{ POP2 JMP2r } #18 DEO INC2 ! @header-txt "const 20 "assembler 20 "= 20 "new 20 "Uint8Array([ 0a 09 00 @footer-txt "0x00]) 00