From 2817db4e1c587c89be683b79f1fbbe01a06693b5 Mon Sep 17 00:00:00 2001 From: Michel Heily Date: Tue, 9 Jul 2019 00:30:23 +0300 Subject: [PATCH] alu: Fix carry detection for subtraction Former-commit-id: c9d8612f72ce4a002ea33446209bd7e6da0eb5aa --- src/arm7tdmi/alu.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/arm7tdmi/alu.rs b/src/arm7tdmi/alu.rs index 4598a85..7ab9ead 100644 --- a/src/arm7tdmi/alu.rs +++ b/src/arm7tdmi/alu.rs @@ -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