Added state reset when assembling.
h3rald h3rald@h3rald.com
Fri, 13 Feb 2026 08:02:14 +0100
1 files changed,
19 insertions(+),
0 deletions(-)
jump to
M
xywasm.c
→
xywasm.c
@@ -1,4 +1,5 @@
#include <stdio.h> +#include <string.h> #include "xyw.h" #define TOKEN_MAX_LENGTH 256@@ -1060,6 +1061,24 @@ xyw_context ctx;
ctx.file = (char *)input; ctx.line = 1; ctx.column = 1; + + // Reset all assembler state so xyw_assemble can be called multiple times + memset(data, 0, sizeof(data)); + ptr = 0; + memset(dict, 0, sizeof(dict)); + dictnext = dict; + memset(symbols, 0, sizeof(symbols)); + symcount = 0; + memset(refs, 0, sizeof(refs)); + refcount = 0; + token_length = 0; + token_type = TOKEN_TYPE_UNKNOWN; + token_value = 0; + token_is_word = 0; + token_line = 1; + token_column = 1; + directive = 0; + if (assemble_file(&ctx) != 0) { return -1;