From 1bf7fb11b26c581834a10ab6bf6d7d6b6a3c2375 Mon Sep 17 00:00:00 2001 From: Andrew Alderwick Date: Sat, 30 Oct 2021 08:55:23 +0100 Subject: [PATCH] Update uxn-fast.c with new LIT opcode meanings --- src/uxn-fast.c | 107 ++++++++++++++++++++++++------------------------- 1 file changed, 53 insertions(+), 54 deletions(-) diff --git a/src/uxn-fast.c b/src/uxn-fast.c index c155f00..ab5fcdf 100644 --- a/src/uxn-fast.c +++ b/src/uxn-fast.c @@ -53,19 +53,6 @@ uxn_eval(Uxn *u, Uint16 vec) #pragma GCC diagnostic push #pragma GCC diagnostic ignored "-Wunused-value" #pragma GCC diagnostic ignored "-Wunused-variable" - case 0x00: /* LIT */ - case 0x80: /* LITk */ - { - u->wst.dat[u->wst.ptr] = peek8(u->ram.dat, u->ram.ptr++); -#ifndef NO_STACK_CHECKS - if(__builtin_expect(u->wst.ptr > 254, 0)) { - u->wst.error = 2; - goto error; - } -#endif - u->wst.ptr += 1; - } - break; case 0x01: /* INC */ { Uint8 a = u->wst.dat[u->wst.ptr - 1]; @@ -501,20 +488,6 @@ uxn_eval(Uxn *u, Uint16 vec) u->wst.ptr -= 1; } break; - 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)); @@ -986,19 +959,6 @@ uxn_eval(Uxn *u, Uint16 vec) 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 - if(__builtin_expect(u->rst.ptr > 254, 0)) { - u->rst.error = 2; - goto error; - } -#endif - u->rst.ptr += 1; - } - break; case 0x41: /* INCr */ { Uint8 a = u->rst.dat[u->rst.ptr - 1]; @@ -1434,20 +1394,6 @@ uxn_eval(Uxn *u, Uint16 vec) u->rst.ptr -= 1; } break; - case 0x60: /* LIT2r */ - case 0xe0: /* LIT2kr */ - { - u->rst.dat[u->rst.ptr] = peek8(u->ram.dat, u->ram.ptr++); - u->rst.dat[u->rst.ptr + 1] = peek8(u->ram.dat, u->ram.ptr++); -#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 0x61: /* INC2r */ { Uint16 a = (u->rst.dat[u->rst.ptr - 1] | (u->rst.dat[u->rst.ptr - 2] << 8)); @@ -1919,6 +1865,18 @@ uxn_eval(Uxn *u, Uint16 vec) u->rst.ptr -= 1; } break; + case 0x80: /* LIT */ + { + u->wst.dat[u->wst.ptr] = peek8(u->ram.dat, u->ram.ptr++); +#ifndef NO_STACK_CHECKS + if(__builtin_expect(u->wst.ptr > 254, 0)) { + u->wst.error = 2; + goto error; + } +#endif + u->wst.ptr += 1; + } + break; case 0x81: /* INCk */ { Uint8 a = u->wst.dat[u->wst.ptr - 1]; @@ -2430,6 +2388,20 @@ uxn_eval(Uxn *u, Uint16 vec) u->wst.ptr += 1; } break; + case 0xa0: /* LIT2 */ + case 0x20: /* LIT2_deprecated */ + { + 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 0xa1: /* INC2k */ { Uint16 a = (u->wst.dat[u->wst.ptr - 1] | (u->wst.dat[u->wst.ptr - 2] << 8)); @@ -2966,6 +2938,19 @@ uxn_eval(Uxn *u, Uint16 vec) u->wst.ptr += 2; } break; + case 0xc0: /* LITr */ + case 0x40: /* LITr_deprecated */ + { + u->rst.dat[u->rst.ptr] = peek8(u->ram.dat, u->ram.ptr++); +#ifndef NO_STACK_CHECKS + if(__builtin_expect(u->rst.ptr > 254, 0)) { + u->rst.error = 2; + goto error; + } +#endif + u->rst.ptr += 1; + } + break; case 0xc1: /* INCkr */ { Uint8 a = u->rst.dat[u->rst.ptr - 1]; @@ -3477,6 +3462,20 @@ uxn_eval(Uxn *u, Uint16 vec) u->rst.ptr += 1; } break; + case 0xe0: /* LIT2r */ + case 0x60: /* LIT2r_deprecated */ + { + u->rst.dat[u->rst.ptr] = peek8(u->ram.dat, u->ram.ptr++); + u->rst.dat[u->rst.ptr + 1] = peek8(u->ram.dat, u->ram.ptr++); +#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 0xe1: /* INC2kr */ { Uint16 a = (u->rst.dat[u->rst.ptr - 1] | (u->rst.dat[u->rst.ptr - 2] << 8));