})
}
+pub fn addis(inputs: InstructionInput) -> InstructionResult {
+ let ra = inputs.try_get_ra()? as i64;
+ let immediate = inputs.try_get_immediate_s16()? as i64;
+ let result = ra.wrapping_add(immediate << 16) as u64;
+ Ok(InstructionOutput {
+ rt: Some(result),
+ ..InstructionOutput::default()
+ })
+}
+
create_instr_variants_ov_cr!(add, addo, add_, addo_, i64);
pub fn addo(inputs: InstructionInput) -> InstructionResult {
})
}
+create_instr_variants_cr!(addic, addic_, i64);
+
+pub fn addic(inputs: InstructionInput) -> InstructionResult {
+ let ra = inputs.try_get_ra()? as i64;
+ let immediate = inputs.try_get_immediate_s16()? as i64;
+ let result = ra.wrapping_add(immediate) as u64;
+ let ca = (ra as u64).overflowing_add(immediate as u64).1;
+ let ca32 = (ra as u32).overflowing_add(immediate as u32).1;
+ Ok(InstructionOutput {
+ rt: Some(result),
+ carry: Some(CarryFlags { ca, ca32 }),
+ ..InstructionOutput::default()
+ })
+}
+
create_instr_variants_ov_cr!(subf, subfo, subf_, subfo_, i64);
pub fn subfo(inputs: InstructionInput) -> InstructionResult {
"addi"
}
+ #[enumerant = AddIS]
+ fn addis(Ra, ImmediateS16) -> (Rt) {
+ "addis"
+ }
+
// add
#[enumerant = Add]
fn add(Ra, Rb) -> (Rt) {
"addo."
}
+ // addic
+ #[enumerant = AddIC]
+ fn addic(Ra, ImmediateS16) -> (Rt, Carry) {
+ "addic"
+ }
+ #[enumerant = AddIC_]
+ fn addic_(Ra, ImmediateS16, Overflow) -> (Rt, Carry, CR0) {
+ "addic."
+ }
+
// subf
#[enumerant = SubF]
fn subf(Ra, Rb) -> (Rt) {