1
0
mirror of https://github.com/TomHarte/CLK.git synced 2024-11-26 08:49:37 +00:00

Start removing 68000-specific timing calculations.

This commit is contained in:
Thomas Harte 2022-05-09 20:32:02 -04:00
parent 8e7340860e
commit 7445c617bc
4 changed files with 17 additions and 25 deletions

View File

@ -49,8 +49,11 @@ template <Model model, typename BusHandler> class Executor {
// Flow control.
void consume_cycles(int) {}
void raise_exception(int, bool use_current_instruction_pc = true);
template <bool use_current_instruction_pc = true> void raise_exception(int);
void did_update_status();
template <typename IntT> void did_mulu(IntT) {}
template <typename IntT> void did_muls(IntT) {}
template <typename IntT> void complete_bcc(bool matched_condition, IntT offset);
void complete_dbcc(bool matched_condition, bool overflowed, int16_t offset);

View File

@ -332,7 +332,8 @@ void Executor<model, BusHandler>::set_state(const Registers &state) {
// MARK: - Flow Control.
template <Model model, typename BusHandler>
void Executor<model, BusHandler>::raise_exception(int index, bool use_current_instruction_pc) {
template <bool use_current_instruction_pc>
void Executor<model, BusHandler>::raise_exception(int index) {
const uint32_t address = index << 2;
// Grab the status to store, then switch into supervisor mode.

View File

@ -492,35 +492,22 @@ template <
Multiplications.
*/
case Operation::MULU: {
case Operation::MULU:
dest.l = dest.w * src.w;
status.carry_flag_ = status.overflow_flag_ = 0;
status.zero_result_ = dest.l;
status.negative_flag_ = status.zero_result_ & 0x80000000;
flow_controller.did_mulu(src.w);
break;
int number_of_ones = src.w;
convert_to_bit_count_16(number_of_ones);
// Time taken = 38 cycles + 2 cycles for every 1 in the source.
flow_controller.consume_cycles(2 * number_of_ones + 34);
} break;
case Operation::MULS: {
case Operation::MULS:
dest.l =
u_extend16(dest.w) * u_extend16(src.w);
status.carry_flag_ = status.overflow_flag_ = 0;
status.zero_result_ = dest.l;
status.negative_flag_ = status.zero_result_ & 0x80000000;
// Find the number of 01 or 10 pairs in the 17-bit number
// formed by the source value with a 0 suffix.
int number_of_pairs = src.w;
number_of_pairs = (number_of_pairs ^ (number_of_pairs << 1)) & 0xffff;
convert_to_bit_count_16(number_of_pairs);
// Time taken = 38 cycles + 2 cycles per 1 in the source.
flow_controller.consume_cycles(2 * number_of_pairs + 34);
} break;
flow_controller.did_muls(src.w);
break;
/*
Divisions.
@ -651,12 +638,12 @@ template <
// TRAP, which is a nicer form of ILLEGAL.
case Operation::TRAP:
flow_controller.raise_exception(src.l + 32, false);
flow_controller.template raise_exception<false>(src.l + 32);
break;
case Operation::TRAPV: {
if(status.overflow_flag_) {
flow_controller.raise_exception(7, false);
flow_controller.template raise_exception<false>(7);
}
} break;
@ -682,7 +669,7 @@ template <
} else {
flow_controller.consume_cycles(12);
}
flow_controller.raise_exception(6, false);
flow_controller.template raise_exception<false>(6);
}
} break;

View File

@ -157,7 +157,8 @@ static constexpr uint8_t StoreOp2 = (1 << 3);
/*!
Provides a bitfield with a value in the range 015 indicating which of the provided operation's
operands are accessed via standard fetch and store cycles.
operands are accessed via standard fetch and store cycles; the bitfield is composted of
[Fetch/Store]Op[1/2] as defined above.
Unusual bus sequences, such as TAS or MOVEM, are not described here.
*/