alu: Fix carry detection for subtraction

Former-commit-id: c9d8612f72ce4a002ea33446209bd7e6da0eb5aa
This commit is contained in:
Michel Heily 2019-07-09 00:30:23 +03:00
parent 1bacb927af
commit 2817db4e1c

View file

@ -201,7 +201,7 @@ impl Core {
fn alu_sub_flags(a: i32, b: i32, carry: &mut bool, overflow: &mut bool) -> i32 {
let res = a.wrapping_sub(b);
*carry = res > a;
*carry = b <= a;
let (_, would_overflow) = a.overflowing_sub(b);
*overflow = would_overflow;
res