alu: Fix carry detection for subtraction
Former-commit-id: c9d8612f72ce4a002ea33446209bd7e6da0eb5aa
This commit is contained in:
parent
1bacb927af
commit
2817db4e1c
|
@ -201,7 +201,7 @@ impl Core {
|
||||||
|
|
||||||
fn alu_sub_flags(a: i32, b: i32, carry: &mut bool, overflow: &mut bool) -> i32 {
|
fn alu_sub_flags(a: i32, b: i32, carry: &mut bool, overflow: &mut bool) -> i32 {
|
||||||
let res = a.wrapping_sub(b);
|
let res = a.wrapping_sub(b);
|
||||||
*carry = res > a;
|
*carry = b <= a;
|
||||||
let (_, would_overflow) = a.overflowing_sub(b);
|
let (_, would_overflow) = a.overflowing_sub(b);
|
||||||
*overflow = would_overflow;
|
*overflow = would_overflow;
|
||||||
res
|
res
|
||||||
|
|
Reference in a new issue