From: Jacob Lifshay Date: Wed, 14 Oct 2020 23:28:21 +0000 (-0700) Subject: add subfic X-Git-Tag: v0.2.0~10 X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=17b167f1a5bc6da49846624e6fabe4f8c925c76c;p=power-instruction-analyzer.git add subfic --- diff --git a/src/instr_models.rs b/src/instr_models.rs index cdb3d18..27f6740 100644 --- a/src/instr_models.rs +++ b/src/instr_models.rs @@ -121,6 +121,21 @@ pub fn subfo(inputs: InstructionInput) -> InstructionResult { }) } +pub fn subfic(inputs: InstructionInput) -> InstructionResult { + let ra = inputs.try_get_ra()? as i64; + let immediate = inputs.try_get_immediate_s16()? as i64; + let immediate_plus_1 = immediate + 1; + let not_ra = !ra; + let result = not_ra.wrapping_add(immediate_plus_1) as u64; + let ca = (not_ra as u64).overflowing_add(immediate_plus_1 as u64).1; + let ca32 = (not_ra as u32).overflowing_add(immediate_plus_1 as u32).1; + Ok(InstructionOutput { + rt: Some(result), + carry: Some(CarryFlags { ca, ca32 }), + ..InstructionOutput::default() + }) +} + create_instr_variants_ov_cr!(addc, addco, addc_, addco_, i64); pub fn addco(inputs: InstructionInput) -> InstructionResult { diff --git a/src/lib.rs b/src/lib.rs index 5c67b24..e49374e 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -360,6 +360,11 @@ instructions! { "subfo." } + #[enumerant = SubFIC] + fn subfic(Ra, ImmediateS16) -> (Rt, Carry) { + "subfic" + } + // addc #[enumerant = AddC] fn addc(Ra, Rb) -> (Rt, Carry) {