Fixed more subtle bugs, improved directory matching in assembler.
h3rald h3rald@h3rald.com
Fri, 13 Feb 2026 07:56:02 +0100
M
xywasm.c
→
xywasm.c
@@ -735,23 +735,23 @@ }
directive = 1; token_type = TOKEN_TYPE_DIRECTIVE; int r; - if (strcmpn(token, ".label", 6) == 0) + if (token_length == 6 && strcmpn(token, ".label", 6) == 0) { r = process_directive_label(ctx); } - else if (strcmpn(token, ".include", 8) == 0) + else if (token_length == 8 && strcmpn(token, ".include", 8) == 0) { r = process_directive_include(ctx); } - else if (strcmpn(token, ".string", 7) == 0) + else if (token_length == 7 && strcmpn(token, ".string", 7) == 0) { r = process_directive_string(ctx); } - else if (strcmpn(token, ".byte", 5) == 0) + else if (token_length == 5 && strcmpn(token, ".byte", 5) == 0) { r = process_directive_byte(ctx); } - else if (strcmpn(token, ".macro", 6) == 0) + else if (token_length == 6 && strcmpn(token, ".macro", 6) == 0) { r = process_directive_macro(ctx); }
M
xywrun.c
→
xywrun.c
@@ -107,23 +107,20 @@ }
//// Read/write memory helpers -static inline xyw_word readw(xyw_word addr) +static inline xyw_byte readb(xyw_word addr) { int dev_num = get_device(addr); if (dev_num >= 0 && xyw_devices[dev_num].input) { xyw_byte dev_addr = get_device_address(addr); - // Read two bytes from device - xyw_byte high = xyw_devices[dev_num].input(get_device_data(addr), dev_addr, error); - xyw_byte low = xyw_devices[dev_num].input(get_device_data(addr), dev_addr + 1, error); - return (xyw_word)((high << 8) | low); + return xyw_devices[dev_num].input(get_device_data(addr), dev_addr, error); } - return XYW_PEEKW(&xyw_memory[addr]); + return xyw_memory[addr]; } -static inline void writew(xyw_word addr, xyw_word val) +static inline void writeb(xyw_word addr, xyw_byte val) { - XYW_POKEW(&xyw_memory[addr], val); + xyw_memory[addr] = val; int dev_num = get_device(addr); if (dev_num >= 0 && xyw_devices[dev_num].output) {@@ -132,26 +129,20 @@ xyw_devices[dev_num].output(get_device_data(addr), dev_addr, error);
} } -static inline xyw_byte readb(xyw_word addr) +static inline xyw_word readw(xyw_word addr) { - int dev_num = get_device(addr); - if (dev_num >= 0 && xyw_devices[dev_num].input) - { - xyw_byte dev_addr = get_device_address(addr); - return xyw_devices[dev_num].input(get_device_data(addr), dev_addr, error); - } - return xyw_memory[addr]; + // Read high and low bytes independently to handle device boundaries + xyw_byte high = readb(addr); + xyw_byte low = readb(addr + 1); + return (xyw_word)((high << 8) | low); } -static inline void writeb(xyw_word addr, xyw_byte val) +static inline void writew(xyw_word addr, xyw_word val) { - xyw_memory[addr] = val; - int dev_num = get_device(addr); - if (dev_num >= 0 && xyw_devices[dev_num].output) - { - xyw_byte dev_addr = get_device_address(addr); - xyw_devices[dev_num].output(get_device_data(addr), dev_addr, error); - } + // Write high and low bytes independently to handle device boundaries + // and trigger output handlers for both bytes + writeb(addr, (xyw_byte)(val >> 8)); + writeb(addr + 1, (xyw_byte)(val & 0xFF)); } //// Device dispatchers@@ -385,7 +376,7 @@ int xyw_eval(xyw_word start_pc)
{ *pc = start_pc; - if (xyw_memory[SYSTEM_STATE] & xyw_debug) + if (xyw_debug) { xyw_memory[SYSTEM_STATE] |= SYSTEM_STATE_DEBUG; }