From 473d080ef7422dcc9f0eb3f2eaff906ede07f612 Mon Sep 17 00:00:00 2001 From: neauoire Date: Thu, 9 Nov 2023 10:37:40 -0800 Subject: [PATCH] Removed old signed entry helper --- src/gyoasm.c | 6 +++--- src/tern.c | 41 ++++++++++------------------------------- src/tern.h | 5 +---- 3 files changed, 14 insertions(+), 38 deletions(-) diff --git a/src/gyoasm.c b/src/gyoasm.c index 27e0582..2d52e94 100644 --- a/src/gyoasm.c +++ b/src/gyoasm.c @@ -86,12 +86,12 @@ asmtoken(char *token) if((l = findlabel(token))) return (binuc15(l->addr) << 4) | 0x1; /* jump */ switch(token[0]) { - case '#': /* LIT */ return (hep2ter(token) << 2) | 0x2; + case '#': /* LIT */ return (hepuc15(token) << 2) | 0x2; case '>': /* JMP */ return (l = findlabel(token + 1)) ? (binuc15(l->addr) << 4) | 0x9 : error("Missing label", token); case '?': /* JCN */ return (l = findlabel(token + 1)) ? (binuc15(l->addr) << 4) | 0x5 : error("Missing label", token); } /* opcode */ - opc = str2ter("------0000--00-"); + opc = hepuc15("00MIL"); // blank OPC with signed flags while((c = *token++)) { switch(c) { case ';': opc &= ~(3 << 12); /* fall-through */ @@ -121,7 +121,7 @@ asmtoken(char *token) break; case '/': /* DEV */ opc &= ~(3 << 16); break; case '!': /* RAM */ opc &= ~(3 << 16), opc |= 2 << 16; break; - case '\'': /* IMM */ opc |= hep2ter(token) << 18; break; + case '\'': /* IMM */ opc |= hepuc15(token) << 18; break; case ']': break; default: printf("-- Unknown rune '%c' in %c%s(%02x)\n", c, c, token, c); break; } diff --git a/src/tern.c b/src/tern.c index 7789eea..02b2bc6 100644 --- a/src/tern.c +++ b/src/tern.c @@ -41,6 +41,16 @@ binuc15(int n) return acc; } +uc15 +hepuc15(char *str) +{ + uc15 acc = 0; + char c; + while((c = *str++)) + acc <<= 6, acc |= binuc15(c ? (c - 'A') + 1 : 0); + return acc; +} + int uc15bin(uc15 t) { @@ -50,17 +60,6 @@ uc15bin(uc15 t) return acc; } -uc3 -chr2tri(char c) -{ - switch(c) { - case '-': return 0; - case '0': return 1; - case '+': return 2; - } - return 3; -} - uc15 op_inc(uc15 a) { @@ -129,23 +128,3 @@ op_bin(uc15 a, uc15 b, uc15 gate) } return acc; } - -uc15 -str2ter(char *str) -{ - char c; - uc15 acc = 0; - while((c = *str++)) - acc = (acc << 2) | (chr2tri(c) & 0x3); - return acc; -} - -uc15 -hep2ter(char *str) -{ - uc15 acc = 0; - char c; - while((c = *str++)) - acc <<= 6, acc |= binuc15(c ? (c - 'A') + 1 : 0); - return acc; -} diff --git a/src/tern.h b/src/tern.h index 1a1f4dc..30d2069 100644 --- a/src/tern.h +++ b/src/tern.h @@ -19,13 +19,10 @@ void phep(uc15 n, int len); int uc15bin(uc15 t); uc15 binuc15(int n); +uc15 hepuc15(char *str); uc15 op_inc(uc15 a); uc15 op_add(uc15 a, uc15 b); uc15 op_cmp(uc15 a, uc15 b); uc15 op_una(uc15 a, uc3 gate); uc15 op_bin(uc15 a, uc15 b, uc15 gate); - -uc3 chr2tri(char c); -uc15 str2ter(char *str); -uc15 hep2ter(char *str); -- 2.45.2