From 50cab0eace9512917b46538ec2ee3fec350dc3a0 Mon Sep 17 00:00:00 2001 From: Jacob Lifshay Date: Fri, 16 Oct 2020 15:32:24 -0700 Subject: [PATCH] add cmpli --- src/instr_models.rs | 22 ++++++++++++++++++++++ src/lib.rs | 10 ++++++++++ 2 files changed, 32 insertions(+) diff --git a/src/instr_models.rs b/src/instr_models.rs index ae3c23c..5d005de 100644 --- a/src/instr_models.rs +++ b/src/instr_models.rs @@ -784,3 +784,25 @@ pub fn cmpwi(inputs: InstructionInput) -> InstructionResult { ..InstructionOutput::default() }) } + +pub fn cmpldi(inputs: InstructionInput) -> InstructionResult { + let ra = inputs.try_get_ra()? as u64; + let immediate = inputs.try_get_immediate_u16()? as u64; + let so = inputs.try_get_overflow()?.so; + let cr0 = ConditionRegister::from_ordering(ra.cmp(&immediate), so); + Ok(InstructionOutput { + cr0: Some(cr0), + ..InstructionOutput::default() + }) +} + +pub fn cmplwi(inputs: InstructionInput) -> InstructionResult { + let ra = inputs.try_get_ra()? as u32; + let immediate = inputs.try_get_immediate_u16()? as u32; + let so = inputs.try_get_overflow()?.so; + let cr0 = ConditionRegister::from_ordering(ra.cmp(&immediate), so); + Ok(InstructionOutput { + cr0: Some(cr0), + ..InstructionOutput::default() + }) +} diff --git a/src/lib.rs b/src/lib.rs index 0e85562..8fa9eec 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -807,6 +807,16 @@ instructions! { fn cmpwi(Ra, ImmediateS16, Overflow) -> (CR0) { "cmpwi" } + + // cmpli + #[enumerant = CmpLDI] + fn cmpldi(Ra, ImmediateU16, Overflow) -> (CR0) { + "cmpldi" + } + #[enumerant = CmpLWI] + fn cmplwi(Ra, ImmediateU16, Overflow) -> (CR0) { + "cmplwi" + } } // must be after instrs macro call since it uses a macro definition -- 2.30.2