This commit is contained in:
~d6 2023-02-06 10:28:44 -05:00
parent aba92a6f67
commit 3d4c79c934
5 changed files with 771 additions and 0 deletions

View File

@ -10,3 +10,5 @@ etc
test-roms test-roms
junk junk
screenshots screenshots
.theme
.snarf

35
hash.c Normal file
View File

@ -0,0 +1,35 @@
#include <stdint.h>
#include <stdio.h>
uint32_t hash(uint8_t *input) {
uint16_t x = 0x1234;
uint16_t y = 0xabcd;
uint16_t a = 0x2443;
uint16_t b = 0x118d;
uint8_t c;
uint16_t cc;
while (c = *input) {
cc = (c << 8) | c;
x = (x * a) + cc;
y = (y * b) + cc;
input++;
}
return (x << 16) | y;
}
int main(int argc, char **argv) {
printf("data1a %08x\n", hash("abc"));
printf("data1b %08x\n", hash("ebc"));
printf("\n");
printf("data2a %08x\n", hash("wigjewigjewigjewigjewigjewigjcncmnbegejgiwejgieg"));
printf("data2b %08x\n", hash("wigjewigjewigjewigjewigjewigjcmcmnbegejgiwejgieg"));
printf("\n");
printf("data3a %08x\n", hash("zzjiewgew"));
printf("data3b %08x\n", hash("zzjiewge"));
printf("\n");
printf("data4a %08x\n", hash("this is a test"));
printf("data4b %08x\n", hash("this is a test."));
return 0;
}

50
hash.tal Normal file
View File

@ -0,0 +1,50 @@
|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

512
terminal12.tal Normal file
View File

