From 2fd4625d744bd5b13fe6b5c1d19d1a375142128f Mon Sep 17 00:00:00 2001 From: Matthew Stanley <1379tech@gmail.com> Date: Sun, 4 Oct 2026 10:50:02 -0700 Subject: [PATCH] disasm: print word 0 as bare NOP Co-Authored-By: Claude Opus 5.5 (1M context) --- runtime/src/disasm_shim.cpp | 2 ++ runtime/tests/test_disasm.cpp | 1 + 2 files changed, 3 insertions(+) diff --git a/runtime/src/disasm_shim.cpp b/runtime/src/disasm_shim.cpp index 46a7fdfc..159535d4 100644 --- a/runtime/src/disasm_shim.cpp +++ b/runtime/src/disasm_shim.cpp @@ -65,6 +65,8 @@ extern "C" int psx_disasm_one(uint32_t word, uint32_t addr, char* out, int cap) int n; if (d.format == InstrFormat::UNKNOWN) { n = std::snprintf(out, (size_t)cap, ".word 0x%08X", word); + } else if (word == 0u) { + n = std::snprintf(out, (size_t)cap, "NOP"); } else if (std::strcmp(m, "JR") == 0) { n = std::snprintf(out, (size_t)cap, "%-8s %s", m, rn(d.rs)); } else if (std::strcmp(m, "JALR") == 0) { diff --git a/runtime/tests/test_disasm.cpp b/runtime/tests/test_disasm.cpp index 69bc463e..2ba577d0 100644 --- a/runtime/tests/test_disasm.cpp +++ b/runtime/tests/test_disasm.cpp @@ -19,6 +19,7 @@ static void check(unsigned word, unsigned pc, const char* expected) { CHECK(n == (int)std::strlen(expected)); } int main() { + check(0,0,"NOP"); check(0x012A4020,0,"ADD $t0, $t1, $t2"); check(0x012A0018,0,"MULT $t1, $t2"); check(0x012A001B,0,"DIVU $t1, $t2");