--- nono/m680x0/testdis.cpp 2026/04/29 17:04:28 1.1 +++ nono/m680x0/testdis.cpp 2026/04/29 17:05:15 1.1.1.6 @@ -1,11 +1,11 @@ // // nono -// Copyright (C) 2018 isaki@NetBSD.org +// Copyright (C) 2020 nono project +// Licensed under nono-license.txt // -#include "header.h" -#include "disasm.h" -#include "m68030.h" +#include "m68030disasm.h" +#include "debugger_memory.h" #include "mystring.h" #include @@ -827,30 +827,24 @@ struct { { { 0xf350 }, "frestore (a0)" }, }; -uint8 mem[1024]; -int failed; +static uint8 ram[1024]; +static int failed; -uint32 -m68030_phys_peek_8(uint32 addr) -{ - if (addr >= sizeof(mem)) { - abort(); - } - return mem[addr ^ 1]; -} +#include "test_debugger_memory.cpp" // リンカを通すためのダミー -uint64 -m68030_mmu_translate_peek(m68kcpu *cpu, uint32 addr, uint fc) -{ - return -1; -} +DisasmLine::~DisasmLine() { } +DebuggerMD::~DebuggerMD() { } int main(int ac, char *av[]) { - std::string buf; - uint32 nextpc; + saddr_t saddr; + + // DebuggerMD (の継承クラス)を用意するのは芋づる式に大変なので、 + // 中でアクセスする変数だけ強引に用意する。 + DebuggerMD *md = (DebuggerMD *)malloc(sizeof(DebuggerMD)); + md->inst_bytes = 2; for (int i = 0; i < countof(table); i++) { std::string expected = table[i].expected; @@ -863,26 +857,27 @@ main(int ac, char *av[]) } // 全体を初期化 - memset(mem, 0xdd, sizeof(mem)); + memset(ram, 0xdd, sizeof(ram)); // 100番地から命令列を書き込む for (int j = 0; j < inst.size(); j++) { - *(uint16 *)(mem + 0x100 + j * 2) = inst[j]; + *(uint16 *)(ram + 0x100 + j * 2) = inst[j]; } // 検査 - Disasm disasm; - buf = disasm.Disassemble(0x100); - nextpc = disasm.GetNextAddr(); + saddr = 0x100; + m680x0disasm dis; + DebuggerMemoryStream mem(NULL, saddr); + dis.Exec(&mem); // 照合 - if (buf != expected) { + if (dis.text != expected) { printf(">%s expects \"%s\" but \"%s\"\n", inst_str.c_str(), - expected.c_str(), buf.c_str()); + expected.c_str(), dis.text.c_str()); failed++; continue; } - uint32 expected_pc = 0x100 + inst.size() * 2; - if (nextpc != expected_pc) { - printf(">%s expects nextpc=$%x but $%x\n", inst_str.c_str(), - expected_pc, nextpc); + uint32 expected_len = inst.size() * 2; + if (dis.bin.size() != expected_len) { + printf(">%s expects len=$%x but $%x\n", inst_str.c_str(), + expected_len, (uint)dis.bin.size()); failed++; continue; }