From: Jacob Lifshay Date: Thu, 3 Sep 2020 23:20:16 +0000 (-0700) Subject: fix subfc* to calculate correct carries X-Git-Tag: v0.2.0~23 X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=e785e6b812224af1b2ce40d55c29e73dc3591531;p=power-instruction-analyzer.git fix subfc* to calculate correct carries --- 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)?),