--- nono/m680x0/testea.cpp 2026/04/29 17:05:15 1.1.1.3 +++ nono/m680x0/testea.cpp 2026/04/29 17:05:40 1.1.1.5 @@ -9,8 +9,27 @@ class MPU680x0Test : public MPU680x0Device { public: + MPU680x0Test() { } + ~MPU680x0Test() override { } void test_ea_ix(); void test_ea_ix2(); + + uint32 fetch_2() override; + uint32 fetch_4() override; + uint32 read_data(busaddr addr) override; + void write_data(busaddr addr, uint32 data) override; + + bool TranslateRead() override { return true; } + bool TranslateWrite() override { return true; } + busaddr TranslatePeek(busaddr) override { return busaddr(0); } + void CalcStat() override { } + bool ops_movec_rc_rn_cpu(uint, uint) override { return true; } + bool ops_movec_rn_rc_cpu(uint, uint) override { return true; } + void ops_mmu30() override { } + void ops_mmu40_pflush() override { } + void ResetMMU() override { } + void ResetCache() override { } + void SetCACR(uint32) override { } }; static uint16 g_fetch[5]; @@ -19,7 +38,7 @@ static int g_fetch_ptr; // ダミーのフェッチルーチン // グローバル変数 g_fetch[] で指定された値を順に返す uint32 -MPU680x0Device::fetch_16() +MPU680x0Test::fetch_2() { uint16 data; @@ -31,26 +50,69 @@ MPU680x0Device::fetch_16() } uint32 -MPU680x0Device::fetch_32() +MPU680x0Test::fetch_4() { uint32 data; - data = fetch_16() << 16; - data |= fetch_16(); + data = fetch_2() << 16; + data |= fetch_2(); return data; } -uint32 MPU680x0Device::read_8(uint32 ea) { return 0; } -uint32 MPU680x0Device::read_16(uint32 ea) { return 0; } + // ダミーリード // アドレスを2倍にして返す。 // メモリ間接の post index、pre index を演算だけで判別するため。 uint32 -MPU680x0Device::read_32(uint32 ea) { - return ea << 1; +MPU680x0Test::read_data(busaddr laddr) +{ + if (laddr.GetSize() == 4) { + return laddr.Addr() << 1; + } + return 0; +} + +void +MPU680x0Test::write_data(busaddr laddr, uint32 data) +{ } -void MPU680x0Device::write_8(uint32 ea, uint32 data) { } -void MPU680x0Device::write_16(uint32 ea, uint32 data) { } -void MPU680x0Device::write_32(uint32 ea, uint32 data) { } + +// リンクを通すためのダミー。 +Object::Object(uint) { } +Object::~Object() { } +Device::Device(uint) : inherited(0) { } +Device::~Device() { } +MPUDevice::MPUDevice(uint) : inherited(0) { } +MPUDevice::~MPUDevice() { } +MainMPUDevice::MainMPUDevice() : inherited(0) { } +MainMPUDevice::~MainMPUDevice() { } +MPU680x0Device::MPU680x0Device() { } +MPU680x0Device::~MPU680x0Device() { } +Event::Event(Device *) { } +Event::~Event() { } +BranchHistory::BranchHistory(uint) : inherited(0) { } +BranchHistory::~BranchHistory() { } +BranchHistory_m680x0::BranchHistory_m680x0(uint) : inherited(0) { } +BranchHistory_m680x0::~BranchHistory_m680x0() { } +void Object::SetLogLevel(int) { } +void Object::putlogn(const char *, ...) const { } +void Device::putlogn(const char *, ...) const { } +bool Device::Create() { return true; } +bool Device::Create2() { return true; } +bool Device::Init() { return true; } +void Device::ResetHard(bool) { } +bool Device::Apply() { return true; } +void Device::PowerOff() { } +bool MPUDevice::Init() { return true; } +void MPUDevice::PowerOff() { } +bool MainMPUDevice::Init() { return true; } +bool MPU680x0Device::Init() { return true; } +void MPU680x0Device::ResetHard(bool) { } +void MPU680x0Device::Interrupt(int) { } +void MPU680x0Device::SetTrace(bool) { } +std::string BranchHistory::FormatHeader() const { return ""; } +std::string BranchHistory::FormatEntry(const BranchEntry&) { return ""; } +std::string BranchHistory_m680x0::FormatEntry(const BranchEntry&) { return ""; } + void panic_func(const char *func, const char *fmt, ...) { @@ -346,10 +408,7 @@ MPU680x0Test::test_ea_ix2() int main(int ac, char *av[]) { - // 本当はコンストラクタを呼ぶべきだが、そうすると必要なオブジェクトが - // 芋づる式に増えて正しく解決するのは面倒。ここのテストではとりあえず - // 存在しててアクセスできればいい程度なのでこれで誤魔化してある。 - cpu = (MPU680x0Test *)calloc(sizeof(*cpu), 1); + cpu = new MPU680x0Test(); // 引数が何かあればテストパターン生成、なければテスト。 // XXX そのうち整備する。