1
0
mirror of https://github.com/TomHarte/CLK.git synced 2025-02-16 18:30:32 +00:00

Add a performer call-out for Scc; use it to implement proper timing in the mk2 68000.

This commit is contained in:
Thomas Harte 2022-05-20 11:19:16 -04:00
parent e5c1621382
commit 452dd3ccfd
5 changed files with 56 additions and 4 deletions

View File

@ -294,9 +294,11 @@ template <
int16_t(dest.w));
} break;
case Operation::Scc:
src.b = status.evaluate_condition(instruction.condition()) ? 0xff : 0x00;
break;
case Operation::Scc: {
const bool condition = status.evaluate_condition(instruction.condition());
src.b = condition ? 0xff : 0x00;
flow_controller.did_scc(condition);
} break;
/*
CLRs: store 0 to the destination, set the zero flag, and clear

View File

@ -46,6 +46,10 @@ struct NullFlowController {
/// Indicates that a bit-manipulation operation (i.e. BTST, BCHG or BSET) was performed, affecting the bit at posiition @c bit_position.
void did_bit_op([[maybe_unused]] int bit_position) {}
/// Indicates that an @c Scc was performed; if @c did_set_ff is true then the condition was true and FF
/// written to the operand; otherwise 00 was written.
void did_scc([[maybe_unused]] bool did_set_ff) {}
/// Provides a notification that the upper byte of the status register has been affected by the current instruction;
/// this gives an opportunity to track the supervisor flag.
void did_update_status() {}

View File

@ -156,7 +156,7 @@ struct TestProcessor: public CPU::MC68000Mk2::BusHandler {
// To limit tests run to a subset of files and/or of tests, uncomment and fill in below.
_fileSet = [NSSet setWithArray:@[
// @"addq_subq.json",
@"addq_subq.json",
// Below this line are passing tests.
@"abcd_sbcd.json",

View File

@ -82,6 +82,10 @@ enum ExecutionState: int {
CHK_no_trap,
CHK_was_over,
CHK_was_under,
Scc_Dn,
Scc_Dn_did_not_set,
Scc_Dn_did_set,
};
// MARK: - The state machine.
@ -504,6 +508,14 @@ void Processor<BusHandler, dtack_is_implicit, permit_overrun, signal_will_perfor
}
})
StdCASE(Scc, {
if(instruction_.mode(0) == Mode::DataRegisterDirect) {
perform_state_ = Scc_Dn;
} else {
perform_state_ = Perform_np;
}
});
default:
assert(false);
}
@ -1024,6 +1036,10 @@ void Processor<BusHandler, dtack_is_implicit, permit_overrun, signal_will_perfor
Access(operand_[1].high); // nW
MoveToState(Decode);
//
// CHK
//
BeginState(CHK):
Prefetch(); // np
InstructionSet::M68k::perform<
@ -1053,7 +1069,32 @@ void Processor<BusHandler, dtack_is_implicit, permit_overrun, signal_will_perfor
exception_vector_ = InstructionSet::M68k::Exception::CHK;
MoveToState(StandardException);
//
// Scc
//
BeginState(Scc_Dn):
Prefetch(); // np
InstructionSet::M68k::perform<
InstructionSet::M68k::Model::M68000,
ProcessorBase,
InstructionSet::M68k::Operation::Scc
>(
instruction_, operand_[0], operand_[1], status_, *static_cast<ProcessorBase *>(this));
// Next state will be set by did_scc.
break;
BeginState(Scc_Dn_did_set):
IdleBus(1); // n
[[fallthrough]];
BeginState(Scc_Dn_did_not_set):
next_operand_ = 0;
MoveToState(StoreOperand);
//
// Various states TODO.
//
#define TODOState(x) \
BeginState(x): [[fallthrough]];
@ -1100,6 +1141,10 @@ void ProcessorBase::did_chk(bool was_under, bool was_over) {
}
}
void ProcessorBase::did_scc(bool did_set_ff) {
state_ = did_set_ff ? Scc_Dn_did_set : Scc_Dn_did_not_set;
}
// MARK: - External state.
template <class BusHandler, bool dtack_is_implicit, bool permit_overrun, bool signal_will_perform>

View File

@ -102,6 +102,7 @@ struct ProcessorBase: public InstructionSet::M68k::NullFlowController {
template <typename IntT> void did_mulu(IntT) {}
template <typename IntT> void did_muls(IntT) {}
inline void did_chk(bool, bool);
inline void did_scc(bool);
inline void did_shift(int) {}
template <bool did_overflow> void did_divu(uint32_t, uint32_t) {}
template <bool did_overflow> void did_divs(int32_t, int32_t) {}