1 #include "debugger.h"
2 #include "i8x41.h"
3
i8x41_dasm(char * dst,offs_t pc,const UINT8 * oprom,const UINT8 * opram)4 offs_t i8x41_dasm(char *dst, offs_t pc, const UINT8 *oprom, const UINT8 *opram)
5 {
6 UINT32 flags = 0;
7 unsigned PC = pc;
8 UINT8 op;
9 UINT8 arg;
10
11 op = oprom[PC++ - pc];
12 switch( op )
13 {
14 case 0x00: /* 1: 0000 0000 */
15 sprintf(dst, "nop");
16 break;
17 case 0x01: /* 1: 0000 0001 */
18 sprintf(dst, "ill");
19 break;
20 case 0x02: /* 1: 0000 0010 */
21 sprintf(dst, "out dbb,a");
22 break;
23 case 0x03: /* 2: 0000 0011 */
24 sprintf(dst, "add a,#$%02X", opram[PC++ - pc]);
25 break;
26 case 0x04: /* 2: aaa0 0100 */
27 case 0x24: /* 2: aaa0 0100 */
28 case 0x44: /* 2: aaa0 0100 */
29 case 0x64: /* 2: aaa0 0100 */
30 case 0x84: /* 2: aaa0 0100 */
31 case 0xa4: /* 2: aaa0 0100 */
32 case 0xc4: /* 2: aaa0 0100 */
33 case 0xe4: /* 2: aaa0 0100 */
34 sprintf(dst, "jmp $%04X", ((op<<3) & 0x700) | opram[PC++ - pc]);
35 break;
36 case 0x05: /* 1: 0000 0101 */
37 sprintf(dst, "en i");
38 break;
39 case 0x06: /* 1: 0000 0110 */
40 sprintf(dst, "ill");
41 break;
42 case 0x07: /* 1: 0000 0111 */
43 sprintf(dst, "dec a");
44 break;
45 case 0x08: /* 2: 0000 10pp */
46 case 0x09: /* 2: 0000 10pp */
47 case 0x0a: /* 2: 0000 10pp */
48 case 0x0b: /* 2: 0000 10pp */
49 sprintf(dst, "in a,p%d", op&3);
50 break;
51 case 0x0c: /* 2: 0000 11pp */
52 case 0x0d: /* 2: 0000 11pp */
53 case 0x0e: /* 2: 0000 11pp */
54 case 0x0f: /* 2: 0000 11pp */
55 sprintf(dst, "movd a,p%d", op&3);
56 break;
57 case 0x10: /* 1: 0001 000r */
58 case 0x11: /* 1: 0001 000r */
59 sprintf(dst, "inc @r%d", op&1);
60 break;
61 case 0x12: /* 2: bbb1 0010 */
62 case 0x32: /* 2: bbb1 0010 */
63 case 0x52: /* 2: bbb1 0010 */
64 case 0x72: /* 2: bbb1 0010 */
65 case 0x92: /* 2: bbb1 0010 */
66 case 0xb2: /* 2: bbb1 0010 */
67 case 0xd2: /* 2: bbb1 0010 */
68 case 0xf2: /* 2: bbb1 0010 */
69 arg = opram[PC++ - pc];
70 sprintf(dst, "jb%d $%04X", op >> 5, (PC & 0x700) | arg);
71 break;
72 case 0x13: /* 2: 0001 0011 */
73 sprintf(dst, "addc $%02X", opram[PC++ - pc]);
74 break;
75 case 0x14: /* 2: aaa1 0100 */
76 case 0x34: /* 2: aaa1 0100 */
77 case 0x54: /* 2: aaa1 0100 */
78 case 0x74: /* 2: aaa1 0100 */
79 case 0x94: /* 2: aaa1 0100 */
80 case 0xb4: /* 2: aaa1 0100 */
81 case 0xd4: /* 2: aaa1 0100 */
82 case 0xf4: /* 2: aaa1 0100 */
83 sprintf(dst, "call $%04X", ((op<<3) & 0x700) | opram[PC++ - pc]);
84 flags = DASMFLAG_STEP_OVER;
85 break;
86 case 0x15: /* 1: 0001 0101 */
87 sprintf(dst, "dis i");
88 break;
89 case 0x16: /* 2: 0001 0110 */
90 arg = opram[PC++ - pc];
91 sprintf(dst, "jtf $%04X", (PC & 0x700) | arg);
92 break;
93 case 0x17: /* 1: 0001 0111 */
94 sprintf(dst, "inc a");
95 break;
96 case 0x18: /* 1: 0001 1rrr */
97 case 0x19: /* 1: 0001 1rrr */
98 case 0x1a: /* 1: 0001 1rrr */
99 case 0x1b: /* 1: 0001 1rrr */
100 case 0x1c: /* 1: 0001 1rrr */
101 case 0x1d: /* 1: 0001 1rrr */
102 case 0x1e: /* 1: 0001 1rrr */
103 case 0x1f: /* 1: 0001 1rrr */
104 sprintf(dst, "inc r%d", op&7);
105 break;
106 case 0x20: /* 1: 0010 000r */
107 case 0x21: /* 1: 0010 000r */
108 sprintf(dst, "xch a,@r%d", op&1);
109 break;
110 case 0x22: /* 1: 0010 0010 */
111 sprintf(dst, "in a,ddb");
112 break;
113 case 0x23: /* 2: 0010 0011 */
114 sprintf(dst, "mov a,#$%02X", opram[PC++ - pc]);
115 break;
116 case 0x25: /* 1: 0010 0101 */
117 sprintf(dst, "en tcnti");
118 break;
119 case 0x26: /* 2: 0010 0110 */
120 arg = opram[PC++ - pc];
121 sprintf(dst, "jnt0 $%04X", (PC & 0x700) | arg);
122 break;
123 case 0x27: /* 1: 0010 0111 */
124 sprintf(dst, "clr a");
125 break;
126 case 0x28: /* 1: 0010 1rrr */
127 case 0x29: /* 1: 0010 1rrr */
128 case 0x2a: /* 1: 0010 1rrr */
129 case 0x2b: /* 1: 0010 1rrr */
130 case 0x2c: /* 1: 0010 1rrr */
131 case 0x2d: /* 1: 0010 1rrr */
132 case 0x2e: /* 1: 0010 1rrr */
133 case 0x2f: /* 1: 0010 1rrr */
134 sprintf(dst, "xch a,r%d", op&7);
135 break;
136 case 0x30: /* 1: 0011 000r */
137 case 0x31: /* 1: 0011 000r */
138 sprintf(dst, "xchd a,@r%d", op&1);
139 break;
140 case 0x33: /* 1: 0011 0101 */
141 sprintf(dst, "ill");
142 break;
143 case 0x35: /* 1: 0000 0101 */
144 sprintf(dst, "dis tcnti");
145 break;
146 case 0x36: /* 2: 0011 0110 */
147 arg = opram[PC++ - pc];
148 sprintf(dst, "jt0 $%04X", (PC & 0x700) | arg);
149 break;
150 case 0x37: /* 1: 0011 0111 */
151 sprintf(dst, "cpl a");
152 break;
153 case 0x38: /* 2: 0011 10pp */
154 case 0x39: /* 2: 0011 10pp */
155 case 0x3a: /* 2: 0011 10pp */
156 case 0x3b: /* 2: 0011 10pp */
157 sprintf(dst, "out p%d,a", op&3);
158 break;
159 case 0x3c: /* 2: 0011 11pp */
160 case 0x3d: /* 2: 0011 11pp */
161 case 0x3e: /* 2: 0011 11pp */
162 case 0x3f: /* 2: 0011 11pp */
163 sprintf(dst, "movd p%d,a", op&7);
164 break;
165 case 0x40: /* 1: 0100 000r */
166 case 0x41: /* 1: 0100 000r */
167 sprintf(dst, "orl a,@r%d", op&1);
168 break;
169 case 0x42: /* 1: 0100 0010 */
170 sprintf(dst, "mov a,t");
171 break;
172 case 0x43: /* 2: 0100 0011 */
173 sprintf(dst, "orl a,#$%02X", opram[PC++ - pc]);
174 break;
175 case 0x45: /* 1: 0100 0101 */
176 sprintf(dst, "strt cnt");
177 break;
178 case 0x46: /* 2: 0100 0110 */
179 arg = opram[PC++ - pc];
180 sprintf(dst, "jnt1 $%04X", (PC & 0x700) | arg);
181 break;
182 case 0x47: /* 1: 0100 0111 */
183 sprintf(dst, "swap a");
184 break;
185 case 0x48: /* 1: 0100 1rrr */
186 case 0x49: /* 1: 0100 1rrr */
187 case 0x4a: /* 1: 0100 1rrr */
188 case 0x4b: /* 1: 0100 1rrr */
189 case 0x4c: /* 1: 0100 1rrr */
190 case 0x4d: /* 1: 0100 1rrr */
191 case 0x4e: /* 1: 0100 1rrr */
192 case 0x4f: /* 1: 0100 1rrr */
193 sprintf(dst, "orl a,r%d", op&7);
194 break;
195 case 0x50: /* 1: 0101 000r */
196 case 0x51: /* 1: 0101 000r */
197 sprintf(dst, "anl a,@r%d", op&1);
198 break;
199 case 0x53: /* 2: 0101 0011 */
200 sprintf(dst, "anl a,#$%02X", opram[PC++ - pc]);
201 break;
202 case 0x55: /* 1: 0101 0101 */
203 sprintf(dst, "strt t");
204 break;
205 case 0x56: /* 2: 0101 0110 */
206 arg = opram[PC++ - pc];
207 sprintf(dst, "jt1 $%04X", (PC & 0x700) | arg);
208 break;
209 case 0x57: /* 1: 0101 0111 */
210 sprintf(dst, "da a");
211 break;
212 case 0x58: /* 1: 0101 1rrr */
213 case 0x59: /* 1: 0101 1rrr */
214 case 0x5a: /* 1: 0101 1rrr */
215 case 0x5b: /* 1: 0101 1rrr */
216 case 0x5c: /* 1: 0101 1rrr */
217 case 0x5d: /* 1: 0101 1rrr */
218 case 0x5e: /* 1: 0101 1rrr */
219 case 0x5f: /* 1: 0101 1rrr */
220 sprintf(dst, "anl a,r%d", op&7);
221 break;
222 case 0x60: /* 1: 0110 000r */
223 case 0x61: /* 1: 0110 000r */
224 sprintf(dst, "add a,@r%d", op&1);
225 break;
226 case 0x62: /* 1: 0110 0010 */
227 sprintf(dst, "mov t,a");
228 break;
229 case 0x63: /* 1: 0110 0011 */
230 sprintf(dst, "ill");
231 break;
232 case 0x65: /* 1: 0110 0101 */
233 sprintf(dst, "stop tcnt");
234 break;
235 case 0x66: /* 1: 0110 0110 */
236 sprintf(dst, "ill");
237 break;
238 case 0x67: /* 1: 0110 0111 */
239 sprintf(dst, "rlc a");
240 break;
241 case 0x68: /* 1: 0110 1rrr */
242 case 0x69: /* 1: 0110 1rrr */
243 case 0x6a: /* 1: 0110 1rrr */
244 case 0x6b: /* 1: 0110 1rrr */
245 case 0x6c: /* 1: 0110 1rrr */
246 case 0x6d: /* 1: 0110 1rrr */
247 case 0x6e: /* 1: 0110 1rrr */
248 case 0x6f: /* 1: 0110 1rrr */
249 sprintf(dst, "add a,r%d", op&7);
250 break;
251 case 0x70: /* 1: 0111 000r */
252 case 0x71: /* 1: 0111 000r */
253 sprintf(dst, "addc a,@r%d", op&1);
254 break;
255 case 0x73: /* 1: 0111 0011 */
256 sprintf(dst, "ill");
257 break;
258 case 0x75: /* 1: 0111 0101 */
259 sprintf(dst, "ill");
260 break;
261 case 0x76: /* 2: 0111 0110 */
262 arg = opram[PC++ - pc];
263 sprintf(dst, "jf1 $%04X", (PC & 0x700) | arg);
264 break;
265 case 0x77: /* 1: 0111 0111 */
266 sprintf(dst, "rl a");
267 break;
268 case 0x78: /* 1: 0111 1rrr */
269 case 0x79: /* 1: 0111 1rrr */
270 case 0x7a: /* 1: 0111 1rrr */
271 case 0x7b: /* 1: 0111 1rrr */
272 case 0x7c: /* 1: 0111 1rrr */
273 case 0x7d: /* 1: 0111 1rrr */
274 case 0x7e: /* 1: 0111 1rrr */
275 case 0x7f: /* 1: 0111 1rrr */
276 sprintf(dst, "addc a,r%d", op&7);
277 break;
278 case 0x80: /* 1: 1000 0000 */
279 sprintf(dst, "ill ");
280 break;
281 case 0x81: /* 1: 1000 0001 */
282 sprintf(dst, "ill ");
283 break;
284 case 0x82: /* 1: 1000 0010 */
285 sprintf(dst, "ill ");
286 break;
287 case 0x83: /* 2: 1000 0011 */
288 sprintf(dst, "ret");
289 flags = DASMFLAG_STEP_OUT;
290 break;
291 case 0x85: /* 1: 1000 0101 */
292 sprintf(dst, "clr f0");
293 break;
294 case 0x86: /* 2: 1000 0110 */
295 arg = opram[PC++ - pc];
296 sprintf(dst, "jobf $%04X", (PC & 0x700) | arg);
297 break;
298 case 0x87: /* 1: 1000 0111 */
299 sprintf(dst, "ill");
300 break;
301 case 0x88: /* 2: 1000 10pp */
302 case 0x89: /* 2: 1000 10pp */
303 case 0x8a: /* 2: 1000 10pp */
304 case 0x8b: /* 2: 1000 10pp */
305 sprintf(dst, "orl p%d,#$%02X", op&3, opram[PC++ - pc]);
306 break;
307 case 0x8c: /* 2: 1000 11pp */
308 case 0x8d: /* 2: 1000 11pp */
309 case 0x8e: /* 2: 1000 11pp */
310 case 0x8f: /* 2: 1000 11pp */
311 sprintf(dst, "orld p%d,a", op&7);
312 break;
313 case 0x90: /* 1: 1001 0000 */
314 sprintf(dst, "mov sts,a");
315 break;
316 case 0x91: /* 1: 1001 0001 */
317 sprintf(dst, "ill");
318 break;
319 case 0x93: /* 2: 1001 0011 */
320 sprintf(dst, "retr");
321 flags = DASMFLAG_STEP_OVER;
322 break;
323 case 0x95: /* 1: 1001 0101 */
324 sprintf(dst, "cpl f0");
325 break;
326 case 0x96: /* 2: 1001 0110 */
327 arg = opram[PC++ - pc];
328 sprintf(dst, "jnz $%04X", (PC & 0x700) | arg);
329 break;
330 case 0x97: /* 1: 1001 0111 */
331 sprintf(dst, "clr c");
332 break;
333 case 0x98: /* 2: 1001 10pp */
334 case 0x99: /* 2: 1001 10pp */
335 case 0x9a: /* 2: 1001 10pp */
336 case 0x9b: /* 2: 1001 10pp */
337 sprintf(dst, "anl p%d,#$%02X", op&3, opram[PC++ - pc]);
338 break;
339 case 0x9c: /* 2: 1001 11pp */
340 case 0x9d: /* 2: 1001 11pp */
341 case 0x9e: /* 2: 1001 11pp */
342 case 0x9f: /* 2: 1001 11pp */
343 sprintf(dst, "anld p%d,a", op&7);
344 break;
345 case 0xa0: /* 1: 1010 000r */
346 case 0xa1: /* 1: 1010 000r */
347 sprintf(dst, "mov @r%d,a", op&1);
348 break;
349 case 0xa2: /* 1: 1010 0010 */
350 sprintf(dst, "ill");
351 break;
352 case 0xa3: /* 2: 1010 0011 */
353 sprintf(dst, "movp a,@a");
354 break;
355 case 0xa5: /* 1: 1010 0101 */
356 sprintf(dst, "clr f1");
357 break;
358 case 0xa6: /* 1: 1010 0110 */
359 sprintf(dst, "ill");
360 break;
361 case 0xa7: /* 1: 1010 0111 */
362 sprintf(dst, "cpl c");
363 break;
364 case 0xa8: /* 1: 1010 1rrr */
365 case 0xa9: /* 1: 1010 1rrr */
366 case 0xaa: /* 1: 1010 1rrr */
367 case 0xab: /* 1: 1010 1rrr */
368 case 0xac: /* 1: 1010 1rrr */
369 case 0xad: /* 1: 1010 1rrr */
370 case 0xae: /* 1: 1010 1rrr */
371 case 0xaf: /* 1: 1010 1rrr */
372 sprintf(dst, "mov r%d,a", op&7);
373 break;
374 case 0xb0: /* 2: 1011 000r */
375 case 0xb1: /* 2: 1011 000r */
376 sprintf(dst, "mov @r%d,#$%02X", op&1, opram[PC++ - pc]);
377 break;
378 case 0xb3: /* 2: 1011 0011 */
379 sprintf(dst, "jmpp @a");
380 break;
381 case 0xb5: /* 1: 1011 0101 */
382 sprintf(dst, "cpl f1");
383 break;
384 case 0xb6: /* 2: 1011 0110 */
385 arg = opram[PC++ - pc];
386 sprintf(dst, "jf0 $%04X", (PC & 0x700) | arg);
387 break;
388 case 0xb7: /* 1: 1011 0111 */
389 sprintf(dst, "ill");
390 break;
391 case 0xb8: /* 1: 1011 1rrr */
392 case 0xb9: /* 1: 1011 1rrr */
393 case 0xba: /* 1: 1011 1rrr */
394 case 0xbb: /* 1: 1011 1rrr */
395 case 0xbc: /* 1: 1011 1rrr */
396 case 0xbd: /* 1: 1011 1rrr */
397 case 0xbe: /* 1: 1011 1rrr */
398 case 0xbf: /* 1: 1011 1rrr */
399 sprintf(dst, "mov r%d,#$%02X", op&7, opram[PC++ - pc]);
400 break;
401 case 0xc0: /* 1: 1100 0000 */
402 sprintf(dst, "ill");
403 break;
404 case 0xc1: /* 1: 1100 0001 */
405 sprintf(dst, "ill");
406 break;
407 case 0xc2: /* 1: 1100 0010 */
408 sprintf(dst, "ill");
409 break;
410 case 0xc3: /* 1: 1100 0011 */
411 sprintf(dst, "ill");
412 break;
413 case 0xc5: /* 1: 1100 0101 */
414 sprintf(dst, "sel rb0");
415 break;
416 case 0xc6: /* 2: 1100 0110 */
417 arg = opram[PC++ - pc];
418 sprintf(dst, "jz $%04X", (PC & 0x700) | arg);
419 break;
420 case 0xc7: /* 1: 1100 0111 */
421 sprintf(dst, "mov a,psw");
422 break;
423 case 0xc8: /* 1: 1100 1rrr */
424 case 0xc9: /* 1: 1100 1rrr */
425 case 0xca: /* 1: 1100 1rrr */
426 case 0xcb: /* 1: 1100 1rrr */
427 case 0xcc: /* 1: 1100 1rrr */
428 case 0xcd: /* 1: 1100 1rrr */
429 case 0xce: /* 1: 1100 1rrr */
430 case 0xcf: /* 1: 1100 1rrr */
431 sprintf(dst, "dec r%d", op&7);
432 break;
433 case 0xd0: /* 1: 1101 000r */
434 case 0xd1: /* 1: 1101 000r */
435 sprintf(dst, "xrl a,@r%d", op&1);
436 break;
437 case 0xd3: /* 1: 1101 0011 */
438 sprintf(dst, "xrl a,#$%02X", opram[PC++ - pc]);
439 break;
440 case 0xd5: /* 1: 1101 0101 */
441 sprintf(dst, "sel rb1");
442 break;
443 case 0xd6: /* 2: 1101 0110 */
444 arg = opram[PC++ - pc];
445 sprintf(dst, "jnibf $%04X", (PC & 0x700) | arg);
446 break;
447 case 0xd7: /* 1: 1101 0111 */
448 sprintf(dst, "mov psw,a");
449 break;
450 case 0xd8: /* 1: 1101 1rrr */
451 case 0xd9: /* 1: 1101 1rrr */
452 case 0xda: /* 1: 1101 1rrr */
453 case 0xdb: /* 1: 1101 1rrr */
454 case 0xdc: /* 1: 1101 1rrr */
455 case 0xdd: /* 1: 1101 1rrr */
456 case 0xde: /* 1: 1101 1rrr */
457 case 0xdf: /* 1: 1101 1rrr */
458 sprintf(dst, "xrl a,r%d", op&7);
459 break;
460 case 0xe0: /* 1: 1110 0000 */
461 sprintf(dst, "ill");
462 break;
463 case 0xe1: /* 1: 1110 0001 */
464 sprintf(dst, "ill");
465 break;
466 case 0xe2: /* 1: 1110 0010 */
467 sprintf(dst, "ill");
468 break;
469 case 0xe3: /* 2: 1110 0011 */
470 sprintf(dst, "movp3 a,@a");
471 break;
472 case 0xe5: /* 1: 1110 0101 */
473 sprintf(dst, "en dma");
474 break;
475 case 0xe6: /* 2: 1110 0110 */
476 arg = opram[PC++ - pc];
477 sprintf(dst, "jnc $%04X", (PC & 0x700) | arg);
478 break;
479 case 0xe7: /* 1: 1110 0111 */
480 sprintf(dst, "rl a");
481 break;
482 case 0xe8: /* 2: 1110 1rrr */
483 case 0xe9: /* 2: 1110 1rrr */
484 case 0xea: /* 2: 1110 1rrr */
485 case 0xeb: /* 2: 1110 1rrr */
486 case 0xec: /* 2: 1110 1rrr */
487 case 0xed: /* 2: 1110 1rrr */
488 case 0xee: /* 2: 1110 1rrr */
489 case 0xef: /* 2: 1110 1rrr */
490 arg = opram[PC++ - pc];
491 sprintf(dst, "djnz r%d,$%04X", op&7, (PC & 0x700) | arg);
492 flags = DASMFLAG_STEP_OVER;
493 break;
494 case 0xf0: /* 1: 1111 000r */
495 case 0xf1: /* 1: 1111 000r */
496 sprintf(dst, "mov a,@r%d", op&1);
497 break;
498 case 0xf3: /* 1: 1111 0011 */
499 sprintf(dst, "ill");
500 break;
501 case 0xf5: /* 1: 1111 0101 */
502 sprintf(dst, "en flags");
503 break;
504 case 0xf6: /* 2: 1111 0110 */
505 arg = opram[PC++ - pc];
506 sprintf(dst, "jc $%04X", (PC & 0x700) | arg);
507 break;
508 case 0xf7: /* 1: 1111 0111 */
509 sprintf(dst, "rlc a");
510 break;
511 case 0xf8: /* 1: 1111 1rrr */
512 case 0xf9: /* 1: 1111 1rrr */
513 case 0xfa: /* 1: 1111 1rrr */
514 case 0xfb: /* 1: 1111 1rrr */
515 case 0xfc: /* 1: 1111 1rrr */
516 case 0xfd: /* 1: 1111 1rrr */
517 case 0xfe: /* 1: 1111 1rrr */
518 case 0xff: /* 1: 1111 1rrr */
519 sprintf(dst, "mov a,r%d", op&7);
520 break;
521 }
522 return (PC - pc) | flags | DASMFLAG_SUPPORTED;
523 }
524