commit 8a3c86a8793dbd2c683acea0f442645e21016ed7
parent 37afbc25fb2c8f699149a5d3ecf881ef4853e958
Author: Sigrid Solveig Haflínudóttir <sigrid@ftrv.se>
Date: Mon, 20 Mar 2023 16:29:46 +0000
core: in plan 9 C it does not wrap around, fix the crash
Diffstat:
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/src/uxn.c b/src/uxn.c
@@ -29,8 +29,8 @@ WITH REGARD TO THIS SOFTWARE.
#define HALT(c) { return uxn_halt(u, ins, (c), pc - 1); }
#define SET(mul, add) { if(mul > s->ptr) HALT(1) tmp = s->ptr + k * mul + add; if(tmp > 254) HALT(2) s->ptr = tmp; }
-#define PUT(o, v) { s->dat[s->ptr - 1 - (o)] = (v); }
-#define PUT2(o, v) { tmp = (v); s->dat[s->ptr - o - 2] = tmp >> 8; s->dat[s->ptr - o - 1] = tmp; }
+#define PUT(o, v) { s->dat[(Uint8)(s->ptr - 1 - (o))] = (v); }
+#define PUT2(o, v) { tmp = (v); s->dat[(Uint8)(s->ptr - o - 2)] = tmp >> 8; s->dat[(Uint8)(s->ptr - o - 1)] = tmp; }
#define PUSH(stack, v) { if(s->ptr > 254) HALT(2) stack->dat[stack->ptr++] = (v); }
#define PUSH2(stack, v) { if(s->ptr > 253) HALT(2) tmp = (v); stack->dat[stack->ptr] = tmp >> 8; stack->dat[stack->ptr + 1] = tmp; stack->ptr += 2; }
#define DEO(a, b) { u->dev[(a)] = (b); if((deo_mask[(a) >> 4] >> ((a) & 0xf)) & 0x1) uxn_deo(u, (a)); }