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
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
|
// license:BSD-3-Clause
// copyright-holders:Philip Bennett
/***************************************************************************
cubedasm.c
Implementation of the Cube Quest AM2901-based CPUs
***************************************************************************/
#include "emu.h"
#include "cubeqcpu.h"
/***************************************************************************
CONSTANTS
***************************************************************************/
/* Am2901 Instruction Fields */
static const char *const ins[] =
{
"ADD ",
"SUBR ",
"SUBS ",
"OR ",
"AND ",
"NOTRS",
"EXOR ",
"EXNOR",
};
static const char *const src[] =
{
"A,Q",
"A,B",
"0,Q",
"0,B",
"0,A",
"D,A",
"D,Q",
"D,0",
};
static const char *const dst[] =
{
"QREG ",
"NOP ",
"RAMA ",
"RAMF ",
"RAMQD",
"RAMD ",
"RAMQU",
"RAMU ",
};
/***************************************************************************
SOUND DISASSEMBLY HOOK
***************************************************************************/
CPU_DISASSEMBLE( cquestsnd )
{
static const char *const jmps[] =
{
"JUMP ",
" ",
"JMSB ",
"JNMSB",
" ",
"JZERO",
"JOVR ",
"JLOOP",
};
static const char *const latches[] =
{
"PLTCH ",
"DAC ",
"ADLATCH",
" ",
};
UINT64 inst = BIG_ENDIANIZE_INT64(*(UINT64 *)oprom);
UINT32 inslow = inst & 0xffffffff;
UINT32 inshig = inst >> 32;
int t = (inshig >> 24) & 0xff;
int b = (inshig >> 20) & 0xf;
int a = (inshig >> 16) & 0xf;
int ci = (inshig >> 15) & 1;
int i5_3 = (inshig >> 12) & 7;
int _ramen = (inshig >> 11) & 1;
int i2_0 = (inshig >> 8) & 7;
int rtnltch = (inshig >> 7) & 1;
int jmp = (inshig >> 4) & 7;
int inca = (inshig >> 3) & 1;
int i8_6 = (inshig >> 0) & 7;
int _ipram = (inslow >> 31) & 1;
int _ipwrt = (inslow >> 30) & 1;
int latch = (inslow >> 28) & 3;
int rtn = (inslow >> 27) & 1;
int _rin = (inslow >> 26) & 1;
sprintf(buffer, "%s %s %s %x,%x,%c %.2x %s %s %.2x %s %s %s %c %c %c",
ins[i5_3],
src[i2_0],
dst[i8_6],
a,
b,
ci ? 'C' : ' ',
_rin,
jmps[jmp],
rtn ? "RET" : " ",
t,
latches[latch],
rtnltch ? "RTLATCH" : " ",
_ramen ? "PROM" : "RAM ",
_ipram ? ' ' : 'R',
_ipwrt ? ' ' : 'W',
inca ? 'I' : ' ');
return 1 | DASMFLAG_SUPPORTED;
}
/***************************************************************************
ROTATE DISASSEMBLY HOOK
***************************************************************************/
CPU_DISASSEMBLE( cquestrot )
{
static const char *const jmps[] =
{
" ",
"JSEQ ",
"JC ",
"JSYNC ",
"JLDWAIT",
"JMSB ",
"JGEONE ",
"JZERO ",
"JUMP ",
"JNSEQ ",
"JNC ",
"JNSYNC ",
"JNLDWAI",
"JNMSB ",
"JLTONE ",
"JNZERO ",
};
static const char *const youts[] =
{
" ",
" ",
"Y2LDA",
"Y2LDD",
"Y2DAD",
"Y2DIN",
"Y2R ",
"Y2D ",
};
static const char *const spfs[] =
{
" ",
" ",
"OP ",
"RET ",
"SQLTCH",
"SWRT ",
"DIV ",
"MULT ",
"DRED ",
"DWRT ",
"??? ",
"??? ",
"??? ",
"??? ",
"??? ",
"??? "
};
UINT64 inst = BIG_ENDIANIZE_INT64(*(UINT64 *)oprom);
UINT32 inslow = inst & 0xffffffff;
UINT32 inshig = inst >> 32;
int t = (inshig >> 20) & 0xfff;
int jmp = (inshig >> 16) & 0xf;
int spf = (inshig >> 12) & 0xf;
// int rsrc = (inshig >> 11) & 0x1;
int yout = (inshig >> 8) & 0x7;
int sel = (inshig >> 6) & 0x3;
// int dsrc = (inshig >> 4) & 0x3;
int b = (inshig >> 0) & 0xf;
int a = (inslow >> 28) & 0xf;
int i8_6 = (inslow >> 24) & 0x7;
int ci = (inslow >> 23) & 0x1;
int i5_3 = (inslow >> 20) & 0x7;
// int _sex = (inslow >> 19) & 0x1;
int i2_0 = (inslow >> 16) & 0x7;
sprintf(buffer, "%s %s,%s %x,%x,%c %d %s %s %s %.2x",
ins[i5_3],
src[i2_0],
dst[i8_6],
a,
b,
ci ? 'C' : ' ',
sel,
jmps[jmp],
youts[yout],
spfs[spf],
t);
return 1 | DASMFLAG_SUPPORTED;
}
/***************************************************************************
LINE DRAWER DISASSEMBLY HOOK
***************************************************************************/
CPU_DISASSEMBLE( cquestlin )
{
static const char *const jmps[] =
{
" ",
"JMSB ",
"JSEQ ",
"JGTZ ",
"JC ",
"JZ ",
"?????",
"?????",
"JUMP ",
"JNMSB",
"JNSEQ",
"JLEZ ",
"JNC ",
"JNZ ",
"?????",
"?????",
};
static const char *const latches[] =
{
" ",
"SEQLTCH",
"XLTCH ",
"YLTCH ",
"BGLTCH ",
"FGLTCH ",
"CLTCH ",
"ZLTCH ",
};
static const char *const spfs[] =
{
" ",
"FSTOP ",
"FREG ",
"FSTART",
"PWRT ",
"MULT ",
"LSTOP ",
"BRES ",
};
UINT64 inst = BIG_ENDIANIZE_INT64(*(UINT64 *)oprom);
UINT32 inslow = inst & 0xffffffff;
UINT32 inshig = inst >> 32;
int t = (inshig >> 24) & 0xff;
int jmp = (inshig >> 20) & 0xf;
int latch = (inshig >> 16) & 0x7;
int op = (inshig >> 15) & 0x1;
int spf = (inshig >> 12) & 0x7;
int b = (inshig >> 8) & 0xf;
int a = (inshig >> 4) & 0xf;
int i8_6 = (inshig >> 0) & 0x7;
int ci = (inslow >> 31) & 0x1;
int i5_3 = (inslow >> 28) & 0x7;
int _pbcs = (inslow >> 27) & 0x1;
int i2_0 = (inslow >> 24) & 0x7;
sprintf(buffer, "%s %s,%s %x,%x %c %s %.2x %s %s %s %s",
ins[i5_3],
src[i2_0],
dst[i8_6],
a,
b,
ci ? 'C' : ' ',
jmps[jmp],
t,
latches[latch],
op ? "OP" : " ",
_pbcs ? " " : "PB",
spfs[spf]);
return 1 | DASMFLAG_SUPPORTED;
}
|