From 7788a109b030a7eab79389a2d7c2b1fad347938a Mon Sep 17 00:00:00 2001 From: Thomas Harte Date: Sun, 29 May 2022 20:51:50 -0400 Subject: [PATCH] Tweak more overtly to avoid divide by zero. --- InstructionSets/M68k/Implementation/PerformImplementation.hpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/InstructionSets/M68k/Implementation/PerformImplementation.hpp b/InstructionSets/M68k/Implementation/PerformImplementation.hpp index 03b353376..a551f11ec 100644 --- a/InstructionSets/M68k/Implementation/PerformImplementation.hpp +++ b/InstructionSets/M68k/Implementation/PerformImplementation.hpp @@ -522,7 +522,8 @@ template < #define DIV(Type16, Type32, flow_function) { \ status.carry_flag = 0; \ \ - if(!src.w) { \ + const auto divisor = Type32(Type16(src.w)); \ + if(!divisor) { \ status.negative_flag = status.overflow_flag = 0; \ status.zero_result = 1; \ flow_controller.raise_exception(Exception::IntegerDivideByZero); \ @@ -530,7 +531,6 @@ template < } \ \ const auto dividend = Type32(dest.l); \ - const auto divisor = Type32(Type16(src.w)); \ const auto quotient = dividend / divisor; \ \ if(quotient != Type32(Type16(quotient))) { \