mirror of
https://github.com/TomHarte/CLK.git
synced 2025-02-27 00:30:26 +00:00
Support STOP.
This commit is contained in:
parent
f83954f5b7
commit
27c4d19455
@ -63,6 +63,9 @@ template <Model model, typename BusHandler> 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 <Model model, typename BusHandler> 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);
|
||||
|
@ -37,6 +37,9 @@ void Executor<model, BusHandler>::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<uint32_t>(0) & 0xffff'fffe;
|
||||
state_.program_counter.l = state_.template read<uint32_t>(4);
|
||||
@ -50,10 +53,13 @@ void Executor<model, BusHandler>::signal_bus_error(FunctionCode code, uint32_t a
|
||||
template <Model model, typename BusHandler>
|
||||
void Executor<model, BusHandler>::set_interrupt_level(int level) {
|
||||
state_.interrupt_input_ = level;
|
||||
state_.stopped &= state_.interrupt_input_ <= state_.status.interrupt_level;
|
||||
}
|
||||
|
||||
template <Model model, typename BusHandler>
|
||||
void Executor<model, BusHandler>::run_for_instructions(int count) {
|
||||
if(state_.stopped) return;
|
||||
|
||||
while(count > 0) {
|
||||
try {
|
||||
state_.run(count);
|
||||
@ -438,7 +444,9 @@ void Executor<model, BusHandler>::State::did_update_status() {
|
||||
}
|
||||
|
||||
template <Model model, typename BusHandler>
|
||||
void Executor<model, BusHandler>::State::stop() {}
|
||||
void Executor<model, BusHandler>::State::stop() {
|
||||
stopped = true;
|
||||
}
|
||||
|
||||
template <Model model, typename BusHandler>
|
||||
void Executor<model, BusHandler>::State::reset() {
|
||||
|
Loading…
x
Reference in New Issue
Block a user