@ -0,0 +1,512 @@
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
00 7e c3 81 a5 81 bd 99 c3 7e 00 00 00 00 00 00
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
00 7e ff ff db ff c3 e7 ff 7e 00 00 00 00 00 00
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
00 00 44 ee fe fe fe 7c 38 10 00 00 00 00 00 00
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
00 10 38 7c fe fe 7c 38 10 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
00 18 3c 3c ff e7 e7 18 18 7e 00 00 00 00 00 00
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
00 18 3c 7e ff ff 7e 18 18 7e 00 00 00 00 00 00
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
00 00 00 00 3c 7e 7e 3c 00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
ff ff ff ff c3 81 81 c3 ff ff ff ff 00 00 00 00
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
00 00 3c 7e 66 42 42 66 7e 3c 00 00 00 00 00 00
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
ff ff c3 81 99 bd bd 99 81 c3 ff ff 00 00 00 00
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
00 3e 0e 3a 72 f8 cc cc cc 78 00 00 00 00 00 00
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
00 3c 66 66 66 3c 18 7e 18 18 00 00 00 00 00 00
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
00 1f 19 19 1f 18 18 78 f8 70 00 00 00 00 00 00
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
00 7f 63 7f 63 63 63 67 e7 e6 c0 00 00 00 00 00
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
00 00 18 db 7e e7 e7 7e db 18 00 00 00 00 00 00
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
00 80 c0 e0 f8 fe f8 e0 c0 80 00 00 00 00 00 00
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
00 02 06 0e 3e fe 3e 0e 06 02 00 00 00 00 00 00
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
00 18 3c 7e 18 18 18 7e 3c 18 00 00 00 00 00 00
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
00 66 66 66 66 66 00 00 66 66 00 00 00 00 00 00
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
00 7f db db db 7b 1b 1b 1b 1b 00 00 00 00 00 00
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
00 7e 63 30 3c 66 66 3c 0c c6 7e 00 00 00 00 00
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 fe fe fe 00 00 00 00 00 00
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
00 18 3c 7e 18 18 18 7e 3c 18 7e 00 00 00 00 00
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
00 18 3c 7e 18 18 18 18 18 18 00 00 00 00 00 00
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
00 18 18 18 18 18 18 7e 3c 18 00 00 00 00 00 00
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
00 00 00 18 0c fe 0c 18 00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
00 00 00 30 60 fe 60 30 00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
00 00 00 00 c0 c0 c0 fe 00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
00 00 00 24 66 ff 66 24 00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
00 00 10 10 38 38 7c 7c fe fe 00 00 00 00 00 00
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
00 00 fe fe 7c 7c 38 38 10 10 00 00 00 00 00 00
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
00 30 78 78 78 30 30 00 30 30 00 00 00 00 00 00
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
00 66 66 66 24 00 00 00 00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
00 6c 6c fe 6c 6c 6c fe 6c 6c 00 00 00 00 00 00
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
30 30 7c c0 c0 78 0c 0c f8 30 30 00 00 00 00 00
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
00 00 00 c4 cc 18 30 60 cc 8c 00 00 00 00 00 00
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
00 70 d8 d8 70 fa de cc dc 76 00 00 00 00 00 00
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
00 30 30 30 60 00 00 00 00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
00 0c 18 30 60 60 60 30 18 0c 00 00 00 00 00 00
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
00 60 30 18 0c 0c 0c 18 30 60 00 00 00 00 00 00
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
00 00 00 66 3c ff 3c 66 00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
00 00 00 18 18 7e 18 18 00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00 38 38 60 00 00 00 00 00
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
00 00 00 00 00 fe 00 00 00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00 38 38 00 00 00 00 00 00
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
00 00 02 06 0c 18 30 60 c0 80 00 00 00 00 00 00
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
00 7c c6 ce de d6 f6 e6 c6 7c 00 00 00 00 00 00
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
00 10 30 f0 30 30 30 30 30 fc 00 00 00 00 00 00
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
00 78 cc cc 0c 18 30 60 cc fc 00 00 00 00 00 00
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
00 78 cc 0c 0c 38 0c 0c cc 78 00 00 00 00 00 00
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
00 0c 1c 3c 6c cc fe 0c 0c 1e 00 00 00 00 00 00
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
00 fc c0 c0 c0 f8 0c 0c cc 78 00 00 00 00 00 00
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
00 38 60 c0 c0 f8 cc cc cc 78 00 00 00 00 00 00
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
00 fe c6 c6 06 0c 18 30 30 30 00 00 00 00 00 00
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
00 78 cc cc cc 78 cc cc cc 78 00 00 00 00 00 00
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
00 78 cc cc cc 7c 18 18 30 70 00 00 00 00 00 00
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
00 00 00 38 38 00 00 38 38 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
00 00 00 38 38 00 00 38 38 18 30 00 00 00 00 00
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
00 0c 18 30 60 c0 60 30 18 0c 00 00 00 00 00 00
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
00 00 00 00 7e 00 7e 00 00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
00 60 30 18 0c 06 0c 18 30 60 00 00 00 00 00 00
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
00 78 cc 0c 18 30 30 00 30 30 00 00 00 00 00 00
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
00 7c c6 c6 de de de c0 c0 7c 00 00 00 00 00 00
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
00 30 78 cc cc cc fc cc cc cc 00 00 00 00 00 00
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
00 fc 66 66 66 7c 66 66 66 fc 00 00 00 00 00 00
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
00 3c 66 c6 c0 c0 c0 c6 66 3c 00 00 00 00 00 00
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
00 f8 6c 66 66 66 66 66 6c f8 00 00 00 00 00 00
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
00 fe 62 60 64 7c 64 60 62 fe 00 00 00 00 00 00
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
00 fe 66 62 64 7c 64 60 60 f0 00 00 00 00 00 00
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
00 3c 66 c6 c0 c0 ce c6 66 3e 00 00 00 00 00 00
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
00 cc cc cc cc fc cc cc cc cc 00 00 00 00 00 00
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
00 78 30 30 30 30 30 30 30 78 00 00 00 00 00 00
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
00 1e 0c 0c 0c 0c cc cc cc 78 00 00 00 00 00 00
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
00 e6 66 6c 6c 78 6c 6c 66 e6 00 00 00 00 00 00
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
00 f0 60 60 60 60 62 66 66 fe 00 00 00 00 00 00
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
00 c6 ee fe fe d6 c6 c6 c6 c6 00 00 00 00 00 00
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
00 c6 c6 e6 f6 fe de ce c6 c6 00 00 00 00 00 00
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
00 38 6c c6 c6 c6 c6 c6 6c 38 00 00 00 00 00 00
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
00 fc 66 66 66 7c 60 60 60 f0 00 00 00 00 00 00
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
00 38 6c c6 c6 c6 ce de 7c 0c 1e 00 00 00 00 00
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
00 fc 66 66 66 7c 6c 66 66 e6 00 00 00 00 00 00
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
00 78 cc cc c0 70 18 cc cc 78 00 00 00 00 00 00
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
00 fc b4 30 30 30 30 30 30 78 00 00 00 00 00 00
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
00 cc cc cc cc cc cc cc cc 78 00 00 00 00 00 00
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
00 cc cc cc cc cc cc cc 78 30 00 00 00 00 00 00
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
00 c6 c6 c6 c6 d6 d6 6c 6c 6c 00 00 00 00 00 00
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
00 cc cc cc 78 30 78 cc cc cc 00 00 00 00 00 00
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
00 cc cc cc cc 78 30 30 30 78 00 00 00 00 00 00
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
00 fe ce 98 18 30 60 62 c6 fe 00 00 00 00 00 00
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
00 3c 30 30 30 30 30 30 30 3c 00 00 00 00 00 00
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
00 00 80 c0 60 30 18 0c 06 02 00 00 00 00 00 00
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
00 3c 0c 0c 0c 0c 0c 0c 0c 3c 00 00 00 00 00 00
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
10 38 6c c6 00 00 00 00 00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00 00 00 ff 00 00 00 00 00
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
30 30 18 00 00 00 00 00 00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
00 00 00 00 78 0c 7c cc cc 76 00 00 00 00 00 00
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
00 e0 60 60 7c 66 66 66 66 dc 00 00 00 00 00 00
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
00 00 00 00 78 cc c0 c0 cc 78 00 00 00 00 00 00
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
00 1c 0c 0c 7c cc cc cc cc 76 00 00 00 00 00 00
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
00 00 00 00 78 cc fc c0 cc 78 00 00 00 00 00 00
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
00 38 6c 60 60 f8 60 60 60 f0 00 00 00 00 00 00
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
00 00 00 00 76 cc cc cc 7c 0c cc 78 00 00 00 00
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
00 e0 60 60 6c 76 66 66 66 e6 00 00 00 00 00 00
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
00 18 18 00 78 18 18 18 18 7e 00 00 00 00 00 00
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
00 0c 0c 00 3c 0c 0c 0c 0c cc cc 78 00 00 00 00
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
00 e0 60 60 66 6c 78 6c 66 e6 00 00 00 00 00 00
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
00 78 18 18 18 18 18 18 18 7e 00 00 00 00 00 00
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
00 00 00 00 fc d6 d6 d6 d6 c6 00 00 00 00 00 00
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
00 00 00 00 f8 cc cc cc cc cc 00 00 00 00 00 00
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
00 00 00 00 78 cc cc cc cc 78 00 00 00 00 00 00
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
00 00 00 00 dc 66 66 66 66 7c 60 f0 00 00 00 00
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
00 00 00 00 76 cc cc cc cc 7c 0c 1e 00 00 00 00
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
00 00 00 00 ec 6e 76 60 60 f0 00 00 00 00 00 00
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
00 00 00 00 78 cc 60 18 cc 78 00 00 00 00 00 00
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
00 00 20 60 fc 60 60 60 6c 38 00 00 00 00 00 00
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
00 00 00 00 cc cc cc cc cc 76 00 00 00 00 00 00
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
00 00 00 00 cc cc cc cc 78 30 00 00 00 00 00 00
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
00 00 00 00 c6 c6 d6 d6 6c 6c 00 00 00 00 00 00
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
00 00 00 00 c6 6c 38 38 6c c6 00 00 00 00 00 00
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
00 00 00 00 66 66 66 66 3c 0c 18 f0 00 00 00 00
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
00 00 00 00 fc 8c 18 60 c4 fc 00 00 00 00 00 00
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
00 1c 30 30 60 c0 60 30 30 1c 00 00 00 00 00 00
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
00 18 18 18 18 00 18 18 18 18 00 00 00 00 00 00
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
00 e0 30 30 18 0c 18 30 30 e0 00 00 00 00 00 00
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
00 73 da ce 00 00 00 00 00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
00 00 00 10 38 6c c6 c6 fe 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
00 78 cc cc c0 c0 c0 cc cc 78 30 60 00 00 00 00
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
00 cc cc 00 cc cc cc cc cc 76 00 00 00 00 00 00
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
0c 18 30 00 78 cc fc c0 cc 78 00 00 00 00 00 00
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
30 78 cc 00 78 0c 7c cc cc 76 00 00 00 00 00 00
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
00 cc cc 00 78 0c 7c cc cc 76 00 00 00 00 00 00
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
c0 60 30 00 78 0c 7c cc cc 76 00 00 00 00 00 00
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
38 6c 6c 38 f8 0c 7c cc cc 76 00 00 00 00 00 00
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
00 00 00 00 78 cc c0 c0 cc 78 30 60 00 00 00 00
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
30 78 cc 00 78 cc fc c0 c0 7c 00 00 00 00 00 00
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
00 cc cc 00 78 cc fc c0 c0 7c 00 00 00 00 00 00
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
c0 60 30 00 78 cc fc c0 c0 7c 00 00 00 00 00 00
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
00 6c 6c 00 78 18 18 18 18 7e 00 00 00 00 00 00
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
10 38 6c 00 78 18 18 18 18 7e 00 00 00 00 00 00
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
60 30 18 00 78 18 18 18 18 7e 00 00 00 00 00 00
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
00 cc 00 30 78 cc cc fc cc cc 00 00 00 00 00 00
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
78 cc cc 78 78 cc cc fc cc cc 00 00 00 00 00 00
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
0c 18 00 fc c4 c0 f8 c0 c4 fc 00 00 00 00 00 00
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
00 00 00 00 fe 1b 7f d8 d8 ef 00 00 00 00 00 00
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
00 3e 78 d8 d8 fe d8 d8 d8 de 00 00 00 00 00 00
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
30 78 cc 00 78 cc cc cc cc 78 00 00 00 00 00 00
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
00 cc cc 00 78 cc cc cc cc 78 00 00 00 00 00 00
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
c0 60 30 00 78 cc cc cc cc 78 00 00 00 00 00 00
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
30 78 cc 00 cc cc cc cc cc 76 00 00 00 00 00 00
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
c0 60 30 00 cc cc cc cc cc 76 00 00 00 00 00 00
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
00 66 66 00 66 66 66 66 3c 0c 18 f0 00 00 00 00
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
00 cc 00 78 cc cc cc cc cc 78 00 00 00 00 00 00
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
cc 00 cc cc cc cc cc cc cc 78 00 00 00 00 00 00
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
00 00 00 00 78 cc dc ec cc 78 00 00 00 00 00 00
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
3c 66 60 60 60 fc 60 60 c0 fe 00 00 00 00 00 00
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
00 3a 6c ce d6 d6 d6 e6 6c b8 00 00 00 00 00 00
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
00 00 00 00 00 c6 6c 38 6c c6 00 00 00 00 00 00
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
0e 1b 18 18 7e 18 18 18 d8 70 00 00 00 00 00 00
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
0c 18 30 00 78 0c 7c cc cc 76 00 00 00 00 00 00
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
0c 18 30 00 78 18 18 18 18 7e 00 00 00 00 00 00
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
0c 18 30 00 78 cc cc cc cc 78 00 00 00 00 00 00
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
0c 18 30 00 cc cc cc cc cc 76 00 00 00 00 00 00
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
00 76 dc 00 f8 cc cc cc cc cc 00 00 00 00 00 00
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
76 dc 00 c6 e6 f6 de ce c6 c6 00 00 00 00 00 00
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
00 78 cc cc 7e 00 fe 00 00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
00 78 cc cc 78 00 fe 00 00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
00 30 30 00 30 60 c0 c0 cc 78 00 00 00 00 00 00
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
00 38 44 ba aa ba b2 aa 44 38 00 00 00 00 00 00
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
00 00 00 00 00 fc 0c 0c 0c 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
00 62 e6 6c 78 30 6e c3 86 0c 1f 00 00 00 00 00
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
00 63 e6 6c 78 37 6f db b3 3f 03 00 00 00 00 00
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
00 30 30 00 30 30 78 78 78 30 00 00 00 00 00 00
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
00 00 00 00 33 66 cc cc 66 33 00 00 00 00 00 00
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
00 00 00 00 cc 66 33 33 66 cc 00 00 00 00 00 00
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
24 92 49 24 92 49 24 92 49 24 92 49 00 00 00 00
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
55 aa 55 aa 55 aa 55 aa 55 aa 55 aa 00 00 00 00
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
6d db b6 6d db b6 6d db b6 6d db b6 00 00 00 00
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
18 18 18 18 18 18 18 18 18 18 18 18 00 00 00 00
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
18 18 18 18 18 f8 18 18 18 18 18 18 00 00 00 00
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
0c 18 00 30 78 cc cc fc cc cc 00 00 00 00 00 00
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
78 cc 00 30 78 cc cc fc cc cc 00 00 00 00 00 00
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
60 30 00 30 78 cc cc fc cc cc 00 00 00 00 00 00
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
00 38 44 ba a2 a2 a2 ba 44 38 00 00 00 00 00 00
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
66 66 66 66 e6 06 06 e6 66 66 66 66 00 00 00 00
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
66 66 66 66 66 66 66 66 66 66 66 66 00 00 00 00
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
00 00 00 00 fe 06 06 e6 66 66 66 66 00 00 00 00
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
66 66 66 66 e6 06 06 fe 00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
00 30 30 78 cc c0 c0 cc 78 30 30 00 00 00 00 00
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
cc cc cc cc 78 fc 30 fc 30 30 00 00 00 00 00 00
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
00 00 00 00 00 f8 18 18 18 18 18 18 00 00 00 00
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
18 18 18 18 18 1f 00 00 00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
18 18 18 18 18 ff 00 00 00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
00 00 00 00 00 ff 18 18 18 18 18 18 00 00 00 00
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
18 18 18 18 18 1f 18 18 18 18 18 18 00 00 00 00
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
00 00 00 00 00 ff 00 00 00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
18 18 18 18 18 ff 18 18 18 18 18 18 00 00 00 00
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
00 76 dc 00 78 0c 7c cc cc 76 00 00 00 00 00 00
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
76 dc 00 30 78 cc cc fc cc cc 00 00 00 00 00 00
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
66 66 66 66 67 60 60 7f 00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
00 00 00 00 7f 60 60 67 66 66 66 66 00 00 00 00
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
66 66 66 66 e7 00 00 ff 00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
00 00 00 00 ff 00 00 e7 66 66 66 66 00 00 00 00
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
66 66 66 66 67 60 60 67 66 66 66 66 00 00 00 00
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
00 00 00 00 ff 00 00 ff 00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
66 66 66 66 e7 00 00 e7 66 66 66 66 00 00 00 00
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
00 00 00 00 00 c6 7c 6c 7c c6 00 00 00 00 00 00
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
cc 30 d8 0c 06 7e c6 c6 c6 7c 00 00 00 00 00 00
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
00 f8 6c 66 66 f6 66 66 6c f8 00 00 00 00 00 00
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
78 cc 00 fc c4 c0 f8 c0 c4 fc 00 00 00 00 00 00
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
00 cc 00 fc c4 c0 f8 c0 c4 fc 00 00 00 00 00 00
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
60 30 00 fc c4 c0 f8 c0 c4 fc 00 00 00 00 00 00
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
00 f0 30 30 30 fc 00 00 00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
18 30 00 78 30 30 30 30 30 78 00 00 00 00 00 00
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
78 cc 00 78 30 30 30 30 30 78 00 00 00 00 00 00
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
00 cc 00 78 30 30 30 30 30 78 00 00 00 00 00 00
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
18 18 18 18 18 f8 00 00 00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
00 00 00 00 00 1f 18 18 18 18 18 18 00 00 00 00
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
ff ff ff ff ff ff ff ff ff ff ff ff 00 00 00 00
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
00 00 00 00 00 00 ff ff ff ff ff ff 00 00 00 00
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
00 18 18 18 18 00 18 18 18 18 00 00 00 00 00 00
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
60 30 00 78 30 30 30 30 30 78 00 00 00 00 00 00
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
ff ff ff ff ff ff 00 00 00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
18 30 00 78 cc cc cc cc cc 78 00 00 00 00 00 00
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
00 78 cc cc d8 cc cc cc f8 c0 60 00 00 00 00 00
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
78 cc 00 78 cc cc cc cc cc 78 00 00 00 00 00 00
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
60 30 00 78 cc cc cc cc cc 78 00 00 00 00 00 00
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
00 76 dc 00 78 cc cc cc cc 78 00 00 00 00 00 00
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
76 dc 00 78 cc cc cc cc cc 78 00 00 00 00 00 00
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
00 00 00 00 66 66 66 66 66 7b 60 c0 00 00 00 00
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
00 00 e0 60 7c 66 66 7c 60 f0 00 00 00 00 00 00
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
00 f0 60 7c 66 66 66 7c 60 f0 00 00 00 00 00 00
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
18 30 00 cc cc cc cc cc cc 78 00 00 00 00 00 00
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
78 cc 00 cc cc cc cc cc cc 78 00 00 00 00 00 00
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
60 30 00 cc cc cc cc cc cc 78 00 00 00 00 00 00
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
06 0c 18 00 66 66 66 66 3c 0c 18 f0 00 00 00 00
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
18 30 00 cc cc cc 78 30 30 78 00 00 00 00 00 00
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
00 fc 00 00 00 00 00 00 00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
0c 18 30 00 00 00 00 00 00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
00 00 00 00 00 fc 00 00 00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
00 00 30 30 fc 30 30 00 fc 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
00 00 00 00 00 f8 00 00 f8 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
e0 33 66 3c f8 37 6f db b3 3f 03 00 00 00 00 00
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
00 7f db db db 7b 1b 1b 1b 1b 00 00 00 00 00 00
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
00 7e 63 30 3c 66 66 3c 0c c6 7e 00 00 00 00 00
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
00 00 30 30 00 fc 00 30 30 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00 00 00 30 70 00 00 00 00
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
00 3c 66 66 66 3c 00 00 00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
00 cc 00 00 00 00 00 00 00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
00 00 00 00 00 18 00 00 00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
00 30 70 30 30 78 00 00 00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
00 78 0c 38 0c 78 00 00 00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
00 78 0c 18 30 7c 00 00 00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
00 00 00 fc fc fc fc fc fc 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00

