From 255f0d4b2a4758f9b31ca280698b30c4bbd1fec2 Mon Sep 17 00:00:00 2001 From: Thomas Harte Date: Sun, 30 Jun 2019 22:33:54 -0400 Subject: [PATCH] Corrects MULS timing. --- .../68000/Implementation/68000Implementation.hpp | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/Processors/68000/Implementation/68000Implementation.hpp b/Processors/68000/Implementation/68000Implementation.hpp index 03c67335e..0b2f3aa55 100644 --- a/Processors/68000/Implementation/68000Implementation.hpp +++ b/Processors/68000/Implementation/68000Implementation.hpp @@ -945,18 +945,19 @@ template void Proces zero_result_ = active_program_->destination->full; negative_flag_ = 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. // TODO: optimise the below? int number_of_pairs = 0; int source = active_program_->source->halves.low.full; - int bit = 0; - while(source | bit) { - number_of_pairs += (bit ^ source) & 1; - bit = source & 1; + source = (source ^ (source << 1)) & 0xffff; + while(source) { + if(source&1) ++number_of_pairs; source >>= 1; } // Time taken = 38 cycles + 2 cycles per 1 in the source. - set_next_microcycle_length(HalfCycles(4 * number_of_pairs + 38*2)); + set_next_microcycle_length(HalfCycles(4 * number_of_pairs + 34*2)); } break; /*