all repos — xyw @ 67b085f0086897889d8eaf784b339502f5373d74

A minimal virtual machine and assembler for terminals.

Added state reset when assembling.
h3rald h3rald@h3rald.com
Fri, 13 Feb 2026 08:02:14 +0100
commit

67b085f0086897889d8eaf784b339502f5373d74

parent

9e819fc4b092dbaa6ac66be875e66dc74b9f4a12

1 files changed, 19 insertions(+), 0 deletions(-)

jump to
M xywasm.cxywasm.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;