commit 182061a
Devine Lu Linvega
·
2026-01-07 20:10:30 +0000 UTC
parent 240da66
Renamed micro ops
1 files changed,
+31,
-31
+31,
-31
1@@ -49,35 +49,35 @@ static Window window;
2 Uint8 *ram, dev[0x100], ptr[2], stk[2][0x100], emu_dei(const Uint8 port);
3 void emu_deo(const Uint8 port, const Uint8 value);
4
5-#define REM *sp -= 1 + _2;
6-#define DEC s[--(*sp)]
7-#define INC s[(*sp)++]
8+#define REM *p -= 1 + _2;
9+#define DEC s[--(*p)]
10+#define INC s[(*p)++]
11 #define MOV { if(_2) pc = a; else pc += (signed char)a; }
12-#define JMP(x) { c = ram[pc] << 8, c |= ram[pc+1]; pc += x + 2; }
13-#define STK(m) Uint8 *s = stk[m], *sp = &ptr[m];
14+#define JMP(x) { c = ram[pc] << 8, c |= ram[pc + 1]; pc += x + 2; }
15+#define STK(m) Uint8 *s = stk[m], *p = &ptr[m];
16 #define PO1(o) o = DEC;
17 #define PO2(o) { PO1(o) o |= DEC << 8; }
18 #define POx(o) { PO1(o) if(_2) o |= DEC << 8; }
19-#define RP1(i) stk[!_r][ptr[!_r]++] = i;
20+#define POt(o) if(_2) PO1(o[1]) PO1(o[0])
21 #define PU1(i) INC = i;
22+#define PU2(i) PU1(i >> 8) PU1(i)
23 #define PUx(i) c = (i); if(_2) PU1(c >> 8) PU1(c)
24-#define GOT(o) if(_2) PO1(o[1]) PO1(o[0])
25-#define PUT(i) PU1(i[0]) if(_2) PU1(i[1])
26+#define PUt(i) PU1(i[0]) if(_2) PU1(i[1])
27+#define PUr(i) stk[!_r][ptr[!_r]++] = i;
28 #define DEO(o,r) emu_deo(o, r[0]); if(_2) emu_deo(o + 1, r[1]);
29-#define DEI(i,r) r[0] = emu_dei(i); if(_2) r[1] = emu_dei(i + 1); PUT(r)
30+#define DEI(i,r) r[0] = emu_dei(i); if(_2) r[1] = emu_dei(i + 1);
31 #define POK(o,r,m) ram[o] = r[0]; if(_2) ram[(o + 1) & m] = r[1];
32-#define PEK(i,r,m) r[0] = ram[i]; if(_2) r[1] = ram[(i + 1) & m]; PUT(r)
33+#define PEK(i,r,m) r[0] = ram[i]; if(_2) r[1] = ram[(i + 1) & m];
34
35 #define OPC(opc, A, B) {\
36 case 0x00|opc: {const int _2=0,_r=0;STK(_r)A B} goto step;\
37 case 0x20|opc: {const int _2=1,_r=0;STK(_r)A B} goto step;\
38 case 0x40|opc: {const int _2=0,_r=1;STK(_r)A B} goto step;\
39 case 0x60|opc: {const int _2=1,_r=1;STK(_r)A B} goto step;\
40- case 0x80|opc: {const int _2=0,_r=0;STK(_r)int k=*sp;A *sp=k;B} goto step;\
41- case 0xa0|opc: {const int _2=1,_r=0;STK(_r)int k=*sp;A *sp=k;B} goto step;\
42- case 0xc0|opc: {const int _2=0,_r=1;STK(_r)int k=*sp;A *sp=k;B} goto step;\
43- case 0xe0|opc: {const int _2=1,_r=1;STK(_r)int k=*sp;A *sp=k;B} goto step; }
44-
45+ case 0x80|opc: {const int _2=0,_r=0;STK(_r)int k=*p; A *p=k;B} goto step;\
46+ case 0xa0|opc: {const int _2=1,_r=0;STK(_r)int k=*p; A *p=k;B} goto step;\
47+ case 0xc0|opc: {const int _2=0,_r=1;STK(_r)int k=*p; A *p=k;B} goto step;\
48+ case 0xe0|opc: {const int _2=1,_r=1;STK(_r)int k=*p; A *p=k;B} goto step;}
49
50 static unsigned int
51 uxn_eval(Uint16 pc)
52@@ -88,34 +88,34 @@ step:
53 /* BRK */ case 0x00: return 1;
54 /* JCI */ case 0x20: if(stk[0][--ptr[0]]) JMP(c) else pc += 2; goto step;
55 /* JMI */ case 0x40: JMP(c) goto step;
56- /* JSI */ case 0x60: { STK(1) JMP(0) INC = pc >> 8; INC = pc; pc += c; } goto step;
57+ /* JSI */ case 0x60: { STK(1) JMP(0) PU2(pc) pc += c; } goto step;
58 /* LI2 */ case 0xa0: { STK(0) INC = ram[pc++]; INC = ram[pc++]; } goto step;
59 /* LIT */ case 0x80: { stk[0][ptr[0]++] = ram[pc++]; } goto step;
60 /* L2r */ case 0xe0: { STK(1) INC = ram[pc++]; INC = ram[pc++]; } goto step;
61 /* LIr */ case 0xc0: { stk[1][ptr[1]++] = ram[pc++]; } goto step;
62 /* INC */ OPC(0x01,POx(a),PUx(a + 1))
63 /* POP */ OPC(0x02,REM,(void)s;)
64- /* NIP */ OPC(0x03,GOT(x) REM,PUT(x))
65- /* SWP */ OPC(0x04,GOT(x) GOT(y),PUT(x) PUT(y))
66- /* ROT */ OPC(0x05,GOT(x) GOT(y) GOT(z),PUT(y) PUT(x) PUT(z))
67- /* DUP */ OPC(0x06,GOT(x),PUT(x) PUT(x))
68- /* OVR */ OPC(0x07,GOT(x) GOT(y),PUT(y) PUT(x) PUT(y))
69+ /* NIP */ OPC(0x03,POt(x) REM,PUt(x))
70+ /* SWP */ OPC(0x04,POt(x) POt(y),PUt(x) PUt(y))
71+ /* ROT */ OPC(0x05,POt(x) POt(y) POt(z),PUt(y) PUt(x) PUt(z))
72+ /* DUP */ OPC(0x06,POt(x),PUt(x) PUt(x))
73+ /* OVR */ OPC(0x07,POt(x) POt(y),PUt(y) PUt(x) PUt(y))
74 /* EQU */ OPC(0x08,POx(a) POx(b),PU1(b == a))
75 /* NEQ */ OPC(0x09,POx(a) POx(b),PU1(b != a))
76 /* GTH */ OPC(0x0a,POx(a) POx(b),PU1(b > a))
77 /* LTH */ OPC(0x0b,POx(a) POx(b),PU1(b < a))
78 /* JMP */ OPC(0x0c,POx(a),MOV)
79 /* JCN */ OPC(0x0d,POx(a) PO1(b),if(b) MOV)
80- /* JSR */ OPC(0x0e,POx(a),RP1(pc >> 8) RP1(pc) MOV)
81- /* STH */ OPC(0x0f,GOT(x),RP1(x[0]) if(_2) RP1(x[1]))
82- /* LDZ */ OPC(0x10,PO1(a),PEK(a, x, 0xff))
83- /* STZ */ OPC(0x11,PO1(a) GOT(y),POK(a, y, 0xff))
84- /* LDR */ OPC(0x12,PO1(a),PEK(pc + (signed char)a, x, 0xffff))
85- /* STR */ OPC(0x13,PO1(a) GOT(y),POK(pc + (signed char)a, y, 0xffff))
86- /* LDA */ OPC(0x14,PO2(a),PEK(a, x, 0xffff))
87- /* STA */ OPC(0x15,PO2(a) GOT(y),POK(a, y, 0xffff))
88- /* DEI */ OPC(0x16,PO1(a),DEI(a, x))
89- /* DEO */ OPC(0x17,PO1(a) GOT(y),DEO(a, y))
90+ /* JSR */ OPC(0x0e,POx(a),PUr(pc >> 8) PUr(pc) MOV)
91+ /* STH */ OPC(0x0f,POt(x),PUr(x[0]) if(_2) PUr(x[1]))
92+ /* LDZ */ OPC(0x10,PO1(a),PEK(a, x, 0xff) PUt(x))
93+ /* STZ */ OPC(0x11,PO1(a) POt(y),POK(a, y, 0xff))
94+ /* LDR */ OPC(0x12,PO1(a),PEK(pc + (signed char)a, x, 0xffff) PUt(x))
95+ /* STR */ OPC(0x13,PO1(a) POt(y),POK(pc + (signed char)a, y, 0xffff))
96+ /* LDA */ OPC(0x14,PO2(a),PEK(a, x, 0xffff) PUt(x))
97+ /* STA */ OPC(0x15,PO2(a) POt(y),POK(a, y, 0xffff))
98+ /* DEI */ OPC(0x16,PO1(a),DEI(a, x) PUt(x))
99+ /* DEO */ OPC(0x17,PO1(a) POt(y),DEO(a, y))
100 /* ADD */ OPC(0x18,POx(a) POx(b),PUx(b + a))
101 /* SUB */ OPC(0x19,POx(a) POx(b),PUx(b - a))
102 /* MUL */ OPC(0x1a,POx(a) POx(b),PUx(b * a))