172
testing.tal Normal file
View File

@ -0,0 +1,172 @@
( testing.tal )
( )
( testing uxntal words based on input/output bytes. )
( )
( this harness works best testing words that are "pure" )
( in the sense that they read from the data stack and )
( write results back onto the data stack. words which )
( manipulate the return stack or read/write from devices )
( may require something else. )
( )
( the model is as follows: )
( )
( - each test case is a line of text ending in a newline )
( - lines starts with a character that selects a test )
( - after that, 0 or more hexadecimal bytes are provided )
( - the test runs )
( - result is 0 or more hexadecimal bytes (or an error) )
( - an empty line ends the test )
( )
( for example, the input "+12345678\n" would run a test )
( selected by "+" with 4 input bytes on the stack: )
( )
( wst: 12 34 56 78 )
( )
( each case should be added to @interact, along with the )
( number of bytes it expects to read and write. )
( program )
|0100 ;interact #10 DEO2 BRK
( include the code being tested )
~math32.tal
( testing )
@buf $33 ( line buffer, not including trailing newline )
@pos $2 ( next position in buffer to write to )
( save character input and execute tests )
( )
( tests always start with a single character then )
( additional arguments are passed as bytes before )
( a terminating newline. )
( )
( the last byte read will be on the top of the stack )
( and the earliest on the bottom. )
@interact
#12 DEI ( read c )
DUP #0a EQU ,&exec JCN ( exec if c is a newline )
;pos LDA2 ;buf ADD2 STA ( else write c to buf+pos )
;pos LDA2k INC2 SWP2 STA2 BRK ( increment pos )
&exec POP ( )
;pos LDA2 #0000 EQU2 ;exit JCN2 ( exit on an empty line )
;buf LDA LIT "+ EQU ;test-add32 JCN2
;buf LDA LIT "* EQU ;test-mul32 JCN2
;buf LDA LIT "- EQU ;test-sub32 JCN2
;buf LDA LIT "/ EQU ;test-div32 JCN2
;buf LDA LIT "% EQU ;test-mod32 JCN2
;buf LDA LIT "G EQU ;test-gcd32 JCN2
;buf LDA LIT "L EQU ;test-lshift32 JCN2
;buf LDA LIT "R EQU ;test-rshift32 JCN2
;buf LDA LIT "B EQU ;test-bitcount32 JCN2
;buf LDA LIT "& EQU ;test-and32 JCN2
;buf LDA LIT "| EQU ;test-or32 JCN2
;buf LDA LIT "^ EQU ;test-xor32 JCN2
;buf LDA LIT "~ EQU ;test-complement32 JCN2
;buf LDA LIT "N EQU ;test-negate32 JCN2
;buf LDA LIT "= EQU ;test-eq32 JCN2
;buf LDA LIT "! EQU ;test-ne32 JCN2
;buf LDA LIT "0 EQU ;test-is-zero32 JCN2
;buf LDA LIT "Z EQU ;test-non-zero32 JCN2
;buf LDA LIT "< EQU ;test-lt32 JCN2
;buf LDA LIT "> EQU ;test-gt32 JCN2
;buf LDA LIT "{ EQU ;test-lteq32 JCN2
;buf LDA LIT "} EQU ;test-gteq32 JCN2
LIT "? #18 DEO #0a #18 DEO ;reset JSR2 BRK
( set the interpreter to exit now )
@exit
#01 #0f DEO BRK
( reads j bytes, emits k bytes )
@test ( j^ k^ word* -> )
STH2 STH STH ( {j k word} )
;buf INC2 STHr ( buf+1 j {k word} )
;read-bytes JSR2 ( <j-bytes> {k word} )
ROTr ROTr STH2r ( <j-bytes> word {k} )
JSR2 STHr ( <k-bytes> k )
;emit-bytes JSR2 ( )
#0a #18 DEO ( )
;reset JSR2 BRK ( )
( reset the interpreter to read another line )
@reset ( -> )
#0000 ;pos STA2
#00 ;buf STA
JMP2r
( different test executors )
( )
( TEST-NAME #IN #OUT WORD-TO-TEST HARNESS )
@test-add32 #08 #04 ;add32 ;test JMP2
@test-mul32 #08 #04 ;mul32 ;test JMP2
@test-sub32 #08 #04 ;sub32 ;test JMP2
@test-div32 #08 #04 ;div32 ;test JMP2
@test-mod32 #08 #04 ;mod32 ;test JMP2
@test-gcd32 #08 #04 ;gcd32 ;test JMP2
@test-lshift32 #05 #04 ;lshift32 ;test JMP2
@test-rshift32 #05 #04 ;rshift32 ;test JMP2
@test-bitcount32 #04 #01 ;bitcount32 ;test JMP2
@test-and32 #08 #04 ;and32 ;test JMP2
@test-or32 #08 #04 ;or32 ;test JMP2
@test-xor32 #08 #04 ;xor32 ;test JMP2
@test-complement32 #04 #04 ;complement32 ;test JMP2
@test-negate32 #04 #04 ;negate32 ;test JMP2
@test-eq32 #08 #01 ;eq32 ;test JMP2
@test-ne32 #08 #01 ;ne32 ;test JMP2
@test-is-zero32 #04 #01 ;is-zero32 ;test JMP2
@test-non-zero32 #04 #01 ;non-zero32 ;test JMP2
@test-lt32 #08 #01 ;lt32 ;test JMP2
@test-lteq32 #08 #01 ;lteq32 ;test JMP2
@test-gt32 #08 #01 ;gt32 ;test JMP2
@test-gteq32 #08 #01 ;gteq32 ;test JMP2
( reads one byte from ASCII: "13" -> 0x13 )
@read-byte ( c0^ c1^ -> n^ )
( lower char )
DUP #3a LTH ,&lo-digit JCN
#57 ,&lo JMP &lo-digit #30
&lo SUB SWP
( higher char )
DUP #3a LTH ,&hi-digit JCN
#57 ,&hi JMP &hi-digit #30
&hi SUB #40 SFT ORA
JMP2r
( read k bytes from the buffer )
@read-bytes ( addr* k^ -> <k bytes> )
DUP ,&non-zero JCN ( addr k )
POP POP2 JMP2r ( )
&non-zero
STH STH2k ( addr {addr k} )
LDA2 ;read-byte JSR2 ( byte {addr k} )
STH2r #0002 ADD2 ( byte addr+2 {k} )
STHr #01 SUB ( byte addr+2 k-1 )
,read-bytes JMP ( byte addr+2 k-1 )
( emit n bytes from the stack, earliest first )
( )
( examples: )
( - #aa #bb #cc #03 will emit "aabbcc" )
( - #aa #bb #01 will emit "bb" leaving aa on wst )
( - #00 will emit nothing )
@emit-bytes ( <n bytes> n -> )
DUP
&loop ( <b0..bk> n k {<bk+1..bn>} )
DUP #00 EQU ,&next JCN
ROT STH #01 SUB ( <b0..bk-1> n k-1 <bk..bn> )
,&loop JMP
&next ( n 0 {<b0..bn>} )
POP
&while ( n-i {<bi..bn>} )
DUP #00 EQU ,&done JCN
STHr ;emit JSR2 #01 SUB
,&while JMP
&done
POP JMP2r
( emit a single byte in hexadecimal notation )
@emit
DUP #04 SFT ,&char JSR
&char #0f AND DUP #09 GTH #27 MUL ADD #30 ADD #18 DEO
JMP2r