In emu_68000_alt, implement traps (BYE command for TBI68K), implement reg trace
authorNick Downing <nick@ndcode.org>
Sun, 21 Aug 2022 08:52:59 +0000 (18:52 +1000)
committerNick Downing <nick@ndcode.org>
Sun, 21 Aug 2022 12:09:29 +0000 (22:09 +1000)
Musashi
emu_68000.c

diff --git a/Musashi b/Musashi
index 3e0087b..5b2b80f 160000 (submodule)
--- a/Musashi
+++ b/Musashi
@@ -1 +1 @@
-Subproject commit 3e0087bd34b3f7c4e6d7eb847b85e388190740b9
+Subproject commit 5b2b80f4b42ea251093583aac1d19033bb37f35c
index b2ca8f7..762038d 100644 (file)
@@ -10,6 +10,8 @@
 #include "cpu_68000.h"
 #endif
 
+#define EXCEPTION_TRAP_BASE 0x20
+
 #define REG_TRACE 0
 #define MEM_TRACE 0
 
@@ -275,6 +277,13 @@ int cpu_irq_ack(int level)
 //     return M68K_INT_ACK_SPURIOUS;
   return 0;
 }
+
+int m68k_service_trap(unsigned int vector) {
+  //fprintf(stderr, "trap %x\n", vector);
+  if (vector == EXCEPTION_TRAP_BASE + 0xe) // TBI68K bye command
+    exit(EXIT_SUCCESS);
+  return 0;
+}
 #endif
 
 int main(int argc, char **argv) {
@@ -295,21 +304,33 @@ int main(int argc, char **argv) {
 
   while (true) {
 #if REG_TRACE
+    int sr = m68k_get_reg(NULL, M68K_REG_SR);
     fprintf(
       stderr,
-      "pc=%04x a=%02x b=%02x s=%04x x=%04x p=%02x hf=%d if=%d nf=%d zf=%d vf=%d cf=%d\n",
-      regs.pc,
-      regs.accd.a,
-      regs.accd.b,
-      regs.sp,
-      regs.ix,
-      regs.ccr | 0xc0,
-      (regs.ccr >> 5) & 1,
-      (regs.ccr >> 4) & 1,
-      (regs.ccr >> 3) & 1,
-      (regs.ccr >> 2) & 1,
-      (regs.ccr >> 1) & 1,
-      regs.ccr & 1
+      "pc=%08x d0=%08x d1=%08x d2=%08x d3=%08x d4=%08x d5=%08x d6=%08x d7=%08x a0=%08x a1=%08x a2=%08x a3=%08x a4=%08x a5=%08x a6=%08x a7=%08x sr=%04x xf=%d nf=%d zf=%d vf=%d cf=%d\n",
+      m68k_get_reg(NULL, M68K_REG_PC),
+      m68k_get_reg(NULL, M68K_REG_D0),
+      m68k_get_reg(NULL, M68K_REG_D1),
+      m68k_get_reg(NULL, M68K_REG_D2),
+      m68k_get_reg(NULL, M68K_REG_D3),
+      m68k_get_reg(NULL, M68K_REG_D4),
+      m68k_get_reg(NULL, M68K_REG_D5),
+      m68k_get_reg(NULL, M68K_REG_D6),
+      m68k_get_reg(NULL, M68K_REG_D7),
+      m68k_get_reg(NULL, M68K_REG_A0),
+      m68k_get_reg(NULL, M68K_REG_A1),
+      m68k_get_reg(NULL, M68K_REG_A2),
+      m68k_get_reg(NULL, M68K_REG_A3),
+      m68k_get_reg(NULL, M68K_REG_A4),
+      m68k_get_reg(NULL, M68K_REG_A5),
+      m68k_get_reg(NULL, M68K_REG_A6),
+      m68k_get_reg(NULL, M68K_REG_A7),
+      sr,
+      (sr >> 4) & 1,
+      (sr >> 3) & 1,
+      (sr >> 2) & 1,
+      (sr >> 1) & 1,
+      sr & 1
     );
 #endif