(uxn.c) Housekeeping
This commit is contained in:
parent
cb41bdfa9a
commit
4db53c1cc6
32
src/uxn.c
32
src/uxn.c
|
@ -11,42 +11,40 @@ THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
|
|||
WITH REGARD TO THIS SOFTWARE.
|
||||
*/
|
||||
|
||||
#define T s->dat[s->ptr - 1]
|
||||
#define N s->dat[s->ptr - 2]
|
||||
#define L s->dat[s->ptr - 3]
|
||||
#define H2 PEEK2(s->dat + s->ptr - 3)
|
||||
#define T2 PEEK2(s->dat + s->ptr - 2)
|
||||
#define N2 PEEK2(s->dat + s->ptr - 4)
|
||||
#define L2 PEEK2(s->dat + s->ptr - 6)
|
||||
|
||||
/* Registers
|
||||
|
||||
[ . ][ . ][ . ][ L ][ N ][ T ] <
|
||||
[ . ][ . ][ . ][ H2 ][ T ] <
|
||||
[ L2 ][ N2 ][ T2 ] <
|
||||
|
||||
*/
|
||||
|
||||
#define T s->dat[s->ptr - 1]
|
||||
#define N s->dat[s->ptr - 2]
|
||||
#define L s->dat[s->ptr - 3]
|
||||
#define T2 PEEK2(s->dat + s->ptr - 2)
|
||||
#define H2 PEEK2(s->dat + s->ptr - 3)
|
||||
#define N2 PEEK2(s->dat + s->ptr - 4)
|
||||
#define L2 PEEK2(s->dat + s->ptr - 6)
|
||||
|
||||
#define HALT(c) { return uxn_halt(u, ins, (c), pc - 1); }
|
||||
#define SET(mul, add) { if(mul > s->ptr) HALT(1) tmp = (mul & k) + add + s->ptr; if(tmp > 254) HALT(2) s->ptr = tmp; }
|
||||
#define PUT(o, v) { s->dat[(Uint8)(s->ptr - 1 - (o))] = (v); }
|
||||
#define PUT2(o, v) { tmp = (v); POKE2(s->dat + (Uint8)(s->ptr - o - 2), tmp); }
|
||||
#define FLIP { s = ins & 0x40 ? &u->wst : &u->rst; }
|
||||
#define SET(x, y) { if(x > s->ptr) HALT(1) tmp = (x & k) + y + s->ptr; if(tmp > 254) HALT(2) s->ptr = tmp; }
|
||||
#define PUT(o, v) { s->dat[(s->ptr - 1 - (o))] = (v); }
|
||||
#define PUT2(o, v) { tmp = (v); POKE2(s->dat + (s->ptr - o - 2), tmp); }
|
||||
#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 FLIP { s = ins & 0x40 ? &u->wst : &u->rst; }
|
||||
|
||||
int
|
||||
uxn_eval(Uxn *u, Uint16 pc)
|
||||
{
|
||||
int t, n, l, k, tmp, ins;
|
||||
Uint8 *ram = u->ram, opc;
|
||||
int t, n, l, k, tmp, ins, opc;
|
||||
Uint8 *ram = u->ram;
|
||||
Stack *s;
|
||||
if(!pc || u->dev[0x0f]) return 0;
|
||||
for(;;) {
|
||||
ins = ram[pc++];
|
||||
k = ins & 0x80 ? 0xff : 0;
|
||||
s = ins & 0x40 ? &u->rst : &u->wst;
|
||||
opc = !(ins & 0x1f) ? (0 - (ins >> 5)) : ins & 0x3f;
|
||||
opc = !(ins & 0x1f) ? (0 - (ins >> 5)) & 0xff : ins & 0x3f;
|
||||
switch(opc) {
|
||||
/* IMM */
|
||||
case 0x00: /* BRK */ return 1;
|
||||
|
|
Loading…
Reference in New Issue