diff options
author | mrb0nk500 <b0nk@b0nk.xyz> | 2020-03-17 15:07:20 -0400 |
---|---|---|
committer | mrb0nk500 <b0nk@b0nk.xyz> | 2020-03-17 15:36:07 -0400 |
commit | 071edf621a6722f94027f37720a5a5f73d9696c0 (patch) | |
tree | 87761e6dca9e7cf47bf0b6f2d52e8e31623ac01a /programs/c-ports/subasm.c | |
parent | 917f864a6d1304d9f0c650c107a5fd6576690cb7 (diff) |
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.
Diffstat (limited to 'programs/c-ports/subasm.c')
-rw-r--r-- | programs/c-ports/subasm.c | 33 |
1 files changed, 33 insertions, 0 deletions
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); +} |