diff --git a/InstructionSets/M68k/Executor.hpp b/InstructionSets/M68k/Executor.hpp index e9ca48b72..35009461f 100644 --- a/InstructionSets/M68k/Executor.hpp +++ b/InstructionSets/M68k/Executor.hpp @@ -63,6 +63,9 @@ template class Executor { public: Executor(BusHandler &); + /// Reset the processor, back to a state as if just externally reset. + void reset(); + /// Executes the number of instructions specified; /// other events — such as initial reset or branching /// to exceptions — may be zero costed, and interrupts @@ -90,14 +93,12 @@ template class Executor { void set_state(const Registers &); private: - /// Reset the processor, back to a state as if just externally reset. - void reset(); - class State: public NullFlowController { public: State(BusHandler &handler) : bus_handler_(handler) {} void run(int &); + bool stopped = false; void read(DataSize size, uint32_t address, CPU::SlicedInt32 &value); void write(DataSize size, uint32_t address, CPU::SlicedInt32 value); diff --git a/InstructionSets/M68k/Implementation/ExecutorImplementation.hpp b/InstructionSets/M68k/Implementation/ExecutorImplementation.hpp index add5cc1d9..ca9d19ce3 100644 --- a/InstructionSets/M68k/Implementation/ExecutorImplementation.hpp +++ b/InstructionSets/M68k/Implementation/ExecutorImplementation.hpp @@ -37,6 +37,9 @@ void Executor::reset() { state_.status.set_status(0b0010'0011'1000'0000); state_.did_update_status(); + // Clear the STOPped state, if currently active. + state_.stopped = false; + // Seed stack pointer and program counter. sp.l = state_.template read(0) & 0xffff'fffe; state_.program_counter.l = state_.template read(4); @@ -50,10 +53,13 @@ void Executor::signal_bus_error(FunctionCode code, uint32_t a template void Executor::set_interrupt_level(int level) { state_.interrupt_input_ = level; + state_.stopped &= state_.interrupt_input_ <= state_.status.interrupt_level; } template void Executor::run_for_instructions(int count) { + if(state_.stopped) return; + while(count > 0) { try { state_.run(count); @@ -438,7 +444,9 @@ void Executor::State::did_update_status() { } template -void Executor::State::stop() {} +void Executor::State::stop() { + stopped = true; +} template void Executor::State::reset() {