From ea463549c75f46bd864bc3b05c3b87f89edf1623 Mon Sep 17 00:00:00 2001 From: Thomas Harte Date: Thu, 25 Apr 2019 13:59:10 -0400 Subject: [PATCH] Corrects overflow flag for LSL and LSR. --- .../Implementation/68000Implementation.hpp | 82 ++++++++++--------- 1 file changed, 44 insertions(+), 38 deletions(-) diff --git a/Processors/68000/Implementation/68000Implementation.hpp b/Processors/68000/Implementation/68000Implementation.hpp index e0a21e3e6..0468267a8 100644 --- a/Processors/68000/Implementation/68000Implementation.hpp +++ b/Processors/68000/Implementation/68000Implementation.hpp @@ -993,47 +993,17 @@ template void Proces set_neg_zero_overflow(destination, 1 << (size - 1)); \ } - case Operation::ASLm: - case Operation::LSLm: { + case Operation::ASLm: { const auto value = active_program_->destination->halves.low.full; active_program_->destination->halves.low.full = value >> 1; extend_flag_ = carry_flag_ = value & 1; set_neg_zero_overflow(active_program_->destination->halves.low.full, 0x8000); } break; - case Operation::ASLb: - case Operation::LSLb: lsl(active_program_->destination->halves.low.halves.low, 8); break; - case Operation::ASLw: - case Operation::LSLw: lsl(active_program_->destination->halves.low.full, 16); break; - case Operation::ASLl: - case Operation::LSLl: lsl(active_program_->destination->full, 32); break; + case Operation::ASLb: lsl(active_program_->destination->halves.low.halves.low, 8); break; + case Operation::ASLw: lsl(active_program_->destination->halves.low.full, 16); break; + case Operation::ASLl: lsl(active_program_->destination->full, 32); break; -#undef lsl -#define lsr(destination, size) {\ - decode_shift_count(); \ - const auto value = destination; \ -\ - if(!shift_count) { \ - carry_flag_ = 0; \ - } else { \ - destination = value >> shift_count; \ - extend_flag_ = carry_flag_ = value & (1 << (shift_count - 1)); \ - } \ -\ - set_neg_zero_overflow(destination, 1 << (size - 1)); \ -} - - case Operation::LSRm: { - const auto value = active_program_->destination->halves.low.full; - active_program_->destination->halves.low.full = value >> 1; - extend_flag_ = carry_flag_ = value & 1; - set_neg_zero_overflow(active_program_->destination->halves.low.full, 0x8000); - } break; - case Operation::LSRb: lsr(active_program_->destination->halves.low.halves.low, 8); break; - case Operation::LSRw: lsr(active_program_->destination->halves.low.full, 16); break; - case Operation::LSRl: lsr(active_program_->destination->full, 32); break; - -#undef lsr #define asr(destination, size) {\ decode_shift_count(); \ @@ -1061,7 +1031,6 @@ template void Proces case Operation::ASRw: asr(active_program_->destination->halves.low.full, 16); break; case Operation::ASRl: asr(active_program_->destination->full, 32); break; -#undef asr #undef set_neg_zero_overflow #define set_neg_zero_overflow(v, m) \ @@ -1076,6 +1045,40 @@ template void Proces overflow_flag_ = 0; \ carry_flag_ = value & (t); + case Operation::LSLm: { + const auto value = active_program_->destination->halves.low.full; + active_program_->destination->halves.low.full = value >> 1; + extend_flag_ = carry_flag_ = value & 1; + set_neg_zero_overflow(active_program_->destination->halves.low.full, 0x8000); + } break; + case Operation::LSLb: lsl(active_program_->destination->halves.low.halves.low, 8); break; + case Operation::LSLw: lsl(active_program_->destination->halves.low.full, 16); break; + case Operation::LSLl: lsl(active_program_->destination->full, 32); break; + +#define lsr(destination, size) {\ + decode_shift_count(); \ + const auto value = destination; \ +\ + if(!shift_count) { \ + carry_flag_ = 0; \ + } else { \ + destination = value >> shift_count; \ + extend_flag_ = carry_flag_ = value & (1 << (shift_count - 1)); \ + } \ +\ + set_neg_zero_overflow(destination, 1 << (size - 1)); \ +} + + case Operation::LSRm: { + const auto value = active_program_->destination->halves.low.full; + active_program_->destination->halves.low.full = value >> 1; + extend_flag_ = carry_flag_ = value & 1; + set_neg_zero_overflow(active_program_->destination->halves.low.full, 0x8000); + } break; + case Operation::LSRb: lsr(active_program_->destination->halves.low.halves.low, 8); break; + case Operation::LSRw: lsr(active_program_->destination->halves.low.full, 16); break; + case Operation::LSRl: lsr(active_program_->destination->full, 32); break; + #define rol(destination, size) { \ decode_shift_count(); \ const auto value = destination; \ @@ -1103,7 +1106,6 @@ template void Proces case Operation::ROLw: rol(active_program_->destination->halves.low.full, 16); break; case Operation::ROLl: rol(active_program_->destination->full, 32); break; -#undef rol #define ror(destination, size) { \ decode_shift_count(); \ @@ -1132,7 +1134,6 @@ template void Proces case Operation::RORw: ror(active_program_->destination->halves.low.full, 16); break; case Operation::RORl: ror(active_program_->destination->full, 32); break; -#undef ror #define roxl(destination, size) { \ decode_shift_count(); \ @@ -1162,7 +1163,6 @@ template void Proces case Operation::ROXLw: roxl(active_program_->destination->halves.low.full, 16); break; case Operation::ROXLl: roxl(active_program_->destination->full, 32); break; -#undef roxl #define roxr(destination, size) { \ decode_shift_count(); \ @@ -1193,6 +1193,12 @@ template void Proces case Operation::ROXRl: roxr(active_program_->destination->full, 32); break; #undef roxr +#undef roxl +#undef ror +#undef rol +#undef asr +#undef lsr +#undef lsl #undef set_flags #undef decode_shift_count