From e785e6b812224af1b2ce40d55c29e73dc3591531 Mon Sep 17 00:00:00 2001 From: Jacob Lifshay Date: Thu, 3 Sep 2020 16:20:16 -0700 Subject: [PATCH] fix subfc* to calculate correct carries --- src/instr_models.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/instr_models.rs b/src/instr_models.rs index e56e4fb..d140ea5 100644 --- a/src/instr_models.rs +++ b/src/instr_models.rs @@ -111,8 +111,8 @@ pub fn subfco(inputs: InstructionInput) -> InstructionResult { let (result, ov) = rb.overflowing_sub(ra); let result = result as u64; let ov32 = (rb as i32).overflowing_sub(ra as i32).1; - let ca = (rb as u64).overflowing_sub(ra as u64).1; - let ca32 = (rb as u32).overflowing_sub(ra as u32).1; + let ca = !(rb as u64).overflowing_sub(ra as u64).1; + let ca32 = !(rb as u32).overflowing_sub(ra as u32).1; Ok(InstructionOutput { rt: Some(result), overflow: Some(propagate_so(OverflowFlags { so: ov, ov, ov32 }, inputs)?), -- 2.30.2