From 93615f6647eeedb05068627daa87bd62af801406 Mon Sep 17 00:00:00 2001 From: Thomas Harte <thomas.harte@gmail.com> Date: Wed, 15 Jun 2022 10:50:03 -0400 Subject: [PATCH 1/4] Apply new status before entering STOP loop. --- .../Implementation/68000Mk2Implementation.hpp | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/Processors/68000Mk2/Implementation/68000Mk2Implementation.hpp b/Processors/68000Mk2/Implementation/68000Mk2Implementation.hpp index 1acfef412..8eb34a825 100644 --- a/Processors/68000Mk2/Implementation/68000Mk2Implementation.hpp +++ b/Processors/68000Mk2/Implementation/68000Mk2Implementation.hpp @@ -27,6 +27,7 @@ enum ExecutionState: int { Reset = std::numeric_limits<int>::min(), Decode, WaitForDTACK, + WaitForInterrupt, StoreOperand, StoreOperand_bw, @@ -377,14 +378,20 @@ void Processor<BusHandler, dtack_is_implicit, permit_overrun, signal_will_perfor } MoveToStateSpecific(WaitForDTACK); - // Spin in place until an interrupt arrives. BeginState(STOP): - IdleBus(1); + // Apply the suffix status. + status_.set_status(operand_[0].w); + did_update_status(); + [[fallthrough]]; + + BeginState(WaitForInterrupt): + // Spin in place until an interrupt arrives. captured_interrupt_level_ = bus_interrupt_level_; if(status_.would_accept_interrupt(captured_interrupt_level_)) { MoveToStateSpecific(DoInterrupt); } - MoveToStateSpecific(STOP); + IdleBus(1); + MoveToStateSpecific(WaitForInterrupt); // Perform the RESET exception, which seeds the stack pointer and program // counter, populates the prefetch queue, and then moves to instruction dispatch. From 5420fd5aa3421705052d134b10c505b0d6604241 Mon Sep 17 00:00:00 2001 From: Thomas Harte <thomas.harte@gmail.com> Date: Wed, 15 Jun 2022 10:54:14 -0400 Subject: [PATCH 2/4] Fix: new status word is still in prefetch. --- Processors/68000Mk2/Implementation/68000Mk2Implementation.hpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Processors/68000Mk2/Implementation/68000Mk2Implementation.hpp b/Processors/68000Mk2/Implementation/68000Mk2Implementation.hpp index 8eb34a825..b1222483f 100644 --- a/Processors/68000Mk2/Implementation/68000Mk2Implementation.hpp +++ b/Processors/68000Mk2/Implementation/68000Mk2Implementation.hpp @@ -380,7 +380,7 @@ void Processor<BusHandler, dtack_is_implicit, permit_overrun, signal_will_perfor BeginState(STOP): // Apply the suffix status. - status_.set_status(operand_[0].w); + status_.set_status(prefetch_.w); did_update_status(); [[fallthrough]]; From bd056973ba68438383dc48c98a8bcd1d1fbc3142 Mon Sep 17 00:00:00 2001 From: Thomas Harte <thomas.harte@gmail.com> Date: Wed, 15 Jun 2022 10:56:45 -0400 Subject: [PATCH 3/4] Don't allow STOP state to block execution. --- Processors/68000Mk2/Implementation/68000Mk2Implementation.hpp | 1 + 1 file changed, 1 insertion(+) diff --git a/Processors/68000Mk2/Implementation/68000Mk2Implementation.hpp b/Processors/68000Mk2/Implementation/68000Mk2Implementation.hpp index b1222483f..7b043d56c 100644 --- a/Processors/68000Mk2/Implementation/68000Mk2Implementation.hpp +++ b/Processors/68000Mk2/Implementation/68000Mk2Implementation.hpp @@ -391,6 +391,7 @@ void Processor<BusHandler, dtack_is_implicit, permit_overrun, signal_will_perfor MoveToStateSpecific(DoInterrupt); } IdleBus(1); + CheckOverrun(); MoveToStateSpecific(WaitForInterrupt); // Perform the RESET exception, which seeds the stack pointer and program From 24823233ff6eecf81c3656bbf86c054969b4f280 Mon Sep 17 00:00:00 2001 From: Thomas Harte <thomas.harte@gmail.com> Date: Wed, 15 Jun 2022 11:00:27 -0400 Subject: [PATCH 4/4] Add spurious interrupt support. --- .../68000Mk2/Implementation/68000Mk2Implementation.hpp | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/Processors/68000Mk2/Implementation/68000Mk2Implementation.hpp b/Processors/68000Mk2/Implementation/68000Mk2Implementation.hpp index 7b043d56c..f26df65c8 100644 --- a/Processors/68000Mk2/Implementation/68000Mk2Implementation.hpp +++ b/Processors/68000Mk2/Implementation/68000Mk2Implementation.hpp @@ -595,8 +595,12 @@ void Processor<BusHandler, dtack_is_implicit, permit_overrun, signal_will_perfor if(vpa_) { temporary_value_.b = uint8_t(InstructionSet::M68k::Exception::InterruptAutovectorBase - 1 + captured_interrupt_level_); } + if(berr_) { + temporary_value_.b = uint8_t(InstructionSet::M68k::Exception::SpuriousInterrupt); + } - // TODO: if bus error is set, treat interrupt as spurious. + // TODO: check documentation for other potential interrupt outcomes; + // and presumably spin here if DTACK isn't implicit. IdleBus(3); // n- n