From 6337990fe016a4135812670814e13d4996db84af Mon Sep 17 00:00:00 2001 From: Andrew Alderwick Date: Mon, 30 Aug 2021 18:45:04 +0100 Subject: [PATCH] Reverted flags in uxn-fast.c --- src/uxn-fast.c | 2119 ++++++++++++++++++++++++------------------------ 1 file changed, 1059 insertions(+), 1060 deletions(-) diff --git a/src/uxn-fast.c b/src/uxn-fast.c index 81ba839..5f3d46e 100644 --- a/src/uxn-fast.c +++ b/src/uxn-fast.c @@ -22,8 +22,7 @@ See etc/mkuxn-fast.moon for instructions. */ -#define MODE_RETURN 0x20 -#define MODE_SHORT 0x40 +#define MODE_RETURN 0x40 #define MODE_KEEP 0x80 #pragma mark - Operations @@ -501,8 +500,492 @@ uxn_eval(Uxn *u, Uint16 vec) u->wst.ptr -= 1; } break; - case 0x20: /* LITr */ - case 0xa0: /* LITkr */ + case 0x20: /* LIT2 */ + case 0xa0: /* LIT2k */ + { + u->wst.dat[u->wst.ptr] = peek8(u->ram.dat, u->ram.ptr++); + u->wst.dat[u->wst.ptr + 1] = peek8(u->ram.dat, u->ram.ptr++); +#ifndef NO_STACK_CHECKS + if(__builtin_expect(u->wst.ptr > 253, 0)) { + u->wst.error = 2; + goto error; + } +#endif + u->wst.ptr += 2; + } + break; + case 0x21: /* INC2 */ + { + Uint16 a = (u->wst.dat[u->wst.ptr - 1] | (u->wst.dat[u->wst.ptr - 2] << 8)); + u->wst.dat[u->wst.ptr - 2] = (a + 1) >> 8; + u->wst.dat[u->wst.ptr - 1] = (a + 1) & 0xff; +#ifndef NO_STACK_CHECKS + if(__builtin_expect(u->wst.ptr < 2, 0)) { + u->wst.error = 1; + goto error; + } +#endif + } + break; + case 0x22: /* POP2 */ + { + (u->wst.dat[u->wst.ptr - 1] | (u->wst.dat[u->wst.ptr - 2] << 8)); +#ifndef NO_STACK_CHECKS + if(__builtin_expect(u->wst.ptr < 2, 0)) { + u->wst.error = 1; + goto error; + } +#endif + u->wst.ptr -= 2; + } + break; + case 0x23: /* DUP2 */ + { + Uint8 a = u->wst.dat[u->wst.ptr - 1], b = u->wst.dat[u->wst.ptr - 2]; + u->wst.dat[u->wst.ptr] = b; + u->wst.dat[u->wst.ptr + 1] = a; +#ifndef NO_STACK_CHECKS + if(__builtin_expect(u->wst.ptr < 2, 0)) { + u->wst.error = 1; + goto error; + } + if(__builtin_expect(u->wst.ptr > 253, 0)) { + u->wst.error = 2; + goto error; + } +#endif + u->wst.ptr += 2; + } + break; + case 0x24: /* NIP2 */ + { + Uint16 a = (u->wst.dat[u->wst.ptr - 1] | (u->wst.dat[u->wst.ptr - 2] << 8)); + (u->wst.dat[u->wst.ptr - 3] | (u->wst.dat[u->wst.ptr - 4] << 8)); + u->wst.dat[u->wst.ptr - 4] = a >> 8; + u->wst.dat[u->wst.ptr - 3] = a & 0xff; +#ifndef NO_STACK_CHECKS + if(__builtin_expect(u->wst.ptr < 4, 0)) { + u->wst.error = 1; + goto error; + } +#endif + u->wst.ptr -= 2; + } + break; + case 0x25: /* SWP2 */ + { + Uint8 a = u->wst.dat[u->wst.ptr - 1], b = u->wst.dat[u->wst.ptr - 2], c = u->wst.dat[u->wst.ptr - 3], d = u->wst.dat[u->wst.ptr - 4]; + u->wst.dat[u->wst.ptr - 4] = b; + u->wst.dat[u->wst.ptr - 3] = a; + u->wst.dat[u->wst.ptr - 2] = d; + u->wst.dat[u->wst.ptr - 1] = c; +#ifndef NO_STACK_CHECKS + if(__builtin_expect(u->wst.ptr < 4, 0)) { + u->wst.error = 1; + goto error; + } +#endif + } + break; + case 0x26: /* OVR2 */ + { + Uint8 a = u->wst.dat[u->wst.ptr - 1], b = u->wst.dat[u->wst.ptr - 2], c = u->wst.dat[u->wst.ptr - 3], d = u->wst.dat[u->wst.ptr - 4]; + u->wst.dat[u->wst.ptr] = d; + u->wst.dat[u->wst.ptr + 1] = c; +#ifndef NO_STACK_CHECKS + if(__builtin_expect(u->wst.ptr < 4, 0)) { + u->wst.error = 1; + goto error; + } + if(__builtin_expect(u->wst.ptr > 253, 0)) { + u->wst.error = 2; + goto error; + } +#endif + u->wst.ptr += 2; + } + break; + case 0x27: /* ROT2 */ + { + Uint8 a = u->wst.dat[u->wst.ptr - 1], b = u->wst.dat[u->wst.ptr - 2], c = u->wst.dat[u->wst.ptr - 3], d = u->wst.dat[u->wst.ptr - 4], e = u->wst.dat[u->wst.ptr - 5], f = u->wst.dat[u->wst.ptr - 6]; + u->wst.dat[u->wst.ptr - 6] = d; + u->wst.dat[u->wst.ptr - 5] = c; + u->wst.dat[u->wst.ptr - 4] = b; + u->wst.dat[u->wst.ptr - 3] = a; + u->wst.dat[u->wst.ptr - 2] = f; + u->wst.dat[u->wst.ptr - 1] = e; +#ifndef NO_STACK_CHECKS + if(__builtin_expect(u->wst.ptr < 6, 0)) { + u->wst.error = 1; + goto error; + } +#endif + } + break; + case 0x28: /* EQU2 */ + { + Uint16 a = (u->wst.dat[u->wst.ptr - 1] | (u->wst.dat[u->wst.ptr - 2] << 8)), b = (u->wst.dat[u->wst.ptr - 3] | (u->wst.dat[u->wst.ptr - 4] << 8)); + u->wst.dat[u->wst.ptr - 4] = b == a; +#ifndef NO_STACK_CHECKS + if(__builtin_expect(u->wst.ptr < 4, 0)) { + u->wst.error = 1; + goto error; + } +#endif + u->wst.ptr -= 3; + } + break; + case 0x29: /* NEQ2 */ + { + Uint16 a = (u->wst.dat[u->wst.ptr - 1] | (u->wst.dat[u->wst.ptr - 2] << 8)), b = (u->wst.dat[u->wst.ptr - 3] | (u->wst.dat[u->wst.ptr - 4] << 8)); + u->wst.dat[u->wst.ptr - 4] = b != a; +#ifndef NO_STACK_CHECKS + if(__builtin_expect(u->wst.ptr < 4, 0)) { + u->wst.error = 1; + goto error; + } +#endif + u->wst.ptr -= 3; + } + break; + case 0x2a: /* GTH2 */ + { + Uint16 a = (u->wst.dat[u->wst.ptr - 1] | (u->wst.dat[u->wst.ptr - 2] << 8)), b = (u->wst.dat[u->wst.ptr - 3] | (u->wst.dat[u->wst.ptr - 4] << 8)); + u->wst.dat[u->wst.ptr - 4] = b > a; +#ifndef NO_STACK_CHECKS + if(__builtin_expect(u->wst.ptr < 4, 0)) { + u->wst.error = 1; + goto error; + } +#endif + u->wst.ptr -= 3; + } + break; + case 0x2b: /* LTH2 */ + { + Uint16 a = (u->wst.dat[u->wst.ptr - 1] | (u->wst.dat[u->wst.ptr - 2] << 8)), b = (u->wst.dat[u->wst.ptr - 3] | (u->wst.dat[u->wst.ptr - 4] << 8)); + u->wst.dat[u->wst.ptr - 4] = b < a; +#ifndef NO_STACK_CHECKS + if(__builtin_expect(u->wst.ptr < 4, 0)) { + u->wst.error = 1; + goto error; + } +#endif + u->wst.ptr -= 3; + } + break; + case 0x2c: /* JMP2 */ + { + u->ram.ptr = (u->wst.dat[u->wst.ptr - 1] | (u->wst.dat[u->wst.ptr - 2] << 8)); +#ifndef NO_STACK_CHECKS + if(__builtin_expect(u->wst.ptr < 2, 0)) { + u->wst.error = 1; + goto error; + } +#endif + u->wst.ptr -= 2; + } + break; + case 0x2d: /* JCN2 */ + { + Uint16 a = (u->wst.dat[u->wst.ptr - 1] | (u->wst.dat[u->wst.ptr - 2] << 8)); + if(u->wst.dat[u->wst.ptr - 3]) u->ram.ptr = a; +#ifndef NO_STACK_CHECKS + if(__builtin_expect(u->wst.ptr < 3, 0)) { + u->wst.error = 1; + goto error; + } +#endif + u->wst.ptr -= 3; + } + break; + case 0x2e: /* JSR2 */ + { + u->rst.dat[u->rst.ptr] = u->ram.ptr >> 8; + u->rst.dat[u->rst.ptr + 1] = u->ram.ptr & 0xff; + u->ram.ptr = (u->wst.dat[u->wst.ptr - 1] | (u->wst.dat[u->wst.ptr - 2] << 8)); +#ifndef NO_STACK_CHECKS + if(__builtin_expect(u->wst.ptr < 2, 0)) { + u->wst.error = 1; + goto error; + } +#endif + u->wst.ptr -= 2; +#ifndef NO_STACK_CHECKS + if(__builtin_expect(u->rst.ptr > 253, 0)) { + u->rst.error = 2; + goto error; + } +#endif + u->rst.ptr += 2; + } + break; + case 0x2f: /* STH2 */ + { + Uint8 a = u->wst.dat[u->wst.ptr - 1], b = u->wst.dat[u->wst.ptr - 2]; + u->rst.dat[u->rst.ptr] = b; + u->rst.dat[u->rst.ptr + 1] = a; +#ifndef NO_STACK_CHECKS + if(__builtin_expect(u->wst.ptr < 2, 0)) { + u->wst.error = 1; + goto error; + } +#endif + u->wst.ptr -= 2; +#ifndef NO_STACK_CHECKS + if(__builtin_expect(u->rst.ptr > 253, 0)) { + u->rst.error = 2; + goto error; + } +#endif + u->rst.ptr += 2; + } + break; + case 0x30: /* LDZ2 */ + { + Uint8 a = u->wst.dat[u->wst.ptr - 1]; + u->wst.dat[u->wst.ptr - 1] = peek8(u->ram.dat, a); + u->wst.dat[u->wst.ptr] = peek8(u->ram.dat, a + 1); +#ifndef NO_STACK_CHECKS + if(__builtin_expect(u->wst.ptr < 1, 0)) { + u->wst.error = 1; + goto error; + } + if(__builtin_expect(u->wst.ptr > 254, 0)) { + u->wst.error = 2; + goto error; + } +#endif + u->wst.ptr += 1; + } + break; + case 0x31: /* STZ2 */ + { + Uint8 a = u->wst.dat[u->wst.ptr - 1]; + Uint16 b = (u->wst.dat[u->wst.ptr - 2] | (u->wst.dat[u->wst.ptr - 3] << 8)); + poke16(u->ram.dat, a, b); +#ifndef NO_STACK_CHECKS + if(__builtin_expect(u->wst.ptr < 3, 0)) { + u->wst.error = 1; + goto error; + } +#endif + u->wst.ptr -= 3; + } + break; + case 0x32: /* LDR2 */ + { + Uint8 a = u->wst.dat[u->wst.ptr - 1]; + u->wst.dat[u->wst.ptr - 1] = peek8(u->ram.dat, u->ram.ptr + (Sint8)a); + u->wst.dat[u->wst.ptr] = peek8(u->ram.dat, u->ram.ptr + (Sint8)a + 1); +#ifndef NO_STACK_CHECKS + if(__builtin_expect(u->wst.ptr < 1, 0)) { + u->wst.error = 1; + goto error; + } + if(__builtin_expect(u->wst.ptr > 254, 0)) { + u->wst.error = 2; + goto error; + } +#endif + u->wst.ptr += 1; + } + break; + case 0x33: /* STR2 */ + { + Uint8 a = u->wst.dat[u->wst.ptr - 1]; + Uint16 b = (u->wst.dat[u->wst.ptr - 2] | (u->wst.dat[u->wst.ptr - 3] << 8)); + poke16(u->ram.dat, u->ram.ptr + (Sint8)a, b); +#ifndef NO_STACK_CHECKS + if(__builtin_expect(u->wst.ptr < 3, 0)) { + u->wst.error = 1; + goto error; + } +#endif + u->wst.ptr -= 3; + } + break; + case 0x34: /* LDA2 */ + { + Uint16 a = (u->wst.dat[u->wst.ptr - 1] | (u->wst.dat[u->wst.ptr - 2] << 8)); + u->wst.dat[u->wst.ptr - 2] = peek8(u->ram.dat, a); + u->wst.dat[u->wst.ptr - 1] = peek8(u->ram.dat, a + 1); +#ifndef NO_STACK_CHECKS + if(__builtin_expect(u->wst.ptr < 2, 0)) { + u->wst.error = 1; + goto error; + } +#endif + } + break; + case 0x35: /* STA2 */ + { + Uint16 a = (u->wst.dat[u->wst.ptr - 1] | (u->wst.dat[u->wst.ptr - 2] << 8)); + Uint16 b = (u->wst.dat[u->wst.ptr - 3] | (u->wst.dat[u->wst.ptr - 4] << 8)); + poke16(u->ram.dat, a, b); +#ifndef NO_STACK_CHECKS + if(__builtin_expect(u->wst.ptr < 4, 0)) { + u->wst.error = 1; + goto error; + } +#endif + u->wst.ptr -= 4; + } + break; + case 0x36: /* DEI2 */ + { + Uint8 a = u->wst.dat[u->wst.ptr - 1]; + u->wst.dat[u->wst.ptr - 1] = devr8(&u->dev[a >> 4], a); + u->wst.dat[u->wst.ptr] = devr8(&u->dev[a >> 4], a + 1); +#ifndef NO_STACK_CHECKS + if(__builtin_expect(u->wst.ptr < 1, 0)) { + u->wst.error = 1; + goto error; + } + if(__builtin_expect(u->wst.ptr > 254, 0)) { + u->wst.error = 2; + goto error; + } +#endif + u->wst.ptr += 1; + } + break; + case 0x37: /* DEO2 */ + { + Uint8 a = u->wst.dat[u->wst.ptr - 1]; + Uint16 b = (u->wst.dat[u->wst.ptr - 2] | (u->wst.dat[u->wst.ptr - 3] << 8)); + devw16(&u->dev[a >> 4], a, b); +#ifndef NO_STACK_CHECKS + if(__builtin_expect(u->wst.ptr < 3, 0)) { + u->wst.error = 1; + goto error; + } +#endif + u->wst.ptr -= 3; + } + break; + case 0x38: /* ADD2 */ + { + Uint16 a = (u->wst.dat[u->wst.ptr - 1] | (u->wst.dat[u->wst.ptr - 2] << 8)), b = (u->wst.dat[u->wst.ptr - 3] | (u->wst.dat[u->wst.ptr - 4] << 8)); + u->wst.dat[u->wst.ptr - 4] = (b + a) >> 8; + u->wst.dat[u->wst.ptr - 3] = (b + a) & 0xff; +#ifndef NO_STACK_CHECKS + if(__builtin_expect(u->wst.ptr < 4, 0)) { + u->wst.error = 1; + goto error; + } +#endif + u->wst.ptr -= 2; + } + break; + case 0x39: /* SUB2 */ + { + Uint16 a = (u->wst.dat[u->wst.ptr - 1] | (u->wst.dat[u->wst.ptr - 2] << 8)), b = (u->wst.dat[u->wst.ptr - 3] | (u->wst.dat[u->wst.ptr - 4] << 8)); + u->wst.dat[u->wst.ptr - 4] = (b - a) >> 8; + u->wst.dat[u->wst.ptr - 3] = (b - a) & 0xff; +#ifndef NO_STACK_CHECKS + if(__builtin_expect(u->wst.ptr < 4, 0)) { + u->wst.error = 1; + goto error; + } +#endif + u->wst.ptr -= 2; + } + break; + case 0x3a: /* MUL2 */ + { + Uint16 a = (u->wst.dat[u->wst.ptr - 1] | (u->wst.dat[u->wst.ptr - 2] << 8)), b = (u->wst.dat[u->wst.ptr - 3] | (u->wst.dat[u->wst.ptr - 4] << 8)); + u->wst.dat[u->wst.ptr - 4] = (b * a) >> 8; + u->wst.dat[u->wst.ptr - 3] = (b * a) & 0xff; +#ifndef NO_STACK_CHECKS + if(__builtin_expect(u->wst.ptr < 4, 0)) { + u->wst.error = 1; + goto error; + } +#endif + u->wst.ptr -= 2; + } + break; + case 0x3b: /* DIV2 */ + { + Uint16 a = (u->wst.dat[u->wst.ptr - 1] | (u->wst.dat[u->wst.ptr - 2] << 8)), b = (u->wst.dat[u->wst.ptr - 3] | (u->wst.dat[u->wst.ptr - 4] << 8)); + if(a == 0) { + u->wst.error = 3; +#ifndef NO_STACK_CHECKS + goto error; +#endif + a = 1; + } + u->wst.dat[u->wst.ptr - 4] = (b / a) >> 8; + u->wst.dat[u->wst.ptr - 3] = (b / a) & 0xff; +#ifndef NO_STACK_CHECKS + if(__builtin_expect(u->wst.ptr < 4, 0)) { + u->wst.error = 1; + goto error; + } +#endif + u->wst.ptr -= 2; + } + break; + case 0x3c: /* AND2 */ + { + Uint8 a = u->wst.dat[u->wst.ptr - 1], b = u->wst.dat[u->wst.ptr - 2], c = u->wst.dat[u->wst.ptr - 3], d = u->wst.dat[u->wst.ptr - 4]; + u->wst.dat[u->wst.ptr - 4] = d & b; + u->wst.dat[u->wst.ptr - 3] = c & a; +#ifndef NO_STACK_CHECKS + if(__builtin_expect(u->wst.ptr < 4, 0)) { + u->wst.error = 1; + goto error; + } +#endif + u->wst.ptr -= 2; + } + break; + case 0x3d: /* ORA2 */ + { + Uint8 a = u->wst.dat[u->wst.ptr - 1], b = u->wst.dat[u->wst.ptr - 2], c = u->wst.dat[u->wst.ptr - 3], d = u->wst.dat[u->wst.ptr - 4]; + u->wst.dat[u->wst.ptr - 4] = d | b; + u->wst.dat[u->wst.ptr - 3] = c | a; +#ifndef NO_STACK_CHECKS + if(__builtin_expect(u->wst.ptr < 4, 0)) { + u->wst.error = 1; + goto error; + } +#endif + u->wst.ptr -= 2; + } + break; + case 0x3e: /* EOR2 */ + { + Uint8 a = u->wst.dat[u->wst.ptr - 1], b = u->wst.dat[u->wst.ptr - 2], c = u->wst.dat[u->wst.ptr - 3], d = u->wst.dat[u->wst.ptr - 4]; + u->wst.dat[u->wst.ptr - 4] = d ^ b; + u->wst.dat[u->wst.ptr - 3] = c ^ a; +#ifndef NO_STACK_CHECKS + if(__builtin_expect(u->wst.ptr < 4, 0)) { + u->wst.error = 1; + goto error; + } +#endif + u->wst.ptr -= 2; + } + break; + case 0x3f: /* SFT2 */ + { + Uint8 a = u->wst.dat[u->wst.ptr - 1]; + Uint16 b = (u->wst.dat[u->wst.ptr - 2] | (u->wst.dat[u->wst.ptr - 3] << 8)); + u->wst.dat[u->wst.ptr - 3] = (b >> (a & 0x0f) << ((a & 0xf0) >> 4)) >> 8; + u->wst.dat[u->wst.ptr - 2] = (b >> (a & 0x0f) << ((a & 0xf0) >> 4)) & 0xff; +#ifndef NO_STACK_CHECKS + if(__builtin_expect(u->wst.ptr < 3, 0)) { + u->wst.error = 1; + goto error; + } +#endif + u->wst.ptr -= 1; + } + break; + case 0x40: /* LITr */ + case 0xc0: /* LITkr */ { u->rst.dat[u->rst.ptr] = peek8(u->ram.dat, u->ram.ptr++); #ifndef NO_STACK_CHECKS @@ -514,7 +997,7 @@ uxn_eval(Uxn *u, Uint16 vec) u->rst.ptr += 1; } break; - case 0x21: /* INCr */ + case 0x41: /* INCr */ { Uint8 a = u->rst.dat[u->rst.ptr - 1]; u->rst.dat[u->rst.ptr - 1] = a + 1; @@ -526,7 +1009,7 @@ uxn_eval(Uxn *u, Uint16 vec) #endif } break; - case 0x22: /* POPr */ + case 0x42: /* POPr */ { u->rst.dat[u->rst.ptr - 1]; #ifndef NO_STACK_CHECKS @@ -538,7 +1021,7 @@ uxn_eval(Uxn *u, Uint16 vec) u->rst.ptr -= 1; } break; - case 0x23: /* DUPr */ + case 0x43: /* DUPr */ { Uint8 a = u->rst.dat[u->rst.ptr - 1]; u->rst.dat[u->rst.ptr] = a; @@ -555,7 +1038,7 @@ uxn_eval(Uxn *u, Uint16 vec) u->rst.ptr += 1; } break; - case 0x24: /* NIPr */ + case 0x44: /* NIPr */ { Uint8 a = u->rst.dat[u->rst.ptr - 1]; u->rst.dat[u->rst.ptr - 2]; @@ -569,7 +1052,7 @@ uxn_eval(Uxn *u, Uint16 vec) u->rst.ptr -= 1; } break; - case 0x25: /* SWPr */ + case 0x45: /* SWPr */ { Uint8 a = u->rst.dat[u->rst.ptr - 1], b = u->rst.dat[u->rst.ptr - 2]; u->rst.dat[u->rst.ptr - 2] = a; @@ -582,7 +1065,7 @@ uxn_eval(Uxn *u, Uint16 vec) #endif } break; - case 0x26: /* OVRr */ + case 0x46: /* OVRr */ { Uint8 a = u->rst.dat[u->rst.ptr - 1], b = u->rst.dat[u->rst.ptr - 2]; u->rst.dat[u->rst.ptr] = b; @@ -599,7 +1082,7 @@ uxn_eval(Uxn *u, Uint16 vec) u->rst.ptr += 1; } break; - case 0x27: /* ROTr */ + case 0x47: /* ROTr */ { Uint8 a = u->rst.dat[u->rst.ptr - 1], b = u->rst.dat[u->rst.ptr - 2], c = u->rst.dat[u->rst.ptr - 3]; u->rst.dat[u->rst.ptr - 3] = b; @@ -613,7 +1096,7 @@ uxn_eval(Uxn *u, Uint16 vec) #endif } break; - case 0x28: /* EQUr */ + case 0x48: /* EQUr */ { Uint8 a = u->rst.dat[u->rst.ptr - 1], b = u->rst.dat[u->rst.ptr - 2]; u->rst.dat[u->rst.ptr - 2] = b == a; @@ -626,7 +1109,7 @@ uxn_eval(Uxn *u, Uint16 vec) u->rst.ptr -= 1; } break; - case 0x29: /* NEQr */ + case 0x49: /* NEQr */ { Uint8 a = u->rst.dat[u->rst.ptr - 1], b = u->rst.dat[u->rst.ptr - 2]; u->rst.dat[u->rst.ptr - 2] = b != a; @@ -639,7 +1122,7 @@ uxn_eval(Uxn *u, Uint16 vec) u->rst.ptr -= 1; } break; - case 0x2a: /* GTHr */ + case 0x4a: /* GTHr */ { Uint8 a = u->rst.dat[u->rst.ptr - 1], b = u->rst.dat[u->rst.ptr - 2]; u->rst.dat[u->rst.ptr - 2] = b > a; @@ -652,7 +1135,7 @@ uxn_eval(Uxn *u, Uint16 vec) u->rst.ptr -= 1; } break; - case 0x2b: /* LTHr */ + case 0x4b: /* LTHr */ { Uint8 a = u->rst.dat[u->rst.ptr - 1], b = u->rst.dat[u->rst.ptr - 2]; u->rst.dat[u->rst.ptr - 2] = b < a; @@ -665,7 +1148,7 @@ uxn_eval(Uxn *u, Uint16 vec) u->rst.ptr -= 1; } break; - case 0x2c: /* JMPr */ + case 0x4c: /* JMPr */ { Uint8 a = u->rst.dat[u->rst.ptr - 1]; u->ram.ptr += (Sint8)a; @@ -678,7 +1161,7 @@ uxn_eval(Uxn *u, Uint16 vec) u->rst.ptr -= 1; } break; - case 0x2d: /* JCNr */ + case 0x4d: /* JCNr */ { Uint8 a = u->rst.dat[u->rst.ptr - 1]; if(u->rst.dat[u->rst.ptr - 2]) u->ram.ptr += (Sint8)a; @@ -691,7 +1174,7 @@ uxn_eval(Uxn *u, Uint16 vec) u->rst.ptr -= 2; } break; - case 0x2e: /* JSRr */ + case 0x4e: /* JSRr */ { Uint8 a = u->rst.dat[u->rst.ptr - 1]; u->wst.dat[u->wst.ptr] = u->ram.ptr >> 8; @@ -713,7 +1196,7 @@ uxn_eval(Uxn *u, Uint16 vec) u->wst.ptr += 2; } break; - case 0x2f: /* STHr */ + case 0x4f: /* STHr */ { Uint8 a = u->rst.dat[u->rst.ptr - 1]; u->wst.dat[u->wst.ptr] = a; @@ -733,7 +1216,7 @@ uxn_eval(Uxn *u, Uint16 vec) u->wst.ptr += 1; } break; - case 0x30: /* LDZr */ + case 0x50: /* LDZr */ { Uint8 a = u->rst.dat[u->rst.ptr - 1]; u->rst.dat[u->rst.ptr - 1] = peek8(u->ram.dat, a); @@ -745,7 +1228,7 @@ uxn_eval(Uxn *u, Uint16 vec) #endif } break; - case 0x31: /* STZr */ + case 0x51: /* STZr */ { Uint8 a = u->rst.dat[u->rst.ptr - 1]; Uint8 b = u->rst.dat[u->rst.ptr - 2]; @@ -759,7 +1242,7 @@ uxn_eval(Uxn *u, Uint16 vec) u->rst.ptr -= 2; } break; - case 0x32: /* LDRr */ + case 0x52: /* LDRr */ { Uint8 a = u->rst.dat[u->rst.ptr - 1]; u->rst.dat[u->rst.ptr - 1] = peek8(u->ram.dat, u->ram.ptr + (Sint8)a); @@ -771,7 +1254,7 @@ uxn_eval(Uxn *u, Uint16 vec) #endif } break; - case 0x33: /* STRr */ + case 0x53: /* STRr */ { Uint8 a = u->rst.dat[u->rst.ptr - 1]; Uint8 b = u->rst.dat[u->rst.ptr - 2]; @@ -785,7 +1268,7 @@ uxn_eval(Uxn *u, Uint16 vec) u->rst.ptr -= 2; } break; - case 0x34: /* LDAr */ + case 0x54: /* LDAr */ { Uint16 a = (u->rst.dat[u->rst.ptr - 1] | (u->rst.dat[u->rst.ptr - 2] << 8)); u->rst.dat[u->rst.ptr - 2] = peek8(u->ram.dat, a); @@ -798,7 +1281,7 @@ uxn_eval(Uxn *u, Uint16 vec) u->rst.ptr -= 1; } break; - case 0x35: /* STAr */ + case 0x55: /* STAr */ { Uint16 a = (u->rst.dat[u->rst.ptr - 1] | (u->rst.dat[u->rst.ptr - 2] << 8)); Uint8 b = u->rst.dat[u->rst.ptr - 3]; @@ -812,7 +1295,7 @@ uxn_eval(Uxn *u, Uint16 vec) u->rst.ptr -= 3; } break; - case 0x36: /* DEIr */ + case 0x56: /* DEIr */ { Uint8 a = u->rst.dat[u->rst.ptr - 1]; u->rst.dat[u->rst.ptr - 1] = devr8(&u->dev[a >> 4], a); @@ -824,7 +1307,7 @@ uxn_eval(Uxn *u, Uint16 vec) #endif } break; - case 0x37: /* DEOr */ + case 0x57: /* DEOr */ { Uint8 a = u->rst.dat[u->rst.ptr - 1], b = u->rst.dat[u->rst.ptr - 2]; devw8(&u->dev[a >> 4], a, b); @@ -837,7 +1320,7 @@ uxn_eval(Uxn *u, Uint16 vec) u->rst.ptr -= 2; } break; - case 0x38: /* ADDr */ + case 0x58: /* ADDr */ { Uint8 a = u->rst.dat[u->rst.ptr - 1], b = u->rst.dat[u->rst.ptr - 2]; u->rst.dat[u->rst.ptr - 2] = b + a; @@ -850,7 +1333,7 @@ uxn_eval(Uxn *u, Uint16 vec) u->rst.ptr -= 1; } break; - case 0x39: /* SUBr */ + case 0x59: /* SUBr */ { Uint8 a = u->rst.dat[u->rst.ptr - 1], b = u->rst.dat[u->rst.ptr - 2]; u->rst.dat[u->rst.ptr - 2] = b - a; @@ -863,7 +1346,7 @@ uxn_eval(Uxn *u, Uint16 vec) u->rst.ptr -= 1; } break; - case 0x3a: /* MULr */ + case 0x5a: /* MULr */ { Uint8 a = u->rst.dat[u->rst.ptr - 1], b = u->rst.dat[u->rst.ptr - 2]; u->rst.dat[u->rst.ptr - 2] = b * a; @@ -876,7 +1359,7 @@ uxn_eval(Uxn *u, Uint16 vec) u->rst.ptr -= 1; } break; - case 0x3b: /* DIVr */ + case 0x5b: /* DIVr */ { Uint8 a = u->rst.dat[u->rst.ptr - 1], b = u->rst.dat[u->rst.ptr - 2]; if(a == 0) { @@ -896,7 +1379,7 @@ uxn_eval(Uxn *u, Uint16 vec) u->rst.ptr -= 1; } break; - case 0x3c: /* ANDr */ + case 0x5c: /* ANDr */ { Uint8 a = u->rst.dat[u->rst.ptr - 1], b = u->rst.dat[u->rst.ptr - 2]; u->rst.dat[u->rst.ptr - 2] = b & a; @@ -909,7 +1392,7 @@ uxn_eval(Uxn *u, Uint16 vec) u->rst.ptr -= 1; } break; - case 0x3d: /* ORAr */ + case 0x5d: /* ORAr */ { Uint8 a = u->rst.dat[u->rst.ptr - 1], b = u->rst.dat[u->rst.ptr - 2]; u->rst.dat[u->rst.ptr - 2] = b | a; @@ -922,7 +1405,7 @@ uxn_eval(Uxn *u, Uint16 vec) u->rst.ptr -= 1; } break; - case 0x3e: /* EORr */ + case 0x5e: /* EORr */ { Uint8 a = u->rst.dat[u->rst.ptr - 1], b = u->rst.dat[u->rst.ptr - 2]; u->rst.dat[u->rst.ptr - 2] = b ^ a; @@ -935,7 +1418,7 @@ uxn_eval(Uxn *u, Uint16 vec) u->rst.ptr -= 1; } break; - case 0x3f: /* SFTr */ + case 0x5f: /* SFTr */ { Uint8 a = u->rst.dat[u->rst.ptr - 1], b = u->rst.dat[u->rst.ptr - 2]; u->rst.dat[u->rst.ptr - 2] = b >> (a & 0x07) << ((a & 0x70) >> 4); @@ -948,490 +1431,6 @@ uxn_eval(Uxn *u, Uint16 vec) u->rst.ptr -= 1; } break; - case 0x40: /* LIT2 */ - case 0xc0: /* LIT2k */ - { - u->wst.dat[u->wst.ptr] = peek8(u->ram.dat, u->ram.ptr++); - u->wst.dat[u->wst.ptr + 1] = peek8(u->ram.dat, u->ram.ptr++); -#ifndef NO_STACK_CHECKS - if(__builtin_expect(u->wst.ptr > 253, 0)) { - u->wst.error = 2; - goto error; - } -#endif - u->wst.ptr += 2; - } - break; - case 0x41: /* INC2 */ - { - Uint16 a = (u->wst.dat[u->wst.ptr - 1] | (u->wst.dat[u->wst.ptr - 2] << 8)); - u->wst.dat[u->wst.ptr - 2] = (a + 1) >> 8; - u->wst.dat[u->wst.ptr - 1] = (a + 1) & 0xff; -#ifndef NO_STACK_CHECKS - if(__builtin_expect(u->wst.ptr < 2, 0)) { - u->wst.error = 1; - goto error; - } -#endif - } - break; - case 0x42: /* POP2 */ - { - (u->wst.dat[u->wst.ptr - 1] | (u->wst.dat[u->wst.ptr - 2] << 8)); -#ifndef NO_STACK_CHECKS - if(__builtin_expect(u->wst.ptr < 2, 0)) { - u->wst.error = 1; - goto error; - } -#endif - u->wst.ptr -= 2; - } - break; - case 0x43: /* DUP2 */ - { - Uint8 a = u->wst.dat[u->wst.ptr - 1], b = u->wst.dat[u->wst.ptr - 2]; - u->wst.dat[u->wst.ptr] = b; - u->wst.dat[u->wst.ptr + 1] = a; -#ifndef NO_STACK_CHECKS - if(__builtin_expect(u->wst.ptr < 2, 0)) { - u->wst.error = 1; - goto error; - } - if(__builtin_expect(u->wst.ptr > 253, 0)) { - u->wst.error = 2; - goto error; - } -#endif - u->wst.ptr += 2; - } - break; - case 0x44: /* NIP2 */ - { - Uint16 a = (u->wst.dat[u->wst.ptr - 1] | (u->wst.dat[u->wst.ptr - 2] << 8)); - (u->wst.dat[u->wst.ptr - 3] | (u->wst.dat[u->wst.ptr - 4] << 8)); - u->wst.dat[u->wst.ptr - 4] = a >> 8; - u->wst.dat[u->wst.ptr - 3] = a & 0xff; -#ifndef NO_STACK_CHECKS - if(__builtin_expect(u->wst.ptr < 4, 0)) { - u->wst.error = 1; - goto error; - } -#endif - u->wst.ptr -= 2; - } - break; - case 0x45: /* SWP2 */ - { - Uint8 a = u->wst.dat[u->wst.ptr - 1], b = u->wst.dat[u->wst.ptr - 2], c = u->wst.dat[u->wst.ptr - 3], d = u->wst.dat[u->wst.ptr - 4]; - u->wst.dat[u->wst.ptr - 4] = b; - u->wst.dat[u->wst.ptr - 3] = a; - u->wst.dat[u->wst.ptr - 2] = d; - u->wst.dat[u->wst.ptr - 1] = c; -#ifndef NO_STACK_CHECKS - if(__builtin_expect(u->wst.ptr < 4, 0)) { - u->wst.error = 1; - goto error; - } -#endif - } - break; - case 0x46: /* OVR2 */ - { - Uint8 a = u->wst.dat[u->wst.ptr - 1], b = u->wst.dat[u->wst.ptr - 2], c = u->wst.dat[u->wst.ptr - 3], d = u->wst.dat[u->wst.ptr - 4]; - u->wst.dat[u->wst.ptr] = d; - u->wst.dat[u->wst.ptr + 1] = c; -#ifndef NO_STACK_CHECKS - if(__builtin_expect(u->wst.ptr < 4, 0)) { - u->wst.error = 1; - goto error; - } - if(__builtin_expect(u->wst.ptr > 253, 0)) { - u->wst.error = 2; - goto error; - } -#endif - u->wst.ptr += 2; - } - break; - case 0x47: /* ROT2 */ - { - Uint8 a = u->wst.dat[u->wst.ptr - 1], b = u->wst.dat[u->wst.ptr - 2], c = u->wst.dat[u->wst.ptr - 3], d = u->wst.dat[u->wst.ptr - 4], e = u->wst.dat[u->wst.ptr - 5], f = u->wst.dat[u->wst.ptr - 6]; - u->wst.dat[u->wst.ptr - 6] = d; - u->wst.dat[u->wst.ptr - 5] = c; - u->wst.dat[u->wst.ptr - 4] = b; - u->wst.dat[u->wst.ptr - 3] = a; - u->wst.dat[u->wst.ptr - 2] = f; - u->wst.dat[u->wst.ptr - 1] = e; -#ifndef NO_STACK_CHECKS - if(__builtin_expect(u->wst.ptr < 6, 0)) { - u->wst.error = 1; - goto error; - } -#endif - } - break; - case 0x48: /* EQU2 */ - { - Uint16 a = (u->wst.dat[u->wst.ptr - 1] | (u->wst.dat[u->wst.ptr - 2] << 8)), b = (u->wst.dat[u->wst.ptr - 3] | (u->wst.dat[u->wst.ptr - 4] << 8)); - u->wst.dat[u->wst.ptr - 4] = b == a; -#ifndef NO_STACK_CHECKS - if(__builtin_expect(u->wst.ptr < 4, 0)) { - u->wst.error = 1; - goto error; - } -#endif - u->wst.ptr -= 3; - } - break; - case 0x49: /* NEQ2 */ - { - Uint16 a = (u->wst.dat[u->wst.ptr - 1] | (u->wst.dat[u->wst.ptr - 2] << 8)), b = (u->wst.dat[u->wst.ptr - 3] | (u->wst.dat[u->wst.ptr - 4] << 8)); - u->wst.dat[u->wst.ptr - 4] = b != a; -#ifndef NO_STACK_CHECKS - if(__builtin_expect(u->wst.ptr < 4, 0)) { - u->wst.error = 1; - goto error; - } -#endif - u->wst.ptr -= 3; - } - break; - case 0x4a: /* GTH2 */ - { - Uint16 a = (u->wst.dat[u->wst.ptr - 1] | (u->wst.dat[u->wst.ptr - 2] << 8)), b = (u->wst.dat[u->wst.ptr - 3] | (u->wst.dat[u->wst.ptr - 4] << 8)); - u->wst.dat[u->wst.ptr - 4] = b > a; -#ifndef NO_STACK_CHECKS - if(__builtin_expect(u->wst.ptr < 4, 0)) { - u->wst.error = 1; - goto error; - } -#endif - u->wst.ptr -= 3; - } - break; - case 0x4b: /* LTH2 */ - { - Uint16 a = (u->wst.dat[u->wst.ptr - 1] | (u->wst.dat[u->wst.ptr - 2] << 8)), b = (u->wst.dat[u->wst.ptr - 3] | (u->wst.dat[u->wst.ptr - 4] << 8)); - u->wst.dat[u->wst.ptr - 4] = b < a; -#ifndef NO_STACK_CHECKS - if(__builtin_expect(u->wst.ptr < 4, 0)) { - u->wst.error = 1; - goto error; - } -#endif - u->wst.ptr -= 3; - } - break; - case 0x4c: /* JMP2 */ - { - u->ram.ptr = (u->wst.dat[u->wst.ptr - 1] | (u->wst.dat[u->wst.ptr - 2] << 8)); -#ifndef NO_STACK_CHECKS - if(__builtin_expect(u->wst.ptr < 2, 0)) { - u->wst.error = 1; - goto error; - } -#endif - u->wst.ptr -= 2; - } - break; - case 0x4d: /* JCN2 */ - { - Uint16 a = (u->wst.dat[u->wst.ptr - 1] | (u->wst.dat[u->wst.ptr - 2] << 8)); - if(u->wst.dat[u->wst.ptr - 3]) u->ram.ptr = a; -#ifndef NO_STACK_CHECKS - if(__builtin_expect(u->wst.ptr < 3, 0)) { - u->wst.error = 1; - goto error; - } -#endif - u->wst.ptr -= 3; - } - break; - case 0x4e: /* JSR2 */ - { - u->rst.dat[u->rst.ptr] = u->ram.ptr >> 8; - u->rst.dat[u->rst.ptr + 1] = u->ram.ptr & 0xff; - u->ram.ptr = (u->wst.dat[u->wst.ptr - 1] | (u->wst.dat[u->wst.ptr - 2] << 8)); -#ifndef NO_STACK_CHECKS - if(__builtin_expect(u->wst.ptr < 2, 0)) { - u->wst.error = 1; - goto error; - } -#endif - u->wst.ptr -= 2; -#ifndef NO_STACK_CHECKS - if(__builtin_expect(u->rst.ptr > 253, 0)) { - u->rst.error = 2; - goto error; - } -#endif - u->rst.ptr += 2; - } - break; - case 0x4f: /* STH2 */ - { - Uint8 a = u->wst.dat[u->wst.ptr - 1], b = u->wst.dat[u->wst.ptr - 2]; - u->rst.dat[u->rst.ptr] = b; - u->rst.dat[u->rst.ptr + 1] = a; -#ifndef NO_STACK_CHECKS - if(__builtin_expect(u->wst.ptr < 2, 0)) { - u->wst.error = 1; - goto error; - } -#endif - u->wst.ptr -= 2; -#ifndef NO_STACK_CHECKS - if(__builtin_expect(u->rst.ptr > 253, 0)) { - u->rst.error = 2; - goto error; - } -#endif - u->rst.ptr += 2; - } - break; - case 0x50: /* LDZ2 */ - { - Uint8 a = u->wst.dat[u->wst.ptr - 1]; - u->wst.dat[u->wst.ptr - 1] = peek8(u->ram.dat, a); - u->wst.dat[u->wst.ptr] = peek8(u->ram.dat, a + 1); -#ifndef NO_STACK_CHECKS - if(__builtin_expect(u->wst.ptr < 1, 0)) { - u->wst.error = 1; - goto error; - } - if(__builtin_expect(u->wst.ptr > 254, 0)) { - u->wst.error = 2; - goto error; - } -#endif - u->wst.ptr += 1; - } - break; - case 0x51: /* STZ2 */ - { - Uint8 a = u->wst.dat[u->wst.ptr - 1]; - Uint16 b = (u->wst.dat[u->wst.ptr - 2] | (u->wst.dat[u->wst.ptr - 3] << 8)); - poke16(u->ram.dat, a, b); -#ifndef NO_STACK_CHECKS - if(__builtin_expect(u->wst.ptr < 3, 0)) { - u->wst.error = 1; - goto error; - } -#endif - u->wst.ptr -= 3; - } - break; - case 0x52: /* LDR2 */ - { - Uint8 a = u->wst.dat[u->wst.ptr - 1]; - u->wst.dat[u->wst.ptr - 1] = peek8(u->ram.dat, u->ram.ptr + (Sint8)a); - u->wst.dat[u->wst.ptr] = peek8(u->ram.dat, u->ram.ptr + (Sint8)a + 1); -#ifndef NO_STACK_CHECKS - if(__builtin_expect(u->wst.ptr < 1, 0)) { - u->wst.error = 1; - goto error; - } - if(__builtin_expect(u->wst.ptr > 254, 0)) { - u->wst.error = 2; - goto error; - } -#endif - u->wst.ptr += 1; - } - break; - case 0x53: /* STR2 */ - { - Uint8 a = u->wst.dat[u->wst.ptr - 1]; - Uint16 b = (u->wst.dat[u->wst.ptr - 2] | (u->wst.dat[u->wst.ptr - 3] << 8)); - poke16(u->ram.dat, u->ram.ptr + (Sint8)a, b); -#ifndef NO_STACK_CHECKS - if(__builtin_expect(u->wst.ptr < 3, 0)) { - u->wst.error = 1; - goto error; - } -#endif - u->wst.ptr -= 3; - } - break; - case 0x54: /* LDA2 */ - { - Uint16 a = (u->wst.dat[u->wst.ptr - 1] | (u->wst.dat[u->wst.ptr - 2] << 8)); - u->wst.dat[u->wst.ptr - 2] = peek8(u->ram.dat, a); - u->wst.dat[u->wst.ptr - 1] = peek8(u->ram.dat, a + 1); -#ifndef NO_STACK_CHECKS - if(__builtin_expect(u->wst.ptr < 2, 0)) { - u->wst.error = 1; - goto error; - } -#endif - } - break; - case 0x55: /* STA2 */ - { - Uint16 a = (u->wst.dat[u->wst.ptr - 1] | (u->wst.dat[u->wst.ptr - 2] << 8)); - Uint16 b = (u->wst.dat[u->wst.ptr - 3] | (u->wst.dat[u->wst.ptr - 4] << 8)); - poke16(u->ram.dat, a, b); -#ifndef NO_STACK_CHECKS - if(__builtin_expect(u->wst.ptr < 4, 0)) { - u->wst.error = 1; - goto error; - } -#endif - u->wst.ptr -= 4; - } - break; - case 0x56: /* DEI2 */ - { - Uint8 a = u->wst.dat[u->wst.ptr - 1]; - u->wst.dat[u->wst.ptr - 1] = devr8(&u->dev[a >> 4], a); - u->wst.dat[u->wst.ptr] = devr8(&u->dev[a >> 4], a + 1); -#ifndef NO_STACK_CHECKS - if(__builtin_expect(u->wst.ptr < 1, 0)) { - u->wst.error = 1; - goto error; - } - if(__builtin_expect(u->wst.ptr > 254, 0)) { - u->wst.error = 2; - goto error; - } -#endif - u->wst.ptr += 1; - } - break; - case 0x57: /* DEO2 */ - { - Uint8 a = u->wst.dat[u->wst.ptr - 1]; - Uint16 b = (u->wst.dat[u->wst.ptr - 2] | (u->wst.dat[u->wst.ptr - 3] << 8)); - devw16(&u->dev[a >> 4], a, b); -#ifndef NO_STACK_CHECKS - if(__builtin_expect(u->wst.ptr < 3, 0)) { - u->wst.error = 1; - goto error; - } -#endif - u->wst.ptr -= 3; - } - break; - case 0x58: /* ADD2 */ - { - Uint16 a = (u->wst.dat[u->wst.ptr - 1] | (u->wst.dat[u->wst.ptr - 2] << 8)), b = (u->wst.dat[u->wst.ptr - 3] | (u->wst.dat[u->wst.ptr - 4] << 8)); - u->wst.dat[u->wst.ptr - 4] = (b + a) >> 8; - u->wst.dat[u->wst.ptr - 3] = (b + a) & 0xff; -#ifndef NO_STACK_CHECKS - if(__builtin_expect(u->wst.ptr < 4, 0)) { - u->wst.error = 1; - goto error; - } -#endif - u->wst.ptr -= 2; - } - break; - case 0x59: /* SUB2 */ - { - Uint16 a = (u->wst.dat[u->wst.ptr - 1] | (u->wst.dat[u->wst.ptr - 2] << 8)), b = (u->wst.dat[u->wst.ptr - 3] | (u->wst.dat[u->wst.ptr - 4] << 8)); - u->wst.dat[u->wst.ptr - 4] = (b - a) >> 8; - u->wst.dat[u->wst.ptr - 3] = (b - a) & 0xff; -#ifndef NO_STACK_CHECKS - if(__builtin_expect(u->wst.ptr < 4, 0)) { - u->wst.error = 1; - goto error; - } -#endif - u->wst.ptr -= 2; - } - break; - case 0x5a: /* MUL2 */ - { - Uint16 a = (u->wst.dat[u->wst.ptr - 1] | (u->wst.dat[u->wst.ptr - 2] << 8)), b = (u->wst.dat[u->wst.ptr - 3] | (u->wst.dat[u->wst.ptr - 4] << 8)); - u->wst.dat[u->wst.ptr - 4] = (b * a) >> 8; - u->wst.dat[u->wst.ptr - 3] = (b * a) & 0xff; -#ifndef NO_STACK_CHECKS - if(__builtin_expect(u->wst.ptr < 4, 0)) { - u->wst.error = 1; - goto error; - } -#endif - u->wst.ptr -= 2; - } - break; - case 0x5b: /* DIV2 */ - { - Uint16 a = (u->wst.dat[u->wst.ptr - 1] | (u->wst.dat[u->wst.ptr - 2] << 8)), b = (u->wst.dat[u->wst.ptr - 3] | (u->wst.dat[u->wst.ptr - 4] << 8)); - if(a == 0) { - u->wst.error = 3; -#ifndef NO_STACK_CHECKS - goto error; -#endif - a = 1; - } - u->wst.dat[u->wst.ptr - 4] = (b / a) >> 8; - u->wst.dat[u->wst.ptr - 3] = (b / a) & 0xff; -#ifndef NO_STACK_CHECKS - if(__builtin_expect(u->wst.ptr < 4, 0)) { - u->wst.error = 1; - goto error; - } -#endif - u->wst.ptr -= 2; - } - break; - case 0x5c: /* AND2 */ - { - Uint8 a = u->wst.dat[u->wst.ptr - 1], b = u->wst.dat[u->wst.ptr - 2], c = u->wst.dat[u->wst.ptr - 3], d = u->wst.dat[u->wst.ptr - 4]; - u->wst.dat[u->wst.ptr - 4] = d & b; - u->wst.dat[u->wst.ptr - 3] = c & a; -#ifndef NO_STACK_CHECKS - if(__builtin_expect(u->wst.ptr < 4, 0)) { - u->wst.error = 1; - goto error; - } -#endif - u->wst.ptr -= 2; - } - break; - case 0x5d: /* ORA2 */ - { - Uint8 a = u->wst.dat[u->wst.ptr - 1], b = u->wst.dat[u->wst.ptr - 2], c = u->wst.dat[u->wst.ptr - 3], d = u->wst.dat[u->wst.ptr - 4]; - u->wst.dat[u->wst.ptr - 4] = d | b; - u->wst.dat[u->wst.ptr - 3] = c | a; -#ifndef NO_STACK_CHECKS - if(__builtin_expect(u->wst.ptr < 4, 0)) { - u->wst.error = 1; - goto error; - } -#endif - u->wst.ptr -= 2; - } - break; - case 0x5e: /* EOR2 */ - { - Uint8 a = u->wst.dat[u->wst.ptr - 1], b = u->wst.dat[u->wst.ptr - 2], c = u->wst.dat[u->wst.ptr - 3], d = u->wst.dat[u->wst.ptr - 4]; - u->wst.dat[u->wst.ptr - 4] = d ^ b; - u->wst.dat[u->wst.ptr - 3] = c ^ a; -#ifndef NO_STACK_CHECKS - if(__builtin_expect(u->wst.ptr < 4, 0)) { - u->wst.error = 1; - goto error; - } -#endif - u->wst.ptr -= 2; - } - break; - case 0x5f: /* SFT2 */ - { - Uint8 a = u->wst.dat[u->wst.ptr - 1]; - Uint16 b = (u->wst.dat[u->wst.ptr - 2] | (u->wst.dat[u->wst.ptr - 3] << 8)); - u->wst.dat[u->wst.ptr - 3] = (b >> (a & 0x0f) << ((a & 0xf0) >> 4)) >> 8; - u->wst.dat[u->wst.ptr - 2] = (b >> (a & 0x0f) << ((a & 0xf0) >> 4)) & 0xff; -#ifndef NO_STACK_CHECKS - if(__builtin_expect(u->wst.ptr < 3, 0)) { - u->wst.error = 1; - goto error; - } -#endif - u->wst.ptr -= 1; - } - break; case 0x60: /* LIT2r */ case 0xe0: /* LIT2kr */ { @@ -2426,517 +2425,7 @@ uxn_eval(Uxn *u, Uint16 vec) u->wst.ptr += 1; } break; - case 0xa1: /* INCkr */ - { - Uint8 a = u->rst.dat[u->rst.ptr - 1]; - u->rst.dat[u->rst.ptr] = a + 1; -#ifndef NO_STACK_CHECKS - if(__builtin_expect(u->rst.ptr < 1, 0)) { - u->rst.error = 1; - goto error; - } - if(__builtin_expect(u->rst.ptr > 254, 0)) { - u->rst.error = 2; - goto error; - } -#endif - u->rst.ptr += 1; - } - break; - case 0xa2: /* POPkr */ - { - u->rst.dat[u->rst.ptr - 1]; -#ifndef NO_STACK_CHECKS - if(__builtin_expect(u->rst.ptr < 1, 0)) { - u->rst.error = 1; - goto error; - } -#endif - } - break; - case 0xa3: /* DUPkr */ - { - Uint8 a = u->rst.dat[u->rst.ptr - 1]; - u->rst.dat[u->rst.ptr] = a; - u->rst.dat[u->rst.ptr + 1] = a; -#ifndef NO_STACK_CHECKS - if(__builtin_expect(u->rst.ptr < 1, 0)) { - u->rst.error = 1; - goto error; - } - if(__builtin_expect(u->rst.ptr > 253, 0)) { - u->rst.error = 2; - goto error; - } -#endif - u->rst.ptr += 2; - } - break; - case 0xa4: /* NIPkr */ - { - Uint8 a = u->rst.dat[u->rst.ptr - 1]; - u->rst.dat[u->rst.ptr - 2]; - u->rst.dat[u->rst.ptr] = a; -#ifndef NO_STACK_CHECKS - if(__builtin_expect(u->rst.ptr < 2, 0)) { - u->rst.error = 1; - goto error; - } - if(__builtin_expect(u->rst.ptr > 254, 0)) { - u->rst.error = 2; - goto error; - } -#endif - u->rst.ptr += 1; - } - break; - case 0xa5: /* SWPkr */ - { - Uint8 a = u->rst.dat[u->rst.ptr - 1], b = u->rst.dat[u->rst.ptr - 2]; - u->rst.dat[u->rst.ptr] = a; - u->rst.dat[u->rst.ptr + 1] = b; -#ifndef NO_STACK_CHECKS - if(__builtin_expect(u->rst.ptr < 2, 0)) { - u->rst.error = 1; - goto error; - } - if(__builtin_expect(u->rst.ptr > 253, 0)) { - u->rst.error = 2; - goto error; - } -#endif - u->rst.ptr += 2; - } - break; - case 0xa6: /* OVRkr */ - { - Uint8 a = u->rst.dat[u->rst.ptr - 1], b = u->rst.dat[u->rst.ptr - 2]; - u->rst.dat[u->rst.ptr] = b; - u->rst.dat[u->rst.ptr + 1] = a; - u->rst.dat[u->rst.ptr + 2] = b; -#ifndef NO_STACK_CHECKS - if(__builtin_expect(u->rst.ptr < 2, 0)) { - u->rst.error = 1; - goto error; - } - if(__builtin_expect(u->rst.ptr > 252, 0)) { - u->rst.error = 2; - goto error; - } -#endif - u->rst.ptr += 3; - } - break; - case 0xa7: /* ROTkr */ - { - Uint8 a = u->rst.dat[u->rst.ptr - 1], b = u->rst.dat[u->rst.ptr - 2], c = u->rst.dat[u->rst.ptr - 3]; - u->rst.dat[u->rst.ptr] = b; - u->rst.dat[u->rst.ptr + 1] = a; - u->rst.dat[u->rst.ptr + 2] = c; -#ifndef NO_STACK_CHECKS - if(__builtin_expect(u->rst.ptr < 3, 0)) { - u->rst.error = 1; - goto error; - } - if(__builtin_expect(u->rst.ptr > 252, 0)) { - u->rst.error = 2; - goto error; - } -#endif - u->rst.ptr += 3; - } - break; - case 0xa8: /* EQUkr */ - { - Uint8 a = u->rst.dat[u->rst.ptr - 1], b = u->rst.dat[u->rst.ptr - 2]; - u->rst.dat[u->rst.ptr] = b == a; -#ifndef NO_STACK_CHECKS - if(__builtin_expect(u->rst.ptr < 2, 0)) { - u->rst.error = 1; - goto error; - } - if(__builtin_expect(u->rst.ptr > 254, 0)) { - u->rst.error = 2; - goto error; - } -#endif - u->rst.ptr += 1; - } - break; - case 0xa9: /* NEQkr */ - { - Uint8 a = u->rst.dat[u->rst.ptr - 1], b = u->rst.dat[u->rst.ptr - 2]; - u->rst.dat[u->rst.ptr] = b != a; -#ifndef NO_STACK_CHECKS - if(__builtin_expect(u->rst.ptr < 2, 0)) { - u->rst.error = 1; - goto error; - } - if(__builtin_expect(u->rst.ptr > 254, 0)) { - u->rst.error = 2; - goto error; - } -#endif - u->rst.ptr += 1; - } - break; - case 0xaa: /* GTHkr */ - { - Uint8 a = u->rst.dat[u->rst.ptr - 1], b = u->rst.dat[u->rst.ptr - 2]; - u->rst.dat[u->rst.ptr] = b > a; -#ifndef NO_STACK_CHECKS - if(__builtin_expect(u->rst.ptr < 2, 0)) { - u->rst.error = 1; - goto error; - } - if(__builtin_expect(u->rst.ptr > 254, 0)) { - u->rst.error = 2; - goto error; - } -#endif - u->rst.ptr += 1; - } - break; - case 0xab: /* LTHkr */ - { - Uint8 a = u->rst.dat[u->rst.ptr - 1], b = u->rst.dat[u->rst.ptr - 2]; - u->rst.dat[u->rst.ptr] = b < a; -#ifndef NO_STACK_CHECKS - if(__builtin_expect(u->rst.ptr < 2, 0)) { - u->rst.error = 1; - goto error; - } - if(__builtin_expect(u->rst.ptr > 254, 0)) { - u->rst.error = 2; - goto error; - } -#endif - u->rst.ptr += 1; - } - break; - case 0xac: /* JMPkr */ - { - Uint8 a = u->rst.dat[u->rst.ptr - 1]; - u->ram.ptr += (Sint8)a; -#ifndef NO_STACK_CHECKS - if(__builtin_expect(u->rst.ptr < 1, 0)) { - u->rst.error = 1; - goto error; - } -#endif - } - break; - case 0xad: /* JCNkr */ - { - Uint8 a = u->rst.dat[u->rst.ptr - 1]; - if(u->rst.dat[u->rst.ptr - 2]) u->ram.ptr += (Sint8)a; -#ifndef NO_STACK_CHECKS - if(__builtin_expect(u->rst.ptr < 2, 0)) { - u->rst.error = 1; - goto error; - } -#endif - } - break; - case 0xae: /* JSRkr */ - { - Uint8 a = u->rst.dat[u->rst.ptr - 1]; - u->wst.dat[u->wst.ptr] = u->ram.ptr >> 8; - u->wst.dat[u->wst.ptr + 1] = u->ram.ptr & 0xff; - u->ram.ptr += (Sint8)a; -#ifndef NO_STACK_CHECKS - if(__builtin_expect(u->rst.ptr < 1, 0)) { - u->rst.error = 1; - goto error; - } - if(__builtin_expect(u->wst.ptr > 253, 0)) { - u->wst.error = 2; - goto error; - } -#endif - u->wst.ptr += 2; - } - break; - case 0xaf: /* STHkr */ - { - Uint8 a = u->rst.dat[u->rst.ptr - 1]; - u->wst.dat[u->wst.ptr] = a; -#ifndef NO_STACK_CHECKS - if(__builtin_expect(u->rst.ptr < 1, 0)) { - u->rst.error = 1; - goto error; - } - if(__builtin_expect(u->wst.ptr > 254, 0)) { - u->wst.error = 2; - goto error; - } -#endif - u->wst.ptr += 1; - } - break; - case 0xb0: /* LDZkr */ - { - Uint8 a = u->rst.dat[u->rst.ptr - 1]; - u->rst.dat[u->rst.ptr] = peek8(u->ram.dat, a); -#ifndef NO_STACK_CHECKS - if(__builtin_expect(u->rst.ptr < 1, 0)) { - u->rst.error = 1; - goto error; - } - if(__builtin_expect(u->rst.ptr > 254, 0)) { - u->rst.error = 2; - goto error; - } -#endif - u->rst.ptr += 1; - } - break; - case 0xb1: /* STZkr */ - { - Uint8 a = u->rst.dat[u->rst.ptr - 1]; - Uint8 b = u->rst.dat[u->rst.ptr - 2]; - poke8(u->ram.dat, a, b); -#ifndef NO_STACK_CHECKS - if(__builtin_expect(u->rst.ptr < 2, 0)) { - u->rst.error = 1; - goto error; - } -#endif - } - break; - case 0xb2: /* LDRkr */ - { - Uint8 a = u->rst.dat[u->rst.ptr - 1]; - u->rst.dat[u->rst.ptr] = peek8(u->ram.dat, u->ram.ptr + (Sint8)a); -#ifndef NO_STACK_CHECKS - if(__builtin_expect(u->rst.ptr < 1, 0)) { - u->rst.error = 1; - goto error; - } - if(__builtin_expect(u->rst.ptr > 254, 0)) { - u->rst.error = 2; - goto error; - } -#endif - u->rst.ptr += 1; - } - break; - case 0xb3: /* STRkr */ - { - Uint8 a = u->rst.dat[u->rst.ptr - 1]; - Uint8 b = u->rst.dat[u->rst.ptr - 2]; - poke8(u->ram.dat, u->ram.ptr + (Sint8)a, b); -#ifndef NO_STACK_CHECKS - if(__builtin_expect(u->rst.ptr < 2, 0)) { - u->rst.error = 1; - goto error; - } -#endif - } - break; - case 0xb4: /* LDAkr */ - { - Uint16 a = (u->rst.dat[u->rst.ptr - 1] | (u->rst.dat[u->rst.ptr - 2] << 8)); - u->rst.dat[u->rst.ptr] = peek8(u->ram.dat, a); -#ifndef NO_STACK_CHECKS - if(__builtin_expect(u->rst.ptr < 2, 0)) { - u->rst.error = 1; - goto error; - } - if(__builtin_expect(u->rst.ptr > 254, 0)) { - u->rst.error = 2; - goto error; - } -#endif - u->rst.ptr += 1; - } - break; - case 0xb5: /* STAkr */ - { - Uint16 a = (u->rst.dat[u->rst.ptr - 1] | (u->rst.dat[u->rst.ptr - 2] << 8)); - Uint8 b = u->rst.dat[u->rst.ptr - 3]; - poke8(u->ram.dat, a, b); -#ifndef NO_STACK_CHECKS - if(__builtin_expect(u->rst.ptr < 3, 0)) { - u->rst.error = 1; - goto error; - } -#endif - } - break; - case 0xb6: /* DEIkr */ - { - Uint8 a = u->rst.dat[u->rst.ptr - 1]; - u->rst.dat[u->rst.ptr] = devr8(&u->dev[a >> 4], a); -#ifndef NO_STACK_CHECKS - if(__builtin_expect(u->rst.ptr < 1, 0)) { - u->rst.error = 1; - goto error; - } - if(__builtin_expect(u->rst.ptr > 254, 0)) { - u->rst.error = 2; - goto error; - } -#endif - u->rst.ptr += 1; - } - break; - case 0xb7: /* DEOkr */ - { - Uint8 a = u->rst.dat[u->rst.ptr - 1], b = u->rst.dat[u->rst.ptr - 2]; - devw8(&u->dev[a >> 4], a, b); -#ifndef NO_STACK_CHECKS - if(__builtin_expect(u->rst.ptr < 2, 0)) { - u->rst.error = 1; - goto error; - } -#endif - } - break; - case 0xb8: /* ADDkr */ - { - Uint8 a = u->rst.dat[u->rst.ptr - 1], b = u->rst.dat[u->rst.ptr - 2]; - u->rst.dat[u->rst.ptr] = b + a; -#ifndef NO_STACK_CHECKS - if(__builtin_expect(u->rst.ptr < 2, 0)) { - u->rst.error = 1; - goto error; - } - if(__builtin_expect(u->rst.ptr > 254, 0)) { - u->rst.error = 2; - goto error; - } -#endif - u->rst.ptr += 1; - } - break; - case 0xb9: /* SUBkr */ - { - Uint8 a = u->rst.dat[u->rst.ptr - 1], b = u->rst.dat[u->rst.ptr - 2]; - u->rst.dat[u->rst.ptr] = b - a; -#ifndef NO_STACK_CHECKS - if(__builtin_expect(u->rst.ptr < 2, 0)) { - u->rst.error = 1; - goto error; - } - if(__builtin_expect(u->rst.ptr > 254, 0)) { - u->rst.error = 2; - goto error; - } -#endif - u->rst.ptr += 1; - } - break; - case 0xba: /* MULkr */ - { - Uint8 a = u->rst.dat[u->rst.ptr - 1], b = u->rst.dat[u->rst.ptr - 2]; - u->rst.dat[u->rst.ptr] = b * a; -#ifndef NO_STACK_CHECKS - if(__builtin_expect(u->rst.ptr < 2, 0)) { - u->rst.error = 1; - goto error; - } - if(__builtin_expect(u->rst.ptr > 254, 0)) { - u->rst.error = 2; - goto error; - } -#endif - u->rst.ptr += 1; - } - break; - case 0xbb: /* DIVkr */ - { - Uint8 a = u->rst.dat[u->rst.ptr - 1], b = u->rst.dat[u->rst.ptr - 2]; - if(a == 0) { - u->rst.error = 3; -#ifndef NO_STACK_CHECKS - goto error; -#endif - a = 1; - } - u->rst.dat[u->rst.ptr] = b / a; -#ifndef NO_STACK_CHECKS - if(__builtin_expect(u->rst.ptr < 2, 0)) { - u->rst.error = 1; - goto error; - } - if(__builtin_expect(u->rst.ptr > 254, 0)) { - u->rst.error = 2; - goto error; - } -#endif - u->rst.ptr += 1; - } - break; - case 0xbc: /* ANDkr */ - { - Uint8 a = u->rst.dat[u->rst.ptr - 1], b = u->rst.dat[u->rst.ptr - 2]; - u->rst.dat[u->rst.ptr] = b & a; -#ifndef NO_STACK_CHECKS - if(__builtin_expect(u->rst.ptr < 2, 0)) { - u->rst.error = 1; - goto error; - } - if(__builtin_expect(u->rst.ptr > 254, 0)) { - u->rst.error = 2; - goto error; - } -#endif - u->rst.ptr += 1; - } - break; - case 0xbd: /* ORAkr */ - { - Uint8 a = u->rst.dat[u->rst.ptr - 1], b = u->rst.dat[u->rst.ptr - 2]; - u->rst.dat[u->rst.ptr] = b | a; -#ifndef NO_STACK_CHECKS - if(__builtin_expect(u->rst.ptr < 2, 0)) { - u->rst.error = 1; - goto error; - } - if(__builtin_expect(u->rst.ptr > 254, 0)) { - u->rst.error = 2; - goto error; - } -#endif - u->rst.ptr += 1; - } - break; - case 0xbe: /* EORkr */ - { - Uint8 a = u->rst.dat[u->rst.ptr - 1], b = u->rst.dat[u->rst.ptr - 2]; - u->rst.dat[u->rst.ptr] = b ^ a; -#ifndef NO_STACK_CHECKS - if(__builtin_expect(u->rst.ptr < 2, 0)) { - u->rst.error = 1; - goto error; - } - if(__builtin_expect(u->rst.ptr > 254, 0)) { - u->rst.error = 2; - goto error; - } -#endif - u->rst.ptr += 1; - } - break; - case 0xbf: /* SFTkr */ - { - Uint8 a = u->rst.dat[u->rst.ptr - 1], b = u->rst.dat[u->rst.ptr - 2]; - u->rst.dat[u->rst.ptr] = b >> (a & 0x07) << ((a & 0x70) >> 4); -#ifndef NO_STACK_CHECKS - if(__builtin_expect(u->rst.ptr < 2, 0)) { - u->rst.error = 1; - goto error; - } - if(__builtin_expect(u->rst.ptr > 254, 0)) { - u->rst.error = 2; - goto error; - } -#endif - u->rst.ptr += 1; - } - break; - case 0xc1: /* INC2k */ + case 0xa1: /* INC2k */ { Uint16 a = (u->wst.dat[u->wst.ptr - 1] | (u->wst.dat[u->wst.ptr - 2] << 8)); u->wst.dat[u->wst.ptr] = (a + 1) >> 8; @@ -2954,7 +2443,7 @@ uxn_eval(Uxn *u, Uint16 vec) u->wst.ptr += 2; } break; - case 0xc2: /* POP2k */ + case 0xa2: /* POP2k */ { (u->wst.dat[u->wst.ptr - 1] | (u->wst.dat[u->wst.ptr - 2] << 8)); #ifndef NO_STACK_CHECKS @@ -2965,7 +2454,7 @@ uxn_eval(Uxn *u, Uint16 vec) #endif } break; - case 0xc3: /* DUP2k */ + case 0xa3: /* DUP2k */ { Uint8 a = u->wst.dat[u->wst.ptr - 1], b = u->wst.dat[u->wst.ptr - 2]; u->wst.dat[u->wst.ptr] = b; @@ -2985,7 +2474,7 @@ uxn_eval(Uxn *u, Uint16 vec) u->wst.ptr += 4; } break; - case 0xc4: /* NIP2k */ + case 0xa4: /* NIP2k */ { Uint16 a = (u->wst.dat[u->wst.ptr - 1] | (u->wst.dat[u->wst.ptr - 2] << 8)); (u->wst.dat[u->wst.ptr - 3] | (u->wst.dat[u->wst.ptr - 4] << 8)); @@ -3004,7 +2493,7 @@ uxn_eval(Uxn *u, Uint16 vec) u->wst.ptr += 2; } break; - case 0xc5: /* SWP2k */ + case 0xa5: /* SWP2k */ { Uint8 a = u->wst.dat[u->wst.ptr - 1], b = u->wst.dat[u->wst.ptr - 2], c = u->wst.dat[u->wst.ptr - 3], d = u->wst.dat[u->wst.ptr - 4]; u->wst.dat[u->wst.ptr] = b; @@ -3024,7 +2513,7 @@ uxn_eval(Uxn *u, Uint16 vec) u->wst.ptr += 4; } break; - case 0xc6: /* OVR2k */ + case 0xa6: /* OVR2k */ { Uint8 a = u->wst.dat[u->wst.ptr - 1], b = u->wst.dat[u->wst.ptr - 2], c = u->wst.dat[u->wst.ptr - 3], d = u->wst.dat[u->wst.ptr - 4]; u->wst.dat[u->wst.ptr] = d; @@ -3046,7 +2535,7 @@ uxn_eval(Uxn *u, Uint16 vec) u->wst.ptr += 6; } break; - case 0xc7: /* ROT2k */ + case 0xa7: /* ROT2k */ { Uint8 a = u->wst.dat[u->wst.ptr - 1], b = u->wst.dat[u->wst.ptr - 2], c = u->wst.dat[u->wst.ptr - 3], d = u->wst.dat[u->wst.ptr - 4], e = u->wst.dat[u->wst.ptr - 5], f = u->wst.dat[u->wst.ptr - 6]; u->wst.dat[u->wst.ptr] = d; @@ -3068,7 +2557,7 @@ uxn_eval(Uxn *u, Uint16 vec) u->wst.ptr += 6; } break; - case 0xc8: /* EQU2k */ + case 0xa8: /* EQU2k */ { Uint16 a = (u->wst.dat[u->wst.ptr - 1] | (u->wst.dat[u->wst.ptr - 2] << 8)), b = (u->wst.dat[u->wst.ptr - 3] | (u->wst.dat[u->wst.ptr - 4] << 8)); u->wst.dat[u->wst.ptr] = b == a; @@ -3085,7 +2574,7 @@ uxn_eval(Uxn *u, Uint16 vec) u->wst.ptr += 1; } break; - case 0xc9: /* NEQ2k */ + case 0xa9: /* NEQ2k */ { Uint16 a = (u->wst.dat[u->wst.ptr - 1] | (u->wst.dat[u->wst.ptr - 2] << 8)), b = (u->wst.dat[u->wst.ptr - 3] | (u->wst.dat[u->wst.ptr - 4] << 8)); u->wst.dat[u->wst.ptr] = b != a; @@ -3102,7 +2591,7 @@ uxn_eval(Uxn *u, Uint16 vec) u->wst.ptr += 1; } break; - case 0xca: /* GTH2k */ + case 0xaa: /* GTH2k */ { Uint16 a = (u->wst.dat[u->wst.ptr - 1] | (u->wst.dat[u->wst.ptr - 2] << 8)), b = (u->wst.dat[u->wst.ptr - 3] | (u->wst.dat[u->wst.ptr - 4] << 8)); u->wst.dat[u->wst.ptr] = b > a; @@ -3119,7 +2608,7 @@ uxn_eval(Uxn *u, Uint16 vec) u->wst.ptr += 1; } break; - case 0xcb: /* LTH2k */ + case 0xab: /* LTH2k */ { Uint16 a = (u->wst.dat[u->wst.ptr - 1] | (u->wst.dat[u->wst.ptr - 2] << 8)), b = (u->wst.dat[u->wst.ptr - 3] | (u->wst.dat[u->wst.ptr - 4] << 8)); u->wst.dat[u->wst.ptr] = b < a; @@ -3136,7 +2625,7 @@ uxn_eval(Uxn *u, Uint16 vec) u->wst.ptr += 1; } break; - case 0xcc: /* JMP2k */ + case 0xac: /* JMP2k */ { u->ram.ptr = (u->wst.dat[u->wst.ptr - 1] | (u->wst.dat[u->wst.ptr - 2] << 8)); #ifndef NO_STACK_CHECKS @@ -3147,7 +2636,7 @@ uxn_eval(Uxn *u, Uint16 vec) #endif } break; - case 0xcd: /* JCN2k */ + case 0xad: /* JCN2k */ { Uint16 a = (u->wst.dat[u->wst.ptr - 1] | (u->wst.dat[u->wst.ptr - 2] << 8)); if(u->wst.dat[u->wst.ptr - 3]) u->ram.ptr = a; @@ -3159,7 +2648,7 @@ uxn_eval(Uxn *u, Uint16 vec) #endif } break; - case 0xce: /* JSR2k */ + case 0xae: /* JSR2k */ { u->rst.dat[u->rst.ptr] = u->ram.ptr >> 8; u->rst.dat[u->rst.ptr + 1] = u->ram.ptr & 0xff; @@ -3177,7 +2666,7 @@ uxn_eval(Uxn *u, Uint16 vec) u->rst.ptr += 2; } break; - case 0xcf: /* STH2k */ + case 0xaf: /* STH2k */ { Uint8 a = u->wst.dat[u->wst.ptr - 1], b = u->wst.dat[u->wst.ptr - 2]; u->rst.dat[u->rst.ptr] = b; @@ -3195,7 +2684,7 @@ uxn_eval(Uxn *u, Uint16 vec) u->rst.ptr += 2; } break; - case 0xd0: /* LDZ2k */ + case 0xb0: /* LDZ2k */ { Uint8 a = u->wst.dat[u->wst.ptr - 1]; u->wst.dat[u->wst.ptr] = peek8(u->ram.dat, a); @@ -3213,7 +2702,7 @@ uxn_eval(Uxn *u, Uint16 vec) u->wst.ptr += 2; } break; - case 0xd1: /* STZ2k */ + case 0xb1: /* STZ2k */ { Uint8 a = u->wst.dat[u->wst.ptr - 1]; Uint16 b = (u->wst.dat[u->wst.ptr - 2] | (u->wst.dat[u->wst.ptr - 3] << 8)); @@ -3226,7 +2715,7 @@ uxn_eval(Uxn *u, Uint16 vec) #endif } break; - case 0xd2: /* LDR2k */ + case 0xb2: /* LDR2k */ { Uint8 a = u->wst.dat[u->wst.ptr - 1]; u->wst.dat[u->wst.ptr] = peek8(u->ram.dat, u->ram.ptr + (Sint8)a); @@ -3244,7 +2733,7 @@ uxn_eval(Uxn *u, Uint16 vec) u->wst.ptr += 2; } break; - case 0xd3: /* STR2k */ + case 0xb3: /* STR2k */ { Uint8 a = u->wst.dat[u->wst.ptr - 1]; Uint16 b = (u->wst.dat[u->wst.ptr - 2] | (u->wst.dat[u->wst.ptr - 3] << 8)); @@ -3257,7 +2746,7 @@ uxn_eval(Uxn *u, Uint16 vec) #endif } break; - case 0xd4: /* LDA2k */ + case 0xb4: /* LDA2k */ { Uint16 a = (u->wst.dat[u->wst.ptr - 1] | (u->wst.dat[u->wst.ptr - 2] << 8)); u->wst.dat[u->wst.ptr] = peek8(u->ram.dat, a); @@ -3275,7 +2764,7 @@ uxn_eval(Uxn *u, Uint16 vec) u->wst.ptr += 2; } break; - case 0xd5: /* STA2k */ + case 0xb5: /* STA2k */ { Uint16 a = (u->wst.dat[u->wst.ptr - 1] | (u->wst.dat[u->wst.ptr - 2] << 8)); Uint16 b = (u->wst.dat[u->wst.ptr - 3] | (u->wst.dat[u->wst.ptr - 4] << 8)); @@ -3288,7 +2777,7 @@ uxn_eval(Uxn *u, Uint16 vec) #endif } break; - case 0xd6: /* DEI2k */ + case 0xb6: /* DEI2k */ { Uint8 a = u->wst.dat[u->wst.ptr - 1]; u->wst.dat[u->wst.ptr] = devr8(&u->dev[a >> 4], a); @@ -3306,7 +2795,7 @@ uxn_eval(Uxn *u, Uint16 vec) u->wst.ptr += 2; } break; - case 0xd7: /* DEO2k */ + case 0xb7: /* DEO2k */ { Uint8 a = u->wst.dat[u->wst.ptr - 1]; Uint16 b = (u->wst.dat[u->wst.ptr - 2] | (u->wst.dat[u->wst.ptr - 3] << 8)); @@ -3319,7 +2808,7 @@ uxn_eval(Uxn *u, Uint16 vec) #endif } break; - case 0xd8: /* ADD2k */ + case 0xb8: /* ADD2k */ { Uint16 a = (u->wst.dat[u->wst.ptr - 1] | (u->wst.dat[u->wst.ptr - 2] << 8)), b = (u->wst.dat[u->wst.ptr - 3] | (u->wst.dat[u->wst.ptr - 4] << 8)); u->wst.dat[u->wst.ptr] = (b + a) >> 8; @@ -3337,7 +2826,7 @@ uxn_eval(Uxn *u, Uint16 vec) u->wst.ptr += 2; } break; - case 0xd9: /* SUB2k */ + case 0xb9: /* SUB2k */ { Uint16 a = (u->wst.dat[u->wst.ptr - 1] | (u->wst.dat[u->wst.ptr - 2] << 8)), b = (u->wst.dat[u->wst.ptr - 3] | (u->wst.dat[u->wst.ptr - 4] << 8)); u->wst.dat[u->wst.ptr] = (b - a) >> 8; @@ -3355,7 +2844,7 @@ uxn_eval(Uxn *u, Uint16 vec) u->wst.ptr += 2; } break; - case 0xda: /* MUL2k */ + case 0xba: /* MUL2k */ { Uint16 a = (u->wst.dat[u->wst.ptr - 1] | (u->wst.dat[u->wst.ptr - 2] << 8)), b = (u->wst.dat[u->wst.ptr - 3] | (u->wst.dat[u->wst.ptr - 4] << 8)); u->wst.dat[u->wst.ptr] = (b * a) >> 8; @@ -3373,7 +2862,7 @@ uxn_eval(Uxn *u, Uint16 vec) u->wst.ptr += 2; } break; - case 0xdb: /* DIV2k */ + case 0xbb: /* DIV2k */ { Uint16 a = (u->wst.dat[u->wst.ptr - 1] | (u->wst.dat[u->wst.ptr - 2] << 8)), b = (u->wst.dat[u->wst.ptr - 3] | (u->wst.dat[u->wst.ptr - 4] << 8)); if(a == 0) { @@ -3398,7 +2887,7 @@ uxn_eval(Uxn *u, Uint16 vec) u->wst.ptr += 2; } break; - case 0xdc: /* AND2k */ + case 0xbc: /* AND2k */ { Uint8 a = u->wst.dat[u->wst.ptr - 1], b = u->wst.dat[u->wst.ptr - 2], c = u->wst.dat[u->wst.ptr - 3], d = u->wst.dat[u->wst.ptr - 4]; u->wst.dat[u->wst.ptr] = d & b; @@ -3416,7 +2905,7 @@ uxn_eval(Uxn *u, Uint16 vec) u->wst.ptr += 2; } break; - case 0xdd: /* ORA2k */ + case 0xbd: /* ORA2k */ { Uint8 a = u->wst.dat[u->wst.ptr - 1], b = u->wst.dat[u->wst.ptr - 2], c = u->wst.dat[u->wst.ptr - 3], d = u->wst.dat[u->wst.ptr - 4]; u->wst.dat[u->wst.ptr] = d | b; @@ -3434,7 +2923,7 @@ uxn_eval(Uxn *u, Uint16 vec) u->wst.ptr += 2; } break; - case 0xde: /* EOR2k */ + case 0xbe: /* EOR2k */ { Uint8 a = u->wst.dat[u->wst.ptr - 1], b = u->wst.dat[u->wst.ptr - 2], c = u->wst.dat[u->wst.ptr - 3], d = u->wst.dat[u->wst.ptr - 4]; u->wst.dat[u->wst.ptr] = d ^ b; @@ -3452,7 +2941,7 @@ uxn_eval(Uxn *u, Uint16 vec) u->wst.ptr += 2; } break; - case 0xdf: /* SFT2k */ + case 0xbf: /* SFT2k */ { Uint8 a = u->wst.dat[u->wst.ptr - 1]; Uint16 b = (u->wst.dat[u->wst.ptr - 2] | (u->wst.dat[u->wst.ptr - 3] << 8)); @@ -3471,6 +2960,516 @@ uxn_eval(Uxn *u, Uint16 vec) u->wst.ptr += 2; } break; + case 0xc1: /* INCkr */ + { + Uint8 a = u->rst.dat[u->rst.ptr - 1]; + u->rst.dat[u->rst.ptr] = a + 1; +#ifndef NO_STACK_CHECKS + if(__builtin_expect(u->rst.ptr < 1, 0)) { + u->rst.error = 1; + goto error; + } + if(__builtin_expect(u->rst.ptr > 254, 0)) { + u->rst.error = 2; + goto error; + } +#endif + u->rst.ptr += 1; + } + break; + case 0xc2: /* POPkr */ + { + u->rst.dat[u->rst.ptr - 1]; +#ifndef NO_STACK_CHECKS + if(__builtin_expect(u->rst.ptr < 1, 0)) { + u->rst.error = 1; + goto error; + } +#endif + } + break; + case 0xc3: /* DUPkr */ + { + Uint8 a = u->rst.dat[u->rst.ptr - 1]; + u->rst.dat[u->rst.ptr] = a; + u->rst.dat[u->rst.ptr + 1] = a; +#ifndef NO_STACK_CHECKS + if(__builtin_expect(u->rst.ptr < 1, 0)) { + u->rst.error = 1; + goto error; + } + if(__builtin_expect(u->rst.ptr > 253, 0)) { + u->rst.error = 2; + goto error; + } +#endif + u->rst.ptr += 2; + } + break; + case 0xc4: /* NIPkr */ + { + Uint8 a = u->rst.dat[u->rst.ptr - 1]; + u->rst.dat[u->rst.ptr - 2]; + u->rst.dat[u->rst.ptr] = a; +#ifndef NO_STACK_CHECKS + if(__builtin_expect(u->rst.ptr < 2, 0)) { + u->rst.error = 1; + goto error; + } + if(__builtin_expect(u->rst.ptr > 254, 0)) { + u->rst.error = 2; + goto error; + } +#endif + u->rst.ptr += 1; + } + break; + case 0xc5: /* SWPkr */ + { + Uint8 a = u->rst.dat[u->rst.ptr - 1], b = u->rst.dat[u->rst.ptr - 2]; + u->rst.dat[u->rst.ptr] = a; + u->rst.dat[u->rst.ptr + 1] = b; +#ifndef NO_STACK_CHECKS + if(__builtin_expect(u->rst.ptr < 2, 0)) { + u->rst.error = 1; + goto error; + } + if(__builtin_expect(u->rst.ptr > 253, 0)) { + u->rst.error = 2; + goto error; + } +#endif + u->rst.ptr += 2; + } + break; + case 0xc6: /* OVRkr */ + { + Uint8 a = u->rst.dat[u->rst.ptr - 1], b = u->rst.dat[u->rst.ptr - 2]; + u->rst.dat[u->rst.ptr] = b; + u->rst.dat[u->rst.ptr + 1] = a; + u->rst.dat[u->rst.ptr + 2] = b; +#ifndef NO_STACK_CHECKS + if(__builtin_expect(u->rst.ptr < 2, 0)) { + u->rst.error = 1; + goto error; + } + if(__builtin_expect(u->rst.ptr > 252, 0)) { + u->rst.error = 2; + goto error; + } +#endif + u->rst.ptr += 3; + } + break; + case 0xc7: /* ROTkr */ + { + Uint8 a = u->rst.dat[u->rst.ptr - 1], b = u->rst.dat[u->rst.ptr - 2], c = u->rst.dat[u->rst.ptr - 3]; + u->rst.dat[u->rst.ptr] = b; + u->rst.dat[u->rst.ptr + 1] = a; + u->rst.dat[u->rst.ptr + 2] = c; +#ifndef NO_STACK_CHECKS + if(__builtin_expect(u->rst.ptr < 3, 0)) { + u->rst.error = 1; + goto error; + } + if(__builtin_expect(u->rst.ptr > 252, 0)) { + u->rst.error = 2; + goto error; + } +#endif + u->rst.ptr += 3; + } + break; + case 0xc8: /* EQUkr */ + { + Uint8 a = u->rst.dat[u->rst.ptr - 1], b = u->rst.dat[u->rst.ptr - 2]; + u->rst.dat[u->rst.ptr] = b == a; +#ifndef NO_STACK_CHECKS + if(__builtin_expect(u->rst.ptr < 2, 0)) { + u->rst.error = 1; + goto error; + } + if(__builtin_expect(u->rst.ptr > 254, 0)) { + u->rst.error = 2; + goto error; + } +#endif + u->rst.ptr += 1; + } + break; + case 0xc9: /* NEQkr */ + { + Uint8 a = u->rst.dat[u->rst.ptr - 1], b = u->rst.dat[u->rst.ptr - 2]; + u->rst.dat[u->rst.ptr] = b != a; +#ifndef NO_STACK_CHECKS + if(__builtin_expect(u->rst.ptr < 2, 0)) { + u->rst.error = 1; + goto error; + } + if(__builtin_expect(u->rst.ptr > 254, 0)) { + u->rst.error = 2; + goto error; + } +#endif + u->rst.ptr += 1; + } + break; + case 0xca: /* GTHkr */ + { + Uint8 a = u->rst.dat[u->rst.ptr - 1], b = u->rst.dat[u->rst.ptr - 2]; + u->rst.dat[u->rst.ptr] = b > a; +#ifndef NO_STACK_CHECKS + if(__builtin_expect(u->rst.ptr < 2, 0)) { + u->rst.error = 1; + goto error; + } + if(__builtin_expect(u->rst.ptr > 254, 0)) { + u->rst.error = 2; + goto error; + } +#endif + u->rst.ptr += 1; + } + break; + case 0xcb: /* LTHkr */ + { + Uint8 a = u->rst.dat[u->rst.ptr - 1], b = u->rst.dat[u->rst.ptr - 2]; + u->rst.dat[u->rst.ptr] = b < a; +#ifndef NO_STACK_CHECKS + if(__builtin_expect(u->rst.ptr < 2, 0)) { + u->rst.error = 1; + goto error; + } + if(__builtin_expect(u->rst.ptr > 254, 0)) { + u->rst.error = 2; + goto error; + } +#endif + u->rst.ptr += 1; + } + break; + case 0xcc: /* JMPkr */ + { + Uint8 a = u->rst.dat[u->rst.ptr - 1]; + u->ram.ptr += (Sint8)a; +#ifndef NO_STACK_CHECKS + if(__builtin_expect(u->rst.ptr < 1, 0)) { + u->rst.error = 1; + goto error; + } +#endif + } + break; + case 0xcd: /* JCNkr */ + { + Uint8 a = u->rst.dat[u->rst.ptr - 1]; + if(u->rst.dat[u->rst.ptr - 2]) u->ram.ptr += (Sint8)a; +#ifndef NO_STACK_CHECKS + if(__builtin_expect(u->rst.ptr < 2, 0)) { + u->rst.error = 1; + goto error; + } +#endif + } + break; + case 0xce: /* JSRkr */ + { + Uint8 a = u->rst.dat[u->rst.ptr - 1]; + u->wst.dat[u->wst.ptr] = u->ram.ptr >> 8; + u->wst.dat[u->wst.ptr + 1] = u->ram.ptr & 0xff; + u->ram.ptr += (Sint8)a; +#ifndef NO_STACK_CHECKS + if(__builtin_expect(u->rst.ptr < 1, 0)) { + u->rst.error = 1; + goto error; + } + if(__builtin_expect(u->wst.ptr > 253, 0)) { + u->wst.error = 2; + goto error; + } +#endif + u->wst.ptr += 2; + } + break; + case 0xcf: /* STHkr */ + { + Uint8 a = u->rst.dat[u->rst.ptr - 1]; + u->wst.dat[u->wst.ptr] = a; +#ifndef NO_STACK_CHECKS + if(__builtin_expect(u->rst.ptr < 1, 0)) { + u->rst.error = 1; + goto error; + } + if(__builtin_expect(u->wst.ptr > 254, 0)) { + u->wst.error = 2; + goto error; + } +#endif + u->wst.ptr += 1; + } + break; + case 0xd0: /* LDZkr */ + { + Uint8 a = u->rst.dat[u->rst.ptr - 1]; + u->rst.dat[u->rst.ptr] = peek8(u->ram.dat, a); +#ifndef NO_STACK_CHECKS + if(__builtin_expect(u->rst.ptr < 1, 0)) { + u->rst.error = 1; + goto error; + } + if(__builtin_expect(u->rst.ptr > 254, 0)) { + u->rst.error = 2; + goto error; + } +#endif + u->rst.ptr += 1; + } + break; + case 0xd1: /* STZkr */ + { + Uint8 a = u->rst.dat[u->rst.ptr - 1]; + Uint8 b = u->rst.dat[u->rst.ptr - 2]; + poke8(u->ram.dat, a, b); +#ifndef NO_STACK_CHECKS + if(__builtin_expect(u->rst.ptr < 2, 0)) { + u->rst.error = 1; + goto error; + } +#endif + } + break; + case 0xd2: /* LDRkr */ + { + Uint8 a = u->rst.dat[u->rst.ptr - 1]; + u->rst.dat[u->rst.ptr] = peek8(u->ram.dat, u->ram.ptr + (Sint8)a); +#ifndef NO_STACK_CHECKS + if(__builtin_expect(u->rst.ptr < 1, 0)) { + u->rst.error = 1; + goto error; + } + if(__builtin_expect(u->rst.ptr > 254, 0)) { + u->rst.error = 2; + goto error; + } +#endif + u->rst.ptr += 1; + } + break; + case 0xd3: /* STRkr */ + { + Uint8 a = u->rst.dat[u->rst.ptr - 1]; + Uint8 b = u->rst.dat[u->rst.ptr - 2]; + poke8(u->ram.dat, u->ram.ptr + (Sint8)a, b); +#ifndef NO_STACK_CHECKS + if(__builtin_expect(u->rst.ptr < 2, 0)) { + u->rst.error = 1; + goto error; + } +#endif + } + break; + case 0xd4: /* LDAkr */ + { + Uint16 a = (u->rst.dat[u->rst.ptr - 1] | (u->rst.dat[u->rst.ptr - 2] << 8)); + u->rst.dat[u->rst.ptr] = peek8(u->ram.dat, a); +#ifndef NO_STACK_CHECKS + if(__builtin_expect(u->rst.ptr < 2, 0)) { + u->rst.error = 1; + goto error; + } + if(__builtin_expect(u->rst.ptr > 254, 0)) { + u->rst.error = 2; + goto error; + } +#endif + u->rst.ptr += 1; + } + break; + case 0xd5: /* STAkr */ + { + Uint16 a = (u->rst.dat[u->rst.ptr - 1] | (u->rst.dat[u->rst.ptr - 2] << 8)); + Uint8 b = u->rst.dat[u->rst.ptr - 3]; + poke8(u->ram.dat, a, b); +#ifndef NO_STACK_CHECKS + if(__builtin_expect(u->rst.ptr < 3, 0)) { + u->rst.error = 1; + goto error; + } +#endif + } + break; + case 0xd6: /* DEIkr */ + { + Uint8 a = u->rst.dat[u->rst.ptr - 1]; + u->rst.dat[u->rst.ptr] = devr8(&u->dev[a >> 4], a); +#ifndef NO_STACK_CHECKS + if(__builtin_expect(u->rst.ptr < 1, 0)) { + u->rst.error = 1; + goto error; + } + if(__builtin_expect(u->rst.ptr > 254, 0)) { + u->rst.error = 2; + goto error; + } +#endif + u->rst.ptr += 1; + } + break; + case 0xd7: /* DEOkr */ + { + Uint8 a = u->rst.dat[u->rst.ptr - 1], b = u->rst.dat[u->rst.ptr - 2]; + devw8(&u->dev[a >> 4], a, b); +#ifndef NO_STACK_CHECKS + if(__builtin_expect(u->rst.ptr < 2, 0)) { + u->rst.error = 1; + goto error; + } +#endif + } + break; + case 0xd8: /* ADDkr */ + { + Uint8 a = u->rst.dat[u->rst.ptr - 1], b = u->rst.dat[u->rst.ptr - 2]; + u->rst.dat[u->rst.ptr] = b + a; +#ifndef NO_STACK_CHECKS + if(__builtin_expect(u->rst.ptr < 2, 0)) { + u->rst.error = 1; + goto error; + } + if(__builtin_expect(u->rst.ptr > 254, 0)) { + u->rst.error = 2; + goto error; + } +#endif + u->rst.ptr += 1; + } + break; + case 0xd9: /* SUBkr */ + { + Uint8 a = u->rst.dat[u->rst.ptr - 1], b = u->rst.dat[u->rst.ptr - 2]; + u->rst.dat[u->rst.ptr] = b - a; +#ifndef NO_STACK_CHECKS + if(__builtin_expect(u->rst.ptr < 2, 0)) { + u->rst.error = 1; + goto error; + } + if(__builtin_expect(u->rst.ptr > 254, 0)) { + u->rst.error = 2; + goto error; + } +#endif + u->rst.ptr += 1; + } + break; + case 0xda: /* MULkr */ + { + Uint8 a = u->rst.dat[u->rst.ptr - 1], b = u->rst.dat[u->rst.ptr - 2]; + u->rst.dat[u->rst.ptr] = b * a; +#ifndef NO_STACK_CHECKS + if(__builtin_expect(u->rst.ptr < 2, 0)) { + u->rst.error = 1; + goto error; + } + if(__builtin_expect(u->rst.ptr > 254, 0)) { + u->rst.error = 2; + goto error; + } +#endif + u->rst.ptr += 1; + } + break; + case 0xdb: /* DIVkr */ + { + Uint8 a = u->rst.dat[u->rst.ptr - 1], b = u->rst.dat[u->rst.ptr - 2]; + if(a == 0) { + u->rst.error = 3; +#ifndef NO_STACK_CHECKS + goto error; +#endif + a = 1; + } + u->rst.dat[u->rst.ptr] = b / a; +#ifndef NO_STACK_CHECKS + if(__builtin_expect(u->rst.ptr < 2, 0)) { + u->rst.error = 1; + goto error; + } + if(__builtin_expect(u->rst.ptr > 254, 0)) { + u->rst.error = 2; + goto error; + } +#endif + u->rst.ptr += 1; + } + break; + case 0xdc: /* ANDkr */ + { + Uint8 a = u->rst.dat[u->rst.ptr - 1], b = u->rst.dat[u->rst.ptr - 2]; + u->rst.dat[u->rst.ptr] = b & a; +#ifndef NO_STACK_CHECKS + if(__builtin_expect(u->rst.ptr < 2, 0)) { + u->rst.error = 1; + goto error; + } + if(__builtin_expect(u->rst.ptr > 254, 0)) { + u->rst.error = 2; + goto error; + } +#endif + u->rst.ptr += 1; + } + break; + case 0xdd: /* ORAkr */ + { + Uint8 a = u->rst.dat[u->rst.ptr - 1], b = u->rst.dat[u->rst.ptr - 2]; + u->rst.dat[u->rst.ptr] = b | a; +#ifndef NO_STACK_CHECKS + if(__builtin_expect(u->rst.ptr < 2, 0)) { + u->rst.error = 1; + goto error; + } + if(__builtin_expect(u->rst.ptr > 254, 0)) { + u->rst.error = 2; + goto error; + } +#endif + u->rst.ptr += 1; + } + break; + case 0xde: /* EORkr */ + { + Uint8 a = u->rst.dat[u->rst.ptr - 1], b = u->rst.dat[u->rst.ptr - 2]; + u->rst.dat[u->rst.ptr] = b ^ a; +#ifndef NO_STACK_CHECKS + if(__builtin_expect(u->rst.ptr < 2, 0)) { + u->rst.error = 1; + goto error; + } + if(__builtin_expect(u->rst.ptr > 254, 0)) { + u->rst.error = 2; + goto error; + } +#endif + u->rst.ptr += 1; + } + break; + case 0xdf: /* SFTkr */ + { + Uint8 a = u->rst.dat[u->rst.ptr - 1], b = u->rst.dat[u->rst.ptr - 2]; + u->rst.dat[u->rst.ptr] = b >> (a & 0x07) << ((a & 0x70) >> 4); +#ifndef NO_STACK_CHECKS + if(__builtin_expect(u->rst.ptr < 2, 0)) { + u->rst.error = 1; + goto error; + } + if(__builtin_expect(u->rst.ptr > 254, 0)) { + u->rst.error = 2; + goto error; + } +#endif + u->rst.ptr += 1; + } + break; case 0xe1: /* INC2kr */ { Uint16 a = (u->rst.dat[u->rst.ptr - 1] | (u->rst.dat[u->rst.ptr - 2] << 8));