16 static char *mnemonic_table
[256] =
276 static char *cb_mnemonic_table
[256] =
536 static byte operand_count
[256] =
538 1, 3, 1, 1, 1, 1, 2, 1, 3, 1, 1, 1, 1, 1, 2, 1,
539 1, 3, 1, 1, 1, 1, 2, 1, 2, 1, 1, 1, 1, 1, 2, 1,
540 2, 3, 1, 1, 1, 1, 2, 1, 2, 1, 1, 1, 1, 1, 2, 1,
541 2, 3, 1, 1, 1, 1, 2, 1, 2, 1, 1, 1, 1, 1, 2, 1,
542 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
543 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
544 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
545 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
546 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
547 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
548 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
549 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
550 1, 1, 3, 3, 3, 1, 2, 1, 1, 1, 3, 2, 3, 3, 2, 1,
551 1, 1, 3, 1, 3, 1, 2, 1, 1, 1, 3, 1, 3, 1, 2, 1,
552 2, 1, 1, 1, 1, 1, 2, 1, 2, 1, 3, 1, 1, 1, 2, 1,
553 2, 1, 1, 1, 1, 1, 2, 1, 2, 1, 3, 1, 1, 1, 2, 1
557 /* replace with a real interactive debugger eventually... */
561 rcvar_t debug_exports
[] =
563 RCV_BOOL("trace", &debug_trace
),
567 void debug_disassemble(addr a
, int c
)
573 static char mnemonic
[256];
574 static char *pattern
;
576 if (!debug_trace
) return;
581 code
= ops
[k
++] = readb(a
); a
++;
584 pattern
= mnemonic_table
[code
];
586 pattern
= "***INVALID***";
590 code
= ops
[k
++] = readb(a
); a
++;
591 pattern
= cb_mnemonic_table
[code
];
596 if (pattern
[i
] == '%')
598 switch (pattern
[++i
])
602 ops
[k
] = readb(a
); a
++;
603 j
+= sprintf(mnemonic
+ j
,
608 ops
[k
] = readb(a
); a
++;
609 ops
[k
+1] = readb(a
); a
++;
610 j
+= sprintf(mnemonic
+ j
, "%04Xh",
611 ((ops
[k
+1] << 8) | ops
[k
]));
616 ops
[k
] = readb(a
); a
++;
617 j
+= sprintf(mnemonic
+ j
, "%+d",
625 mnemonic
[j
++] = pattern
[i
++];
629 printf("%04X ", opaddr
);
630 switch (operand_count
[ops
[0]]) {
632 printf("%02X ", ops
[0]);
635 printf("%02X %02X ", ops
[0], ops
[1]);
638 printf("%02X %02X %02X ", ops
[0], ops
[1], ops
[2]);
641 printf("%-16.16s", mnemonic
);
643 " SP=%04X.%04X BC=%04X.%02X.%02X DE=%04X.%02X "
644 "HL=%04X.%02X A=%02X F=%02X %c%c%c%c%c",
646 BC
, readb(BC
), readb(0xFF00 | C
),
649 F
, (IME
? 'I' : '-'),
650 ((F
& 0x80) ? 'Z' : '-'),
651 ((F
& 0x40) ? 'N' : '-'),
652 ((F
& 0x20) ? 'H' : '-'),
653 ((F
& 0x10) ? 'C' : '-')
656 " IE=%02X IF=%02X LCDC=%02X STAT=%02X LY=%02X LYC=%02X",
657 R_IE
, R_IF
, R_LCDC
, R_STAT
, R_LY
, R_LYC