..InstructionOutput::default()
})
}
+
+pub fn cmpdi(inputs: InstructionInput) -> InstructionResult {
+ let ra = inputs.try_get_ra()? as i64;
+ let immediate = inputs.try_get_immediate_s16()? as i64;
+ 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 cmpwi(inputs: InstructionInput) -> InstructionResult {
+ let ra = inputs.try_get_ra()? as i32;
+ let immediate = inputs.try_get_immediate_s16()? as i32;
+ let so = inputs.try_get_overflow()?.so;
+ let cr0 = ConditionRegister::from_ordering(ra.cmp(&immediate), so);
+ Ok(InstructionOutput {
+ cr0: Some(cr0),
+ ..InstructionOutput::default()
+ })
+}
so,
}
}
+ pub fn from_ordering(ordering: Ordering, so: bool) -> Self {
+ Self {
+ lt: ordering == Ordering::Less,
+ gt: ordering == Ordering::Greater,
+ eq: ordering == Ordering::Equal,
+ so,
+ }
+ }
}
#[derive(Copy, Clone, Default, Debug, PartialEq, Serialize, Deserialize)]
fn maddld(Ra, Rb, Rc) -> (Rt) {
"maddld"
}
+
+ // cmpi
+ #[enumerant = CmpDI]
+ fn cmpdi(Ra, ImmediateS16, Overflow) -> (CR0) {
+ "cmpdi"
+ }
+ #[enumerant = CmpWI]
+ fn cmpwi(Ra, ImmediateS16, Overflow) -> (CR0) {
+ "cmpwi"
+ }
}
// must be after instrs macro call since it uses a macro definition