From 6b666bc92a6fd7ff4e485658a4514a90f50ef3ab Mon Sep 17 00:00:00 2001 From: Thomas Harte Date: Wed, 8 Nov 2023 22:19:51 -0500 Subject: [PATCH] Simplify DAS. --- InstructionSets/x86/Implementation/BCD.hpp | 38 ++-------------------- 1 file changed, 2 insertions(+), 36 deletions(-) diff --git a/InstructionSets/x86/Implementation/BCD.hpp b/InstructionSets/x86/Implementation/BCD.hpp index 876cd813e..2ea8e37db 100644 --- a/InstructionSets/x86/Implementation/BCD.hpp +++ b/InstructionSets/x86/Implementation/BCD.hpp @@ -158,56 +158,22 @@ void das( uint8_t &al, ContextT &context ) { - /* - (as modified by https://www.felixcloutier.com/x86/daa ...) - - old_AL ← AL; - old_CF ← CF; - CF ← 0; - - IF (((AL AND 0FH) > 9) or AF = 1) - THEN - AL ← AL - 6; - CF ← old_CF OR CarryFromLastAddition; (* CF OR borrow from AL ← AL - 6 *) - AF ← 1; - ELSE - AF ← 0; - FI; - IF ((old_AL > 99H) or old_CF = 1) - THEN - AL ← AL - 60H; - CF ← 1; - ELSE - CF ← 0; - FI; - */ - /* - The CF and AF flags are set if the adjustment of the value results in a - decimal carry in either digit of the result (see the “Operation” section above). - The SF, ZF, and PF flags are set according to the result. The OF flag is undefined. - */ const uint8_t old_al = al; - const auto old_carry = context.flags.template flag(); - context.flags.template set_from(0); if((al & 0x0f) > 0x09 || context.flags.template flag()) { - context.flags.template set_from(old_carry | (al < 0x06)); al -= 0x06; context.flags.template set_from(1); - } else { - context.flags.template set_from(0); } - if(old_al > 0x99 || old_carry) { + if(old_al > 0x99 || context.flags.template flag()) { al -= 0x60; context.flags.template set_from(1); - } else { - context.flags.template set_from(0); } context.flags.template set_from(al); } + } #endif /* BCD_h */