--- nono/hd64180/hd64180core.cpp 2026/04/29 17:05:30 1.1.1.2 +++ nono/hd64180/hd64180core.cpp 2026/04/29 17:05:51 1.1.1.6 @@ -10,6 +10,7 @@ #include "mpu64180.h" #include "debugger.h" +#include "event.h" #include "hd64180.h" #include "hd647180.h" #include "scheduler.h" @@ -19,7 +20,7 @@ #include "hd64180ops.cpp" void -MPU64180Device::ExecNormal(Event& ev) +MPU64180Device::ExecNormal(Event *ev) { uint64 cycle_start = used_cycle; @@ -59,7 +60,7 @@ MPU64180Device::ExecNormal(Event& ev) } int cycle = used_cycle - cycle_start; - ev.time = cycle * clock_nsec; + ev->time = cycle * clock_nsec; scheduler->StartEvent(ev); } @@ -91,7 +92,14 @@ MPU64180Device::op_illegal(int pos) // PC は未定義命令の先頭番地ではなく、未定義 opcode だった位置? // nono の実装ではフェッチと同時にインクリメントしているので、 // 1つ前でいい? HD64180.pdf p38-39 - Push2(reg.pc - 1); + if (pos == 2) { + Push2(reg.pc - 1); + } else { + // DD CB d OP xx + // ^ PC + // d の位置をスタックに積む + Push2(reg.pc - 2); + } ExceptionDirect(HD647180::IntmapTRAP, 0x0000); } @@ -103,15 +111,15 @@ MPU64180Device::Jump(uint16 addr) // 命令本体(オペランドを含まない)を16ビット左詰めにする。 // 分岐命令は1バイト命令か ED XX か DD/FD XX の2バイト命令しかないはず。 - //上位ワードは $0000。 - uint32 inst; + // 上位ワードは $0000。 + uint32 info; if (ops[0] == 0xed || ops[0] == 0xdd || ops[0] == 0xfd) { - inst = (ops[0] << 8) | ops[1]; + info = (ops[0] << 8) | ops[1]; } else { - inst = (ops[0] << 8); + info = (ops[0] << 8); } - brhist.AddEntry(GetPPC(), addr, inst); + brhist.AddEntry(GetPPC(), addr, info); } // @@ -185,6 +193,20 @@ MPU64180Device::NegateINT0() NegateIntmap(HD647180::IntmapINT0); } +// ASCIn 割り込みをアサート/ネゲートする。 +// IEF1 はこちらで加味する。 +void +MPU64180Device::ChangeASCIInt(uint n, bool asci_req) +{ + uint32 map = HD647180::IntmapASCI(n); + + if ((asci_req && GetIEF1())) { + AssertIntmap(map); + } else { + NegateIntmap(map); + } +} + // マスカブル割り込みを処理する。(命令境界で呼ばれる) void MPU64180Device::DoInterrupt()