+#ifdef DEBUG_ILLEGAL
+if (!tripped)
+{
+ backTrace[btPtr] = regs.RdMem(regs.pc);
+ btRegs[btPtr] = regs;
+ btPtr = (btPtr + 1) & 0xFF;
+
+ if (regs.cpuFlags & V6809_STATE_ILLEGAL_INST)
+ {
+ WriteLog("V6809: Executed illegal instruction!!!!\n\nBacktrace:\n\n");
+ regs.cpuFlags &= ~V6809_STATE_ILLEGAL_INST;
+
+ for(uint16 i=btPtr; i<btPtr+256; i++)
+ {
+ Decode6809(btRegs[i & 0xFF].pc);
+// Note that these values are *before* execution, so stale...
+ WriteLog("\n\tA=%02X B=%02X CC=%02X DP=%02X X=%04X Y=%04X S=%04X U=%04X PC=%04X\n",
+ btRegs[i & 0xFF].a, btRegs[i & 0xFF].b, btRegs[i & 0xFF].cc, btRegs[i & 0xFF].dp, btRegs[i & 0xFF].x, btRegs[i & 0xFF].y, btRegs[i & 0xFF].s, btRegs[i & 0xFF].u, btRegs[i & 0xFF].pc);//*/
+ }
+
+ tripped = true;
+ }
+}
+#endif