mirror of
https://github.com/TomHarte/CLK.git
synced 2025-08-13 00:25:26 +00:00
Implement Bcc.
This commit is contained in:
@@ -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.
|
// To limit tests run to a subset of files and/or of tests, uncomment and fill in below.
|
||||||
_fileSet = [NSSet setWithArray:@[
|
_fileSet = [NSSet setWithArray:@[
|
||||||
// @"bcc.json",
|
@"bcc.json",
|
||||||
|
|
||||||
// Below this line are passing tests.
|
// Below this line are passing tests.
|
||||||
@"abcd_sbcd.json",
|
@"abcd_sbcd.json",
|
||||||
@@ -167,7 +167,7 @@ struct TestProcessor: public CPU::MC68000Mk2::BusHandler {
|
|||||||
@"dbcc_scc.json",
|
@"dbcc_scc.json",
|
||||||
@"eor_and_or.json",
|
@"eor_and_or.json",
|
||||||
@"nbcd.json",
|
@"nbcd.json",
|
||||||
@"ext.json"]];
|
@"ext.json"]]; // 9/32 = ~28% done, as far as the tests go.
|
||||||
// _testSet = [NSSet setWithArray:@[@"ADDQ 05df"]];
|
// _testSet = [NSSet setWithArray:@[@"ADDQ 05df"]];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -91,6 +91,11 @@ enum ExecutionState: int {
|
|||||||
DBcc_branch_taken,
|
DBcc_branch_taken,
|
||||||
DBcc_condition_true,
|
DBcc_condition_true,
|
||||||
DBcc_counter_overflow,
|
DBcc_counter_overflow,
|
||||||
|
|
||||||
|
Bcc,
|
||||||
|
Bcc_branch_taken,
|
||||||
|
Bcc_b_branch_not_taken,
|
||||||
|
Bcc_w_branch_not_taken,
|
||||||
};
|
};
|
||||||
|
|
||||||
// MARK: - The state machine.
|
// MARK: - The state machine.
|
||||||
@@ -523,6 +528,9 @@ void Processor<BusHandler, dtack_is_implicit, permit_overrun, signal_will_perfor
|
|||||||
|
|
||||||
StdCASE(DBcc, perform_state_ = DBcc);
|
StdCASE(DBcc, perform_state_ = DBcc);
|
||||||
|
|
||||||
|
StdCASE(Bccb, perform_state_ = Bcc);
|
||||||
|
StdCASE(Bccw, perform_state_ = Bcc);
|
||||||
|
|
||||||
default:
|
default:
|
||||||
assert(false);
|
assert(false);
|
||||||
}
|
}
|
||||||
@@ -962,7 +970,7 @@ void Processor<BusHandler, dtack_is_implicit, permit_overrun, signal_will_perfor
|
|||||||
|
|
||||||
|
|
||||||
//
|
//
|
||||||
// Specific forms of perform.
|
// Specific forms of perform...
|
||||||
//
|
//
|
||||||
|
|
||||||
BeginState(MOVEw):
|
BeginState(MOVEw):
|
||||||
@@ -988,6 +996,9 @@ void Processor<BusHandler, dtack_is_implicit, permit_overrun, signal_will_perfor
|
|||||||
Prefetch() // np
|
Prefetch() // np
|
||||||
MoveToState(Decode);
|
MoveToState(Decode);
|
||||||
|
|
||||||
|
//
|
||||||
|
// [ABCD/SBCD/SUBX/ADDX] (An)-, (An)-
|
||||||
|
//
|
||||||
BeginState(TwoOp_Predec_bw):
|
BeginState(TwoOp_Predec_bw):
|
||||||
IdleBus(1); // n
|
IdleBus(1); // n
|
||||||
|
|
||||||
@@ -1046,7 +1057,6 @@ void Processor<BusHandler, dtack_is_implicit, permit_overrun, signal_will_perfor
|
|||||||
//
|
//
|
||||||
// CHK
|
// CHK
|
||||||
//
|
//
|
||||||
|
|
||||||
BeginState(CHK):
|
BeginState(CHK):
|
||||||
Prefetch(); // np
|
Prefetch(); // np
|
||||||
InstructionSet::M68k::perform<
|
InstructionSet::M68k::perform<
|
||||||
@@ -1079,7 +1089,6 @@ void Processor<BusHandler, dtack_is_implicit, permit_overrun, signal_will_perfor
|
|||||||
//
|
//
|
||||||
// Scc
|
// Scc
|
||||||
//
|
//
|
||||||
|
|
||||||
BeginState(Scc_Dn):
|
BeginState(Scc_Dn):
|
||||||
Prefetch(); // np
|
Prefetch(); // np
|
||||||
InstructionSet::M68k::perform<
|
InstructionSet::M68k::perform<
|
||||||
@@ -1113,7 +1122,7 @@ void Processor<BusHandler, dtack_is_implicit, permit_overrun, signal_will_perfor
|
|||||||
// Just do the write-back here.
|
// Just do the write-back here.
|
||||||
registers_[instruction_.reg(0)].w = operand_[0].w;
|
registers_[instruction_.reg(0)].w = operand_[0].w;
|
||||||
|
|
||||||
// Next state was set by complete_dbcc. Branch to it.
|
// Next state was set by complete_dbcc.
|
||||||
break;
|
break;
|
||||||
|
|
||||||
BeginState(DBcc_branch_taken):
|
BeginState(DBcc_branch_taken):
|
||||||
@@ -1141,6 +1150,33 @@ void Processor<BusHandler, dtack_is_implicit, permit_overrun, signal_will_perfor
|
|||||||
Prefetch(); // np
|
Prefetch(); // np
|
||||||
MoveToState(Decode);
|
MoveToState(Decode);
|
||||||
|
|
||||||
|
//
|
||||||
|
// Bcc [.b and .w]
|
||||||
|
//
|
||||||
|
BeginState(Bcc):
|
||||||
|
InstructionSet::M68k::perform<InstructionSet::M68k::Model::M68000>(
|
||||||
|
instruction_, operand_[0], operand_[1], status_, *static_cast<ProcessorBase *>(this));
|
||||||
|
|
||||||
|
// Next state was set by complete_bcc.
|
||||||
|
break;
|
||||||
|
|
||||||
|
BeginState(Bcc_branch_taken):
|
||||||
|
IdleBus(1); // n
|
||||||
|
Prefetch(); // np
|
||||||
|
Prefetch(); // np
|
||||||
|
MoveToState(Decode);
|
||||||
|
|
||||||
|
BeginState(Bcc_b_branch_not_taken):
|
||||||
|
IdleBus(2); // nn
|
||||||
|
Prefetch(); // np
|
||||||
|
MoveToState(Decode);
|
||||||
|
|
||||||
|
BeginState(Bcc_w_branch_not_taken):
|
||||||
|
IdleBus(2); // nn
|
||||||
|
Prefetch(); // np
|
||||||
|
Prefetch(); // np
|
||||||
|
MoveToState(Decode);
|
||||||
|
|
||||||
//
|
//
|
||||||
// Various states TODO.
|
// Various states TODO.
|
||||||
//
|
//
|
||||||
@@ -1207,6 +1243,18 @@ void ProcessorBase::complete_dbcc(bool matched_condition, bool overflowed, int16
|
|||||||
state_ = DBcc_condition_true;
|
state_ = DBcc_condition_true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
template <typename IntT> void ProcessorBase::complete_bcc(bool take_branch, IntT offset) {
|
||||||
|
if(take_branch) {
|
||||||
|
program_counter_.l = instruction_address_.l + uint32_t(offset) + 2;
|
||||||
|
state_ = Bcc_branch_taken;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
state_ =
|
||||||
|
(instruction_.operation == InstructionSet::M68k::Operation::Bccb) ?
|
||||||
|
Bcc_b_branch_not_taken : Bcc_w_branch_not_taken;
|
||||||
|
}
|
||||||
|
|
||||||
// MARK: - External state.
|
// MARK: - External state.
|
||||||
|
|
||||||
template <class BusHandler, bool dtack_is_implicit, bool permit_overrun, bool signal_will_perform>
|
template <class BusHandler, bool dtack_is_implicit, bool permit_overrun, bool signal_will_perform>
|
||||||
|
@@ -108,7 +108,7 @@ struct ProcessorBase: public InstructionSet::M68k::NullFlowController {
|
|||||||
template <bool did_overflow> void did_divs(int32_t, int32_t) {}
|
template <bool did_overflow> void did_divs(int32_t, int32_t) {}
|
||||||
inline void did_bit_op(int) {}
|
inline void did_bit_op(int) {}
|
||||||
inline void did_update_status();
|
inline void did_update_status();
|
||||||
template <typename IntT> void complete_bcc(bool, IntT) {}
|
template <typename IntT> void complete_bcc(bool, IntT);
|
||||||
inline void complete_dbcc(bool, bool, int16_t);
|
inline void complete_dbcc(bool, bool, int16_t);
|
||||||
inline void bsr(uint32_t) {}
|
inline void bsr(uint32_t) {}
|
||||||
inline void jsr(uint32_t) {}
|
inline void jsr(uint32_t) {}
|
||||||
|
Reference in New Issue
Block a user