From e3f99e4360aabc84ab9d341dce7184b96ec4cd62 Mon Sep 17 00:00:00 2001 From: Jacob Lifshay Date: Thu, 27 Aug 2020 17:17:47 -0700 Subject: [PATCH] add subf[o][.] instructions --- src/instr_models.rs | 15 +++++++++++++++ src/lib.rs | 18 ++++++++++++++++++ 2 files changed, 33 insertions(+) diff --git a/src/instr_models.rs b/src/instr_models.rs index 8711e22..59ff2bb 100644 --- a/src/instr_models.rs +++ b/src/instr_models.rs @@ -53,6 +53,21 @@ pub fn addo(inputs: InstructionInput) -> InstructionResult { } } +create_instr_variants_ov_cr!(subf, subfo, subf_, subfo_, i64); + +pub fn subfo(inputs: InstructionInput) -> InstructionResult { + let ra = inputs.ra as i64; + let rb = inputs.rb as i64; + let (result, ov) = rb.overflowing_sub(ra); + let result = result as u64; + let ov32 = (rb as i32).overflowing_sub(ra as i32).1; + InstructionResult { + rt: Some(result), + overflow: Some(OverflowFlags { so: ov, ov, ov32 }), + ..InstructionResult::default() + } +} + create_instr_variants_ov_cr!(divde, divdeo, divde_, divdeo_, i64); pub fn divdeo(inputs: InstructionInput) -> InstructionResult { diff --git a/src/lib.rs b/src/lib.rs index 98880c2..6faa451 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -423,6 +423,24 @@ instrs! { "addo." } + // subf + #[enumerant = SubF] + fn subf(ra, rb) -> (rt) { + "subf" + } + #[enumerant = SubFO] + fn subfo(ra, rb) -> (rt, ov) { + "subfo" + } + #[enumerant = SubF_] + fn subf_(ra, rb) -> (rt, cr0) { + "subf." + } + #[enumerant = SubFO_] + fn subfo_(ra, rb) -> (rt, ov, cr0) { + "subfo." + } + // divde #[enumerant = DivDE] fn divde(ra, rb) -> (rt) { -- 2.30.2