--- nono/m680x0/testea.cpp 2026/04/29 17:05:26 1.1.1.4 +++ nono/m680x0/testea.cpp 2026/04/29 17:05:48 1.1.1.6 @@ -5,12 +5,35 @@ // #include "mpu680x0.h" +#define M680X0_CYCLE_TABLE +#include "m680x0cycle.h" class MPU680x0Test : public MPU680x0Device { public: + MPU680x0Test() { + cycle_table = cycle_table_030cc; + } + ~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 +42,7 @@ static int g_fetch_ptr; // ダミーのフェッチルーチン // グローバル変数 g_fetch[] で指定された値を順に返す uint32 -MPU680x0Device::fetch_2() +MPU680x0Test::fetch_2() { uint16 data; @@ -31,7 +54,7 @@ MPU680x0Device::fetch_2() } uint32 -MPU680x0Device::fetch_4() +MPU680x0Test::fetch_4() { uint32 data; @@ -44,7 +67,7 @@ MPU680x0Device::fetch_4() // アドレスを2倍にして返す。 // メモリ間接の post index、pre index を演算だけで判別するため。 uint32 -MPU680x0Device::read_data(busaddr laddr) +MPU680x0Test::read_data(busaddr laddr) { if (laddr.GetSize() == 4) { return laddr.Addr() << 1; @@ -53,10 +76,44 @@ MPU680x0Device::read_data(busaddr laddr) } void -MPU680x0Device::write_data(busaddr laddr, uint32 data) +MPU680x0Test::write_data(busaddr laddr, 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() { } +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) { } +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, ...) { @@ -352,10 +409,7 @@ MPU680x0Test::test_ea_ix2() int main(int ac, char *av[]) { - // 本当はコンストラクタを呼ぶべきだが、そうすると必要なオブジェクトが - // 芋づる式に増えて正しく解決するのは面倒。ここのテストではとりあえず - // 存在しててアクセスできればいい程度なのでこれで誤魔化してある。 - cpu = (MPU680x0Test *)calloc(sizeof(*cpu), 1); + cpu = new MPU680x0Test(); // 引数が何かあればテストパターン生成、なければテスト。 // XXX そのうち整備する。