From 84167af54ffb5258f6ee4afba27a864517ca29a9 Mon Sep 17 00:00:00 2001 From: Thomas Harte Date: Mon, 16 Dec 2019 20:01:33 -0500 Subject: [PATCH] Corrects CHK N flag. --- Processors/68000/Implementation/68000Implementation.hpp | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/Processors/68000/Implementation/68000Implementation.hpp b/Processors/68000/Implementation/68000Implementation.hpp index 001f3e138..77066889e 100644 --- a/Processors/68000/Implementation/68000Implementation.hpp +++ b/Processors/68000/Implementation/68000Implementation.hpp @@ -1326,7 +1326,8 @@ template void Proces overflow_flag_ = carry_flag_ = 0; zero_result_ = destination()->halves.low.full; - negative_flag_ = (is_under && !is_over) ? 1 : 0; + if(is_under) negative_flag_ = 1; + if(is_over) negative_flag_ = 0; // No exception is the default course of action; deviate only if an // exception is necessary. @@ -1541,7 +1542,7 @@ template void Proces extend_flag_ = carry_flag_ = decltype(carry_flag_)(result & ~0xff); \ negative_flag_ = result & 0x80; \ const int unadjusted_result = destination - source - (extend_flag_ ? 1 : 0); \ - overflow_flag_ = unadjusted_result & (~result) & 0x80; \ + overflow_flag_ = ~unadjusted_result & result & 0x80; \ \ /* Store the result. */ \ destination()->halves.low.halves.low = uint8_t(result);