From ef07ad11bb0a20f137682e901a0a6beacfc08968 Mon Sep 17 00:00:00 2001 From: gbc dev Date: Fri, 17 Jul 2026 19:47:02 +0200 Subject: cpu: log the $ED poweroff opcode with pc/registers The clean-exit opcode used to print nothing, so any guest crash that walked into a stray $ED byte was indistinguishable from a silent socket death (one of the kill vectors in the link-drop investigation). Now it identifies itself on stderr with pc/af/bc/de/hl/sp. --- src/cpu.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/cpu.c b/src/cpu.c index 5b73724..e2f0ad0 100644 --- a/src/cpu.c +++ b/src/cpu.c @@ -1,4 +1,5 @@ #include "cpu.h" +#include #define FZ 0x80 #define FN 0x40 @@ -407,7 +408,11 @@ int cpu_step(GB *gb) { case 0xCB: do_cb(gb); break; - case 0xED: gb->poweroff = true; break; // (illegal on HW) clean-exit signal + case 0xED: gb->poweroff = true; // (illegal on HW) clean-exit signal + fprintf(stderr, "[sl0pboy] poweroff opcode $ED at pc=%04X (af=%04X bc=%04X " + "de=%04X hl=%04X sp=%04X)\n", (unsigned)(c->pc - 1), c->af, c->bc, + c->de, c->hl, c->sp); + break; default: // 0x40-0xBF block: LD r,r' and ALU A,r -- cgit v1.3.1-sl0p