From 1ec19679b3db209429b0897f6ccda6d09d018a70 Mon Sep 17 00:00:00 2001 From: mrb0nk500 Date: Sat, 8 Aug 2020 10:28:36 -0400 Subject: Did a ton of stuff. - Changed the file structure of the SuB Suite, so that all variable declarations, symbols, and constants are in a single file. - Moved the C library functionss into a separate file, and made them use stack frames. - Added support for using the emulator's assembler for realtime debugging, to enter it, get in to stepping mode by pressing Ctrl+s, press any other key, then press F1, The reason for having to press some other key before pressing F1 is because it only allows entering the assembler when the keyboard is not ready. - Added the ".res" directive to the emulator's assembler, the ".res" directive tells the assembler to reserve however many bytes specified by the operand. - Fixed some bugs in the emulator's assembler. --- assemble.c | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) (limited to 'assemble.c') diff --git a/assemble.c b/assemble.c index 49137c3..8100485 100644 --- a/assemble.c +++ b/assemble.c @@ -364,7 +364,8 @@ uint64_t parse_tokens(token *t, bytecount *bc, uint8_t isasm, uint64_t address, switch (t->id) { case TOK_DIR: switch (t->type) { - case DIR_ORG: t = t->next; address = get_val(t, address, 3, dbg); break; + case DIR_RES: t = t->next; address += get_val(t, address, 3, dbg); break; + case DIR_ORG: t = t->next; address = get_val(t, address, 3, dbg); break; case DIR_BYTE: case DIR_WORD: case DIR_DWORD: @@ -422,7 +423,6 @@ void assemble(line *ln, bytecount *bc, uint8_t dbg) { for (; l; l = l->next) { address = parse_tokens(l->tok, bc, 1, address, dbg); } - } static inline void free_tokens(token *t) { @@ -474,19 +474,24 @@ void cleanup() { uint16_t i; if (lines) { free_lines(); + lines = NULL; } if (symbols) { free_symbols(symbols); + symbols = NULL; } if (fixups) { free_fixups(); + fixups = NULL; } while (i < stridx || i < comidx) { - if (i < stridx) { + if (i < stridx && string[i]) { free(string[i]); + string[i] = NULL; } - if (i < comidx) { + if (i < comidx && comment[i]) { free(comment[i]); + comment[i] = NULL; } i++; } -- cgit v1.2.3-13-gbd6f