Browse code

Merge branch 'main' of git.sr.ht:~rabbits/uxn

Devine Lu Linvega authored on 13/03/2023 17:32:44
Showing 1 changed files
... ...
@@ -28,7 +28,7 @@ WITH REGARD TO THIS SOFTWARE.
28 28
 */
29 29
 
30 30
 #define HALT(c) { return uxn_halt(u, ins, (c), pc - 1); }
31
-#define SET(mul, add) { if(mul > s->ptr) HALT(1) s->ptr += k * mul + add; if(s->ptr > 254) HALT(2) }
31
+#define SET(mul, add) { if(mul > s->ptr) HALT(1) tmp = s->ptr + k * mul + add; if(tmp > 254) HALT(2) s->ptr = tmp; }
32 32
 #define PUT(o, v) { s->dat[s->ptr - 1 - (o)] = (v); }
33 33
 #define PUT2(o, v) { tmp = (v); s->dat[s->ptr - o - 2] = tmp >> 8; s->dat[s->ptr - o - 1] = tmp; }
34 34
 #define PUSH(stack, v) { if(s->ptr > 254) HALT(2) stack->dat[stack->ptr++] = (v); }
... ...
@@ -61,7 +61,7 @@ uxn_eval(Uxn *u, Uint16 pc)
61 61
 			/* ALU */
62 62
 			case 0x01: /* INC  */ t=T;         SET(1, 0) PUT(0, t + 1) break;                           case 0x21: t=T2;           SET(2, 0) PUT2(0, t + 1) break;
63 63
 			case 0x02: /* POP  */              SET(1,-1) break;                                         case 0x22:                 SET(2,-2) break;
64
-			case 0x03: /* NIP  */ t=T;         SET(1,-1) PUT(0, t) break;                               case 0x23: t=T2;           SET(2,-2) PUT2(0, t) break;
64
+			case 0x03: /* NIP  */ t=T;         SET(2,-1) PUT(0, t) break;                               case 0x23: t=T2;           SET(4,-2) PUT2(0, t) break;
65 65
 			case 0x04: /* SWP  */ t=T;n=N;     SET(2, 0) PUT(0, n) PUT(1, t) break;                     case 0x24: t=T2;n=N2;      SET(4, 0) PUT2(0, n) PUT2(2, t) break;
66 66
 			case 0x05: /* ROT  */ t=T;n=N;l=L; SET(3, 0) PUT(0, l) PUT(1, t) PUT(2, n) break;           case 0x25: t=T2;n=N2;l=L2; SET(6, 0) PUT2(0, l) PUT2(2, t) PUT2(4, n) break;
67 67
 			case 0x06: /* DUP  */ t=T;         SET(1, 1) PUT(0, t) PUT(1, t) break;                     case 0x26: t=T2;           SET(2, 2) PUT2(0, t) PUT2(2, t) break;