(uxn.c) Faster stack registers

This commit is contained in:
neauoire 2023-08-30 09:40:45 -07:00
parent d974111939
commit 07dc45c0e7
1 changed files with 8 additions and 7 deletions

View File

@ -11,19 +11,20 @@ THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
WITH REGARD TO THIS SOFTWARE. WITH REGARD TO THIS SOFTWARE.
*/ */
#define T *ptr
#define N *(ptr - 1)
#define L *(ptr - 2)
#define T2 (N << 8 | T)
#define H2 (L << 8 | N)
#define N2 (*(ptr - 3) << 8 | L)
#define L2 (*(ptr - 5) << 8 | *(ptr - 4))
/* Registers /* Registers
[ . ][ . ][ . ][ L ][ N ][ T ] < [ . ][ . ][ . ][ L ][ N ][ T ] <
[ . ][ . ][ . ][ H2 ][ T ] < [ . ][ . ][ . ][ H2 ][ T ] <
[ L2 ][ N2 ][ T2 ] < [ L2 ][ N2 ][ T2 ] <
*/ */
#define T *ptr
#define N *(ptr - 1)
#define L *(ptr - 2)
#define T2 PEEK2((ptr - 1))
#define H2 PEEK2((ptr - 2))
#define N2 PEEK2((ptr - 3))
#define L2 PEEK2((ptr - 5))
#define HALT(c) { return emu_halt(u, ins, c, pc - 1); } #define HALT(c) { return emu_halt(u, ins, c, pc - 1); }
#define FLIP { s = ins & 0x40 ? &u->wst : &u->rst; } #define FLIP { s = ins & 0x40 ? &u->wst : &u->rst; }
#define SET(x, y) { r = s->ptr; if(x > r) HALT(1) r += (x & k) + y; if(r > 254) HALT(2) ptr = s->dat + r - 1; s->ptr = r; } #define SET(x, y) { r = s->ptr; if(x > r) HALT(1) r += (x & k) + y; if(r > 254) HALT(2) ptr = s->dat + r - 1; s->ptr = r; }