...
|
...
|
@@ -11,42 +11,40 @@ THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
|
11
|
11
|
WITH REGARD TO THIS SOFTWARE.
|
12
|
12
|
*/
|
13
|
13
|
|
|
14
|
+/* Registers
|
|
15
|
+[ . ][ . ][ . ][ L ][ N ][ T ] <
|
|
16
|
+[ . ][ . ][ . ][ H2 ][ T ] <
|
|
17
|
+[ L2 ][ N2 ][ T2 ] <
|
|
18
|
+*/
|
|
19
|
+
|
14
|
20
|
#define T s->dat[s->ptr - 1]
|
15
|
21
|
#define N s->dat[s->ptr - 2]
|
16
|
22
|
#define L s->dat[s->ptr - 3]
|
17
|
|
-#define H2 PEEK2(s->dat + s->ptr - 3)
|
18
|
23
|
#define T2 PEEK2(s->dat + s->ptr - 2)
|
|
24
|
+#define H2 PEEK2(s->dat + s->ptr - 3)
|
19
|
25
|
#define N2 PEEK2(s->dat + s->ptr - 4)
|
20
|
26
|
#define L2 PEEK2(s->dat + s->ptr - 6)
|
21
|
27
|
|
22
|
|
-/* Registers
|
23
|
|
-
|
24
|
|
-[ . ][ . ][ . ][ L ][ N ][ T ] <
|
25
|
|
-[ . ][ . ][ . ][ H2 ][ T ] <
|
26
|
|
-[ L2 ][ N2 ][ T2 ] <
|
27
|
|
-
|
28
|
|
-*/
|
29
|
|
-
|
30
|
|
-#define HALT(c) { return uxn_halt(u, ins, (c), pc - 1); }
|
31
|
|
-#define SET(mul, add) { if(mul > s->ptr) HALT(1) tmp = (mul & k) + add + s->ptr; if(tmp > 254) HALT(2) s->ptr = tmp; }
|
32
|
|
-#define PUT(o, v) { s->dat[(Uint8)(s->ptr - 1 - (o))] = (v); }
|
33
|
|
-#define PUT2(o, v) { tmp = (v); POKE2(s->dat + (Uint8)(s->ptr - o - 2), tmp); }
|
34
|
|
-#define DEO(a, b) { u->dev[(a)] = (b); if((deo_mask[(a) >> 4] >> ((a) & 0xf)) & 0x1) uxn_deo(u, (a)); }
|
35
|
|
-#define DEI(a, b) { PUT((a), ((dei_mask[(b) >> 4] >> ((b) & 0xf)) & 0x1) ? uxn_dei(u, (b)) : u->dev[(b)]) }
|
36
|
|
-#define FLIP { s = ins & 0x40 ? &u->wst : &u->rst; }
|
|
28
|
+#define HALT(c) { return uxn_halt(u, ins, (c), pc - 1); }
|
|
29
|
+#define FLIP { s = ins & 0x40 ? &u->wst : &u->rst; }
|
|
30
|
+#define SET(x, y) { if(x > s->ptr) HALT(1) tmp = (x & k) + y + s->ptr; if(tmp > 254) HALT(2) s->ptr = tmp; }
|
|
31
|
+#define PUT(o, v) { s->dat[(s->ptr - 1 - (o))] = (v); }
|
|
32
|
+#define PUT2(o, v) { tmp = (v); POKE2(s->dat + (s->ptr - o - 2), tmp); }
|
|
33
|
+#define DEO(a, b) { u->dev[(a)] = (b); if((deo_mask[(a) >> 4] >> ((a) & 0xf)) & 0x1) uxn_deo(u, (a)); }
|
|
34
|
+#define DEI(a, b) { PUT((a), ((dei_mask[(b) >> 4] >> ((b) & 0xf)) & 0x1) ? uxn_dei(u, (b)) : u->dev[(b)]) }
|
37
|
35
|
|
38
|
36
|
int
|
39
|
37
|
uxn_eval(Uxn *u, Uint16 pc)
|
40
|
38
|
{
|
41
|
|
- int t, n, l, k, tmp, ins;
|
42
|
|
- Uint8 *ram = u->ram, opc;
|
|
39
|
+ int t, n, l, k, tmp, ins, opc;
|
|
40
|
+ Uint8 *ram = u->ram;
|
43
|
41
|
Stack *s;
|
44
|
42
|
if(!pc || u->dev[0x0f]) return 0;
|
45
|
43
|
for(;;) {
|
46
|
44
|
ins = ram[pc++];
|
47
|
45
|
k = ins & 0x80 ? 0xff : 0;
|
48
|
46
|
s = ins & 0x40 ? &u->rst : &u->wst;
|
49
|
|
- opc = !(ins & 0x1f) ? (0 - (ins >> 5)) : ins & 0x3f;
|
|
47
|
+ opc = !(ins & 0x1f) ? (0 - (ins >> 5)) & 0xff : ins & 0x3f;
|
50
|
48
|
switch(opc) {
|
51
|
49
|
/* IMM */
|
52
|
50
|
case 0x00: /* BRK */ return 1;
|