From ec5d57fefe9328397cb45c465eafd69602cf5b34 Mon Sep 17 00:00:00 2001 From: Thomas Harte Date: Tue, 11 Oct 2022 10:33:28 -0400 Subject: [PATCH] Eliminate 64-bit work. --- .../Implementation/PerformImplementation.hpp | 19 +++++++++---------- 1 file changed, 9 insertions(+), 10 deletions(-) diff --git a/InstructionSets/M68k/Implementation/PerformImplementation.hpp b/InstructionSets/M68k/Implementation/PerformImplementation.hpp index 89fd1dfb8..a214e31ee 100644 --- a/InstructionSets/M68k/Implementation/PerformImplementation.hpp +++ b/InstructionSets/M68k/Implementation/PerformImplementation.hpp @@ -67,26 +67,25 @@ static Status::FlagT overflow(IntT source, IntT destination, IntT result) { template static void add_sub(IntT source, IntT &destination, Status &status) { static_assert(!std::numeric_limits::is_signed); - using BigIntT = typename BiggerInt::type; - const BigIntT extend = (is_extend && status.extend_flag) ? 1 : 0; - const BigIntT result = is_add ? - (BigIntT(destination) + BigIntT(source) + extend) : - (BigIntT(destination) - BigIntT(source) - extend); + const IntT extend = (is_extend && status.extend_flag) ? 1 : 0; + const IntT result = is_add ? + (destination + source + extend) : + (destination - source - extend); // Extend operations can reset the zero flag only; non-extend operations // can either set it or reset it. Which in the reverse-logic world of // zero_result means ORing or storing. if constexpr (is_extend) { - status.zero_result |= IntT(result); + status.zero_result |= Status::FlagT(result); } else { - status.zero_result = IntT(result); + status.zero_result = Status::FlagT(result); } status.extend_flag = - status.carry_flag = Status::FlagT(result >> bit_count()); + status.carry_flag = is_add ? result < destination : result > destination; status.negative_flag = Status::FlagT(result & top_bit()); - status.overflow_flag = overflow(source, destination, IntT(result)); - destination = IntT(result); + status.overflow_flag = overflow(source, destination, result); + destination = result; } }