diff --git a/src/cpu/run/arithutil.rs b/src/cpu/run/arithutil.rs index 6c3ec8d..4db919d 100644 --- a/src/cpu/run/arithutil.rs +++ b/src/cpu/run/arithutil.rs @@ -241,7 +241,7 @@ fn did_8bit_add_full_carry_including_carry_bit, R: Into>( } fn did_16bit_add_half_carry(lhs: u16, rhs: u16) -> bool { - (lhs & 0x0fff).wrapping_add(rhs & 0x0fff) > 0x0f00 + (lhs & 0x0fff).wrapping_add(rhs & 0x0fff) > 0x0fff } fn twos_comp_abs(n: i8) -> u8 { @@ -361,6 +361,7 @@ mod tests { } #[test_case(0x0002, 0x0001, (0x0003, false, false); "simple add")] + #[test_case(0x0CDF, 0x0293, (3954, false, false); "simple add, big numbers")] #[test_case(0x00FF, 0x0001, (0x0100, false, false); "8 bit overflow case does not overflow")] #[test_case(0x8000, 0x8001, (0x0001, false, true); "full carry only")] #[test_case(0x0F00, 0x0100, (0x1000, true, false); "half carry only")]