/* * Tcode9 disassembler * Nils M Holm, 2017, CC0 license * https://creativecommons.org/publicdomain/zero/1.0/ */ #include #include #include #include #include #define MEMSIZE 131072 #define byte unsigned char #define sbyte signed char #define cell int byte *M; sbyte *S; cell Red; cell Data; void writes(char *s) { write(1, s, strlen(s)); } void wlog(char *s) { write(1, s, strlen(s)); } void fail(char *s) { wlog("tcdis: "); wlog(s); wlog("\n"); _exit(1); } #define BSIZE 1024 char B[BSIZE]; int Fd, C, K; int rdch(void) { if (C >= K) { K = read(Fd, B, BSIZE); C = 0; if (K < 1) return -1; } C = C+1; return B[C-1] & 255; } cell rdwd(void) { cell v; v = rdch(); v = v | (rdch() << 8); v = v | (rdch() << 16); v = v | (rdch() << 24); return v; } void readblk(byte *v, int k) { int i, c; for (i=0; i