alu: Also fix carry detection for unsigned addition

Former-commit-id: d405f885e2b54c23aef5faab86cc1da681bd05ec
This commit is contained in:
Michel Heily 2019-07-09 00:39:35 +03:00
parent 6c0df33597
commit 6ddb136852

View file

@ -238,11 +238,11 @@ impl Core {
}
fn alu_add_flags(a: i32, b: i32, carry: &mut bool, overflow: &mut bool) -> i32 {
let res = a.wrapping_add(b);
*carry = res < a;
let res = a.wrapping_add(b) as u32;
*carry = res < a as u32|| res < b as u32;
let (_, would_overflow) = a.overflowing_add(b);
*overflow = would_overflow;
res
res as i32
}
#[allow(non_snake_case)]