mirror of
https://github.com/TomHarte/CLK.git
synced 2025-02-23 03:29:04 +00:00
Ensure you can't trace into divide-by-zero, etc.
This commit is contained in:
parent
002a8c061f
commit
77b56c50e6
@ -113,7 +113,10 @@ template <Model model, typename BusHandler> class Executor {
|
||||
CPU::SlicedInt32 stack_pointers[2];
|
||||
uint32_t instruction_address;
|
||||
uint16_t instruction_opcode;
|
||||
|
||||
// Things that are ephemerally duplicative of Status.
|
||||
int active_stack_pointer = 0;
|
||||
Status::FlagT should_trace = 0;
|
||||
|
||||
// Bus state.
|
||||
int interrupt_input = 0;
|
||||
|
@ -69,6 +69,9 @@ void Executor<model, BusHandler>::run_for_instructions(int count) {
|
||||
state_.status.trace_flag = 0;
|
||||
state_.did_update_status();
|
||||
|
||||
// Ensure no tracing occurs into the exception.
|
||||
state_.should_trace = 0;
|
||||
|
||||
// Push status and the program counter at instruction start.
|
||||
state_.template write<uint16_t>(sp.l - 14, code);
|
||||
state_.template write<uint32_t>(sp.l - 12, faulting_address);
|
||||
@ -322,6 +325,14 @@ void Executor<model, BusHandler>::State::run(int &count) {
|
||||
status.interrupt_level = interrupt_input;
|
||||
}
|
||||
|
||||
// Capture the trace bit, indicating whether to trace
|
||||
// after this instruction.
|
||||
//
|
||||
// If an exception occurs, this value will be cleared, but
|
||||
// it'll persist across mere status register changes for
|
||||
// one instruction's duration.
|
||||
should_trace = status.trace_flag;
|
||||
|
||||
// Read the next instruction.
|
||||
instruction_address = program_counter.l;
|
||||
instruction_opcode = read_pc<uint16_t>();
|
||||
@ -345,10 +356,6 @@ void Executor<model, BusHandler>::State::run(int &count) {
|
||||
}
|
||||
}
|
||||
|
||||
// Capture the trace bit, indicating whether to trace
|
||||
// after this instruction.
|
||||
const auto should_trace = status.trace_flag;
|
||||
|
||||
// Temporary storage.
|
||||
CPU::SlicedInt32 operand_[2];
|
||||
EffectiveAddress effective_address_[2];
|
||||
@ -415,6 +422,9 @@ void Executor<model, BusHandler>::State::raise_exception(int index) {
|
||||
write<uint16_t>(sp.l - 6, previous_status);
|
||||
sp.l -= 6;
|
||||
|
||||
// Ensure no tracing occurs into the exception.
|
||||
should_trace = 0;
|
||||
|
||||
// Fetch the new program counter.
|
||||
program_counter.l = read<uint32_t>(address);
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user