uxn-utils/cli/checksum/checksum-original.tal

51 lines
1.6 KiB
Tal
Raw Permalink Normal View History

2023-02-06 18:54:12 -05:00
|0100
;data1a hash emit/long #0a18 DEO
;data1b hash emit/long #0a18 DEOk DEO
;data2a hash emit/long #0a18 DEO
;data2b hash emit/long #0a18 DEOk DEO
;data3a hash emit/long #0a18 DEO
;data3b hash emit/long #0a18 DEOk DEO
;data4a hash emit/long #0a18 DEO
;data4b hash emit/long #0a18 DEOk DEO
#010f DEO BRK
( hash function: run two 16-bit LCGs in parallel )
( )
( upper fn: x1=x0*9283+cc ; a is #2443 x0 is #1234 )
( lower fn: y1=y0*4493+cc ; b is #118d y1 is #abcd )
@hash ( s* -> x* y* )
STH2 LIT2 2443 LIT2 1234 ( a* x0* [s*] )
STH2r LIT2r 118d LIT2r abcd ( a* x0* s* [b* y0*] )
&loop ( a* x* s* [b* y*] )
LDAk DUP ?&ok ( a* x* s* c^ [b* y*] )
POP POP2 NIP2 ( x* [b* y*] )
STH2r POP2r JMP2r ( x* y* )
&ok ( a* x* s* c^ [b* y*] )
DUP STH2 STH2 ( a* x* [b* y* cc* s*] )
OVR2 MUL2 OVR2r ( a* ax* [b* y* cc* s* cc*] )
STH2r ADD2 STH2r STH2r ( a* ax+cc* s* cc* [b* y*] )
OVR2r MUL2r STH2 ADD2r ( a* ax+cc* s* [b* by+cc*] )
INC2 !&loop ( a* ax+cc s+1* [b* by+cc*] )
@emit ( n* -> )
&long SWP2 emit/short
&short SWP emit/byte
&byte DUP #04 SFT emit/char
&char #0f AND DUP #09 GTH #27 MUL ADD #30 ADD #18 DEO JMP2r
@data1a "abc 00
@data1b "ebc 00
@data2a "wigjewigjewigjewigjewigjewigjcncmnbegejgiwejgieg 00
@data2b "wigjewigjewigjewigjewigjewigjcmcmnbegejgiwejgieg 00
@data3a "zzjiewgew 00
@data3b "zzjiewge 00
@data4a "this 20 "is 20 "a 20 "test 00
@data4b "this 20 "is 20 "a 20 "test. 00