1 |
|
/* |
2 |
|
* mon_z80.cpp - Z80 disassembler |
3 |
|
* |
4 |
< |
* cxmon (C) 1997-2002 Christian Bauer, Marc Hellwig |
4 |
> |
* cxmon (C) 1997-2003 Christian Bauer, Marc Hellwig |
5 |
|
* |
6 |
|
* This program is free software; you can redistribute it and/or modify |
7 |
|
* it under the terms of the GNU General Public License as published by |
46 |
|
A_COND, // condition code (bits 3..5 of opcode) |
47 |
|
A_COND2, // condition code (bits 3..4 of opcode) |
48 |
|
A_BIT, // bit number (bits 3..5 of opcode) |
49 |
+ |
A_BIT_REG1, // bit number (bits 3..5 of opcode) followed by 8-bit register (bits 0..2 of opcode) |
50 |
|
A_RST, // restart |
51 |
|
A_BC_IND, // (bc) |
52 |
|
A_DE_IND, // (de) |
53 |
|
A_HL_IND, // (hl) or (ix) or (iy) |
54 |
+ |
A_XY_IND, // (ix+d) or (iy+d) |
55 |
|
A_SP_IND, // (sp) |
56 |
|
A_DE_HL, // de,hl |
57 |
|
A_AF_AF, // af,af' |
273 |
|
mon_sprintf(f, "%d", (op >> 3) & 7); |
274 |
|
break; |
275 |
|
|
276 |
+ |
case A_BIT_REG1: { // undoc |
277 |
+ |
int reg = op & 7; |
278 |
+ |
if (reg == 6) |
279 |
+ |
mon_sprintf(f, "%d", (op >> 3) & 7); |
280 |
+ |
else |
281 |
+ |
mon_sprintf(f, "%d,%s", (op >> 3) & 7, reg_name[reg]); |
282 |
+ |
break; |
283 |
+ |
} |
284 |
+ |
|
285 |
|
case A_RST: |
286 |
|
mon_sprintf(f, "$%02x", op & 0x38); |
287 |
|
break; |
298 |
|
mon_sprintf(f, ix ? "(ix)" : (iy ? "(iy)" : "(hl)")); |
299 |
|
break; |
300 |
|
|
301 |
+ |
case A_XY_IND: // undoc |
302 |
+ |
mon_sprintf(f, "(%s+$%02x)", ix ? "ix" : "iy", mon_read_byte(adr)); adr++; |
303 |
+ |
break; |
304 |
+ |
|
305 |
|
case A_SP_IND: |
306 |
|
mon_sprintf(f, "(sp)"); |
307 |
|
break; |
352 |
|
char mnem = M_ILLEGAL, dst_mode = A_IMPL, src_mode = A_IMPL; |
353 |
|
switch (op & 0xc0) { |
354 |
|
case 0x00: |
355 |
< |
dst_mode = A_REG1; |
355 |
> |
dst_mode = A_REG1X; |
356 |
> |
if ((ix || iy) && ((op & 7) != 6)) |
357 |
> |
src_mode = A_XY_IND; |
358 |
|
switch ((op >> 3) & 7) { |
359 |
|
case 0: mnem = M_RLC; break; |
360 |
|
case 1: mnem = M_RRC; break; |
367 |
|
} |
368 |
|
break; |
369 |
|
case 0x40: |
370 |
< |
mnem = M_BIT; dst_mode = A_BIT; src_mode = A_REG1; |
370 |
> |
mnem = M_BIT; dst_mode = A_BIT; |
371 |
> |
if (ix || iy) |
372 |
> |
src_mode = A_XY_IND; |
373 |
> |
else |
374 |
> |
src_mode = A_REG1; |
375 |
|
break; |
376 |
|
case 0x80: |
377 |
< |
mnem = M_RES; dst_mode = A_BIT; src_mode = A_REG1; |
377 |
> |
mnem = M_RES; |
378 |
> |
if (ix || iy) { |
379 |
> |
dst_mode = A_BIT_REG1; |
380 |
> |
src_mode = A_XY_IND; |
381 |
> |
} else { |
382 |
> |
dst_mode = A_BIT; |
383 |
> |
src_mode = A_REG1; |
384 |
> |
} |
385 |
|
break; |
386 |
|
case 0xc0: |
387 |
< |
mnem = M_SET; dst_mode = A_BIT; src_mode = A_REG1; |
387 |
> |
mnem = M_SET; |
388 |
> |
if (ix || iy) { |
389 |
> |
dst_mode = A_BIT_REG1; |
390 |
> |
src_mode = A_XY_IND; |
391 |
> |
} else { |
392 |
> |
dst_mode = A_BIT; |
393 |
> |
src_mode = A_REG1; |
394 |
> |
} |
395 |
|
break; |
396 |
|
} |
397 |
|
|
415 |
|
case 0x60: |
416 |
|
case 0x68: |
417 |
|
case 0x78: |
418 |
< |
mon_sprintf(f, "in\t%s,(c)", reg_name[(op >> 3) & 7]); |
418 |
> |
mon_sprintf(f, "in %s,(c)", reg_name[(op >> 3) & 7]); |
419 |
|
return 1; |
420 |
|
case 0x70: |
421 |
< |
mon_sprintf(f, "in\t(c)"); |
421 |
> |
mon_sprintf(f, "in (c)"); |
422 |
|
return 1; |
423 |
|
|
424 |
|
case 0x41: |
428 |
|
case 0x61: |
429 |
|
case 0x69: |
430 |
|
case 0x79: |
431 |
< |
mon_sprintf(f, "out\t(c),%s", reg_name[(op >> 3) & 7]); |
431 |
> |
mon_sprintf(f, "out (c),%s", reg_name[(op >> 3) & 7]); |
432 |
|
return 1; |
433 |
|
case 0x71: // undoc |
434 |
< |
mon_sprintf(f, "out\t(c),0"); |
434 |
> |
mon_sprintf(f, "out (c),0"); |
435 |
|
return 1; |
436 |
|
|
437 |
|
case 0x42: |
500 |
|
break; |
501 |
|
|
502 |
|
case 0x47: |
503 |
< |
mon_sprintf(f, "ld\ti,a"); |
503 |
> |
mon_sprintf(f, "ld i,a"); |
504 |
|
return 1; |
505 |
|
case 0x4f: |
506 |
< |
mon_sprintf(f, "ld\tr,a"); |
506 |
> |
mon_sprintf(f, "ld r,a"); |
507 |
|
return 1; |
508 |
|
case 0x57: |
509 |
< |
mon_sprintf(f, "ld\ta,i"); |
509 |
> |
mon_sprintf(f, "ld a,i"); |
510 |
|
return 1; |
511 |
|
case 0x5f: |
512 |
< |
mon_sprintf(f, "ld\ta,r"); |
512 |
> |
mon_sprintf(f, "ld a,r"); |
513 |
|
return 1; |
514 |
|
|
515 |
|
case 0x67: mnem = M_RRD; break; |
533 |
|
case 0xbb: mnem = M_OTDR; break; |
534 |
|
|
535 |
|
default: |
536 |
< |
mnem = M_ILLEGAL; |
536 |
> |
mnem = M_NOP; |
537 |
|
break; |
538 |
|
} |
539 |
|
|