uxn-utils/cli/checksum/checksum.tal

91 lines
1.5 KiB
Tal
Raw Normal View History

2023-03-18 00:24:26 -04:00
( uxncli checksum.rom file.bin )
2023-02-06 18:54:12 -05:00
2023-06-04 11:02:11 -04:00
|10 @Console &vector $2 &read $1 &pad $4 &type $1 &write $1 &error $1
2023-02-06 18:54:12 -05:00
|a0 @File &vector $2 &success $2 &stat $2 &delete $1 &append $1 &name $2 &length $2 &read $2 &write $2
|0000
@src $40
2023-06-20 00:28:40 -04:00
|0100
2023-06-04 11:02:11 -04:00
2023-06-20 00:28:40 -04:00
@on-reset ( -> )
.Console/type DEI ?&>has-arg
;dict/usage <perr>
#010f DEO
BRK &>has-arg
2023-02-06 18:54:12 -05:00
;await-src .Console/vector DEO2
2023-06-20 00:28:40 -04:00
BRK
2023-02-06 18:54:12 -05:00
@await-src ( -> )
2023-06-20 00:28:40 -04:00
.Console/read DEI .src skey ?on-ready
BRK
2023-02-06 18:54:12 -05:00
@on-ready ( -> )
2023-06-20 00:28:40 -04:00
;src DUP2 hash <emit-long>
#2018 DEO
<pstr>
#0a18 DEO
2023-06-04 11:02:11 -04:00
#800f DEO
2023-06-20 00:28:40 -04:00
BRK
2023-02-06 18:54:12 -05:00
2023-03-17 13:13:40 -04:00
(
@|core )
2023-02-06 18:54:12 -05:00
@hash ( filename* -- x* y* )
.File/name DEO2
#0001 .File/length DEO2
2023-06-20 00:28:40 -04:00
#1234 ,&x STR2
#abcd ,&y STR2
#2443 ,&a STR2
#118d ,&b STR2
&w ( -- )
2023-02-06 18:54:12 -05:00
;&c .File/read DEO2
2023-06-20 00:28:40 -04:00
[ LIT &c $1 ] DUP DUP2 [ LIT2 &x $2 ] [ LIT2 &a $2 ] MUL2 ADD2 ,&x STR2
2023-02-06 18:54:12 -05:00
[ LIT2 &y $2 ] [ LIT2 &b $2 ] MUL2 ADD2 ,&y STR2
2023-02-06 18:59:17 -05:00
.File/success DEI2 ORA ?&w
2023-06-20 00:28:40 -04:00
,&x LDR2 ,&y LDR2 JMP2r
2023-02-06 18:54:12 -05:00
2023-03-17 13:13:40 -04:00
(
@|stdlib )
2023-02-06 18:54:12 -05:00
@scap ( str* -- end* )
2023-06-20 00:28:40 -04:00
!&a
&w ( -- )
INC2 &a LDAk ?&w
JMP2r
2023-02-06 18:54:12 -05:00
@sput ( chr str* -- )
2023-06-20 00:28:40 -04:00
scap ROT #00 SWP2 STA2
JMP2r
2023-02-06 18:54:12 -05:00
@skey ( key buf -- proc )
2023-06-20 00:28:40 -04:00
OVR #21 LTH ?&eval
#00 SWP sput #00 JMP2r
&eval POP2 #01 JMP2r
@<pstr> ( str* -- )
&w ( -- )
LDAk #18 DEO
INC2 LDAk ?&w
POP2 JMP2r
@<perr> ( str* -- )
&w ( -- )
LDAk #19 DEO
INC2 LDAk ?&w
POP2 JMP2r
@<emit-long> ( a* b* -> )
SWP2 <emit-long>/s
&s ( -- )
SWP <emit-long>/b
&b ( -- )
DUP #04 SFT <emit-long>/c
&c ( -- )
#0f AND DUP #09 GTH #27 MUL ADD #30 ADD #18 DEO
JMP2r
@dict &usage "usage: 20 "checksum.rom 20 "input.bin 0a $1
2023-02-06 18:54:12 -05:00