Make use of macros in PUT/PUSH

This commit is contained in:
Devine Lu Linvega 2023-03-12 15:54:20 -07:00
parent 4e77d3d5ae
commit 3ecbfe5e03
1 changed files with 12 additions and 12 deletions

View File

@ -29,12 +29,12 @@ WITH REGARD TO THIS SOFTWARE.
#define HALT(c) { return uxn_halt(u, ins, (c), pc - 1); } #define HALT(c) { return uxn_halt(u, ins, (c), pc - 1); }
#define SET(mul, add) { if(mul > s->ptr) HALT(1) s->ptr += k * mul + add; if(s->ptr > 254) HALT(2) } #define SET(mul, add) { if(mul > s->ptr) HALT(1) s->ptr += k * mul + add; if(s->ptr > 254) HALT(2) }
#define PUT(o, v) { s->dat[s->ptr - o - 1] = (v); } #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 PUT2(o, v) { tmp = (v); POKE2(s->dat + s->ptr - 2 - (o), tmp) }
#define PUSH(stack, v) { if(s->ptr > 254) HALT(2) stack->dat[stack->ptr++] = (v); } #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] = (v) >> 8; stack->dat[stack->ptr + 1] = (v); stack->ptr += 2; } #define PUSH2(stack, v) { if(s->ptr > 253) HALT(2) tmp = (v); POKE2(stack->dat + stack->ptr, tmp) stack->ptr += 2; }
#define DEO(a, b) { u->dev[a] = b; if((deo_mask[(a) >> 4] >> ((a) & 0xf)) & 0x1) uxn_deo(u, a); } #define DEO(a, b) { u->dev[(a)] = (b); if((deo_mask[(a) >> 4] >> ((a) & 0xf)) & 0x1) uxn_deo(u, (a)); }
#define DEI(a, b) { PUT(a, ((dei_mask[(b) >> 4] >> ((b) & 0xf)) & 0x1) ? uxn_dei(u, b) : u->dev[b]) } #define DEI(a, b) { PUT((a), ((dei_mask[(b) >> 4] >> ((b) & 0xf)) & 0x1) ? uxn_dei(u, (b)) : u->dev[(b)]) }
int int
uxn_eval(Uxn *u, Uint16 pc) uxn_eval(Uxn *u, Uint16 pc)