--- nono/m680x0/m68030subr.cpp 2026/04/29 17:04:38 1.1.1.3 +++ nono/m680x0/m68030subr.cpp 2026/04/29 17:04:40 1.1.1.4 @@ -54,12 +54,28 @@ m68030_double_bus_fault(m68kcpu *cpu, co void m68030_exception_reset(m68kcpu *cpu) { - // 例外履歴ちょっとどうするかは置いておく + // 履歴を初期化。リセット前の履歴いらんよな? + cpu->exhist.Clear(); + cpu->brhist.Clear(); + + // 例外履歴に記録 (例外発生はブランチ履歴にも記録) + // リセット例外発生時の PC にはあまり意味がないので 0 にするか。 + // 履歴のリセットベクタは 0 の代わりに 1 を使う仕様になっている。 + const uint vector = 0; + cpu->exhist.AddEntry(0, 0, 0x8000 | (vector + 1)); + cpu->brhist.AddEntry(0, 0, 0x8000 | (vector + 1)); + // デバッガに通知 (例外ブレーク用)。こっちのベクタは 0 のままでよい。 + debugger_notify_exception(vector); // 1. T0, T1 クリア // 2. S をセット、M をクリア // 3. 割り込みレベルを 7 + // 受け付け中だった割り込みをクリア + cpu->intrmtx.lock(); + memset(&cpu->intr_vector, 0, sizeof(cpu->intr_vector)); + cpu->intrmtx.unlock(); + // ここは set_sr を使わずに設定する。 cpu->reg.s = true; cpu->reg.m = false; @@ -90,6 +106,8 @@ m68030_exception_reset(m68kcpu *cpu) try { RegA(7) = m68030_read_32(cpu, cpu->reset_vector); RegPC = m68030_read_32(cpu, cpu->reset_vector + 4); + // リセットベクタは常に 0, 4 番地から取得したことになっている + cpu->brhist.AddEntry(0x00000004, RegPC, 0x8000); } catch (int) { m68030_double_bus_fault(cpu, "reset exception"); } @@ -398,7 +416,7 @@ m68030_exception(m68kcpu *cpu, int vecto cpu->exhist.AddEntry(RegPPC, 0, 0x8000 | vector); cpu->brhist.AddEntry(RegPPC, 0, 0x8000 | vector); // デバッガに通知 (例外ブレーク用) - debugger_notifyexception(vector); + debugger_notify_exception(vector); // 状態を保存 uint16 sr = RegSR; @@ -456,7 +474,7 @@ m68030_exception_buserr(m68kcpu *cpu, in cpu->exhist.AddEntry(RegPPC, 0, 0x8000 | vector); cpu->brhist.AddEntry(RegPPC, 0, 0x8000 | vector); // デバッガに通知 (例外ブレーク用) - debugger_notifyexception(vector); + debugger_notify_exception(vector); // 状態を保存 uint16 sr = RegSR; @@ -500,7 +518,7 @@ m68030_exception_interrupt(m68kcpu *cpu, cpu->exhist.AddEntry(RegPPC, 0, 0x8000 | (level << 8) | vector); cpu->brhist.AddEntry(RegPPC, 0, 0x8000 | (level << 8) | vector); // デバッガに通知 (例外ブレーク用) - debugger_notifyexception(vector); + debugger_notify_exception(vector); // 状態を保存 uint16 sr = RegSR;