From 071edf621a6722f94027f37720a5a5f73d9696c0 Mon Sep 17 00:00:00 2001 From: mrb0nk500 Date: Tue, 17 Mar 2020 15:07:20 -0400 Subject: Revamped the opcode table, made the emulator more efficient, and ported SuBEditor to C. I revamped the opcode table to add another prefix bit for the addressing mode, finally giving access to all addresses, without wasting any bytes. I made the stack based operations more efficient, by sort of applying Duff's device to it. And I ported SuBEditor to C, to make it easier for me to figure out how to implement SuBAsm. --- programs/c-ports/subasm.c | 33 +++++++++++++++++++++++++++++++++ 1 file changed, 33 insertions(+) create mode 100644 programs/c-ports/subasm.c (limited to 'programs/c-ports/subasm.c') diff --git a/programs/c-ports/subasm.c b/programs/c-ports/subasm.c new file mode 100644 index 0000000..a996e3a --- /dev/null +++ b/programs/c-ports/subasm.c @@ -0,0 +1,33 @@ +#include "subeditor.h" +int16_t str_cmp(const char *s0, uint16_t i, const char *s1, uint16_t j) { + for (; s0[i] == s1[j]; i++, j++); + return i-j; +} + +void tokenize(char *str) { + uint16_t i = 0; + uint16_t skip = 0; + uint8_t done = 0; + while (!done) { + if (!cmd_buf[i]) { + done = 1; + } else { + switch (cmd_buf[i]) { + case '.': + if (skip = str_cmp(cmd_buf, i+1, "org", 0) > 0) { + f = TOK_ORG; + i += skip; + } else if (skip = str_cmp(cmd_buf, i+1, "byte", 0) > 0) { + f = TOK_BYTE; + i+=skip; + } + break; + } + } + } +} + +void subasm() { + uint64_t address = 0; + tokenize(cmd_buf); +} -- cgit v1.2.3-13-gbd6f