Fixes.
h3rald h3rald@h3rald.com
Sat, 29 Nov 2025 17:22:19 +0100
M
xywvm.c
→
xywvm.c
@@ -147,6 +147,29 @@ (*ssp) += 2;
} */ +//// User stack management + +static void us_push(xyw_byte val) +{ + if (*usp > STACK_SIZE - 1) + { + xyw_memory[SYSTEM_ERROR] = XYW_ERROR_STACK_OVERFLOW; + return; + } + user_stack[(*usp)++] = val; +} + +static void us_pushw(xyw_word val) +{ + if (*usp > STACK_SIZE - 2) + { + xyw_memory[SYSTEM_ERROR] = XYW_ERROR_STACK_OVERFLOW; + return; + } + mset(USER_STACK_START + *usp, val); + (*usp) += 2; +} + //// Instructions static void PSH()@@ -303,11 +326,11 @@
//// Macro helpers // Infix operation -#define IOP(op) is_w() ? PSHw((POPw(1) op POPw(0))) : PSH((POP(1) op POP(0))) +#define IOP(op) is_w() ? us_pushw((POPw(1) op POPw(0))) : us_push((POP(1) op POP(0))) // Binary operation -#define BOP(op) is_w() ? PSHw(op(POPw(1), POPw(0))) : PSH(op(POP(1), POP(0))) +#define BOP(op) is_w() ? us_pushw(op(POPw(1), POPw(0))) : us_push(op(POP(1), POP(0))) // Unary operation -#define UOP(op) is_w() ? PSHw(op(POPw(1))) : PSH(op(POP(1))) +#define UOP(op) is_w() ? us_pushw(op(POPw(1))) : us_push(op(POP(1))) int run() {