1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
|
/***************************************************************************
dasm7725.c
Disassembler for the portable uPD7725 emulator.
Written by byuu
MAME conversion by R. Belmont
***************************************************************************/
#include "emu.h"
#include "upd7725.h"
CPU_DISASSEMBLE( upd7725 )
{
static char output[256];
UINT32 opcode = oprom[2] | (oprom[1] << 8) | (oprom[0] << 16);
UINT32 type = (opcode >> 22);
// printf("dasm: PC %x opcode %08x\n", pc, opcode);
memset(output, 0, sizeof(output));
if(type == 0 || type == 1) { //OP,RT
UINT8 pselect = (opcode >> 20)&0x3; //P select
UINT8 alu = (opcode >> 16)&0xf; //ALU operation mode
UINT8 asl = (opcode >> 15)&0x1; //accumulator select
UINT8 dpl = (opcode >> 13)&0x3; //DP low modify
UINT8 dphm = (opcode >> 9)&0xf; //DP high XOR modify
UINT8 rpdcr = (opcode >> 8)&0x1; //RP decrement
UINT8 src = (opcode >> 4)&0xf; //move source
UINT8 dst = (opcode >> 0)&0xf; //move destination
switch(alu) {
case 0: strcat(output, "nop "); break;
case 1: strcat(output, "or "); break;
case 2: strcat(output, "and "); break;
case 3: strcat(output, "xor "); break;
case 4: strcat(output, "sub "); break;
case 5: strcat(output, "add "); break;
case 6: strcat(output, "sbb "); break;
case 7: strcat(output, "adc "); break;
case 8: strcat(output, "dec "); break;
case 9: strcat(output, "inc "); break;
case 10: strcat(output, "cmp "); break;
case 11: strcat(output, "shr1 "); break;
case 12: strcat(output, "shl1 "); break;
case 13: strcat(output, "shl2 "); break;
case 14: strcat(output, "shl4 "); break;
case 15: strcat(output, "xchg "); break;
}
if(alu < 8) {
switch(pselect) {
case 0: strcat(output, "ram,"); break;
case 1: strcat(output, "idb,"); break;
case 2: strcat(output, "m,"); break;
case 3: strcat(output, "n,"); break;
}
}
switch(asl) {
case 0: strcat(output, "a"); break;
case 1: strcat(output, "b"); break;
}
if(dst) {
strcat(output, " | mov ");
switch(src) {
case 0: strcat(output, "trb,"); break;
case 1: strcat(output, "a,"); break;
case 2: strcat(output, "b,"); break;
case 3: strcat(output, "tr,"); break;
case 4: strcat(output, "dp,"); break;
case 5: strcat(output, "rp,"); break;
case 6: strcat(output, "ro,"); break;
case 7: strcat(output, "sgn,"); break;
case 8: strcat(output, "dr,"); break;
case 9: strcat(output, "drnf,"); break;
case 10: strcat(output, "sr,"); break;
case 11: strcat(output, "sim,"); break;
case 12: strcat(output, "sil,"); break;
case 13: strcat(output, "k,"); break;
case 14: strcat(output, "l,"); break;
case 15: strcat(output, "mem,"); break;
}
switch(dst) {
case 0: strcat(output, "non"); break;
case 1: strcat(output, "a"); break;
case 2: strcat(output, "b"); break;
case 3: strcat(output, "tr"); break;
case 4: strcat(output, "dp"); break;
case 5: strcat(output, "rp"); break;
case 6: strcat(output, "dr"); break;
case 7: strcat(output, "sr"); break;
case 8: strcat(output, "sol"); break;
case 9: strcat(output, "som"); break;
case 10: strcat(output, "k"); break;
case 11: strcat(output, "klr"); break;
case 12: strcat(output, "klm"); break;
case 13: strcat(output, "l"); break;
case 14: strcat(output, "trb"); break;
case 15: strcat(output, "mem"); break;
}
}
if(dpl) {
switch(dpl) {
case 0: strcat(output, " | dpnop"); break;
case 1: strcat(output, " | dpinc"); break;
case 2: strcat(output, " | dpdec"); break;
case 3: strcat(output, " | dpclr"); break;
}
}
if(dphm) {
switch(dphm) {
case 0: strcat(output, " | m0"); break;
case 1: strcat(output, " | m1"); break;
case 2: strcat(output, " | m2"); break;
case 3: strcat(output, " | m3"); break;
case 4: strcat(output, " | m4"); break;
case 5: strcat(output, " | m5"); break;
case 6: strcat(output, " | m6"); break;
case 7: strcat(output, " | m7"); break;
case 8: strcat(output, " | m8"); break;
case 9: strcat(output, " | m9"); break;
case 10: strcat(output, " | ma"); break;
case 11: strcat(output, " | mb"); break;
case 12: strcat(output, " | mc"); break;
case 13: strcat(output, " | md"); break;
case 14: strcat(output, " | me"); break;
case 15: strcat(output, " | mf"); break;
}
}
if(rpdcr == 1) {
strcat(output, " | rpdec");
}
if(type == 1) {
strcat(output, " | ret");
}
}
if(type == 2) { //JP
UINT16 brch = (opcode >> 13) & 0x1ff; //branch
UINT16 na = (opcode >> 2) & 0x7ff; //next address
switch(brch) {
case 0x000: strcat(output, "jmpso "); break;
case 0x080: strcat(output, "jnca "); break;
case 0x082: strcat(output, "jca "); break;
case 0x084: strcat(output, "jncb "); break;
case 0x086: strcat(output, "jcb "); break;
case 0x088: strcat(output, "jnza "); break;
case 0x08a: strcat(output, "jza "); break;
case 0x08c: strcat(output, "jnzb "); break;
case 0x08e: strcat(output, "jzb "); break;
case 0x090: strcat(output, "jnova0 "); break;
case 0x092: strcat(output, "jova0 "); break;
case 0x094: strcat(output, "jnovb0 "); break;
case 0x096: strcat(output, "jovb0 "); break;
case 0x098: strcat(output, "jnova1 "); break;
case 0x09a: strcat(output, "jova1 "); break;
case 0x09c: strcat(output, "jnovb1 "); break;
case 0x09e: strcat(output, "jovb1 "); break;
case 0x0a0: strcat(output, "jnsa0 "); break;
case 0x0a2: strcat(output, "jsa0 "); break;
case 0x0a4: strcat(output, "jnsb0 "); break;
case 0x0a6: strcat(output, "jsb0 "); break;
case 0x0a8: strcat(output, "jnsa1 "); break;
case 0x0aa: strcat(output, "jsa1 "); break;
case 0x0ac: strcat(output, "jnsb1 "); break;
case 0x0ae: strcat(output, "jsb1 "); break;
case 0x0b0: strcat(output, "jdpl0 "); break;
case 0x0b1: strcat(output, "jdpln0 "); break;
case 0x0b2: strcat(output, "jdplf "); break;
case 0x0b3: strcat(output, "jdplnf "); break;
case 0x0b4: strcat(output, "jnsiak "); break;
case 0x0b6: strcat(output, "jsiak "); break;
case 0x0b8: strcat(output, "jnsoak "); break;
case 0x0ba: strcat(output, "jsoak "); break;
case 0x0bc: strcat(output, "jnrqm "); break;
case 0x0be: strcat(output, "jrqm "); break;
case 0x100: strcat(output, "ljmp "); break;
case 0x101: strcat(output, "hjmp "); break;
case 0x140: strcat(output, "lcall "); break;
case 0x141: strcat(output, "hcall "); break;
default: strcat(output, "?????? "); break;
}
char temp[16];
sprintf(temp, "$%x", na);
strcat(output, temp);
}
if(type == 3) { //LD
strcat(output, "ld ");
UINT16 id = opcode >> 6;
UINT8 dst = (opcode >> 0) & 0xf; //destination
char temp[16];
sprintf(temp, "$%x,", id);
strcat(output, temp);
switch(dst) {
case 0: strcat(output, "non"); break;
case 1: strcat(output, "a"); break;
case 2: strcat(output, "b"); break;
case 3: strcat(output, "tr"); break;
case 4: strcat(output, "dp"); break;
case 5: strcat(output, "rp"); break;
case 6: strcat(output, "dr"); break;
case 7: strcat(output, "sr"); break;
case 8: strcat(output, "sol"); break;
case 9: strcat(output, "som"); break;
case 10: strcat(output, "k"); break;
case 11: strcat(output, "klr"); break;
case 12: strcat(output, "klm"); break;
case 13: strcat(output, "l"); break;
case 14: strcat(output, "trb"); break;
case 15: strcat(output, "mem"); break;
}
}
strcpy(buffer, output);
return 1 | DASMFLAG_SUPPORTED;
}
|