alu: Also fix carry detection for unsigned addition
Former-commit-id: d405f885e2b54c23aef5faab86cc1da681bd05ec
This commit is contained in:
parent
6c0df33597
commit
6ddb136852
|
@ -238,11 +238,11 @@ impl Core {
|
||||||
}
|
}
|
||||||
|
|
||||||
fn alu_add_flags(a: i32, b: i32, carry: &mut bool, overflow: &mut bool) -> i32 {
|
fn alu_add_flags(a: i32, b: i32, carry: &mut bool, overflow: &mut bool) -> i32 {
|
||||||
let res = a.wrapping_add(b);
|
let res = a.wrapping_add(b) as u32;
|
||||||
*carry = res < a;
|
*carry = res < a as u32|| res < b as u32;
|
||||||
let (_, would_overflow) = a.overflowing_add(b);
|
let (_, would_overflow) = a.overflowing_add(b);
|
||||||
*overflow = would_overflow;
|
*overflow = would_overflow;
|
||||||
res
|
res as i32
|
||||||
}
|
}
|
||||||
|
|
||||||
#[allow(non_snake_case)]
|
#[allow(non_snake_case)]
|
||||||
|
|
Reference in a new issue