mirror of
https://github.com/mre/mos6502.git
synced 2024-12-22 12:29:31 +00:00
set carry flag if carry_in && value == "$ff" (#44)
This commit is contained in:
parent
e2fd2469e3
commit
ef9a49ac8b
@ -552,7 +552,7 @@ impl CPU {
|
||||
a_after
|
||||
};
|
||||
|
||||
let did_carry = (result as u8) < (a_before as u8);
|
||||
let did_carry = (result as u8) < (a_before as u8) || (c_before == 1 && value == -1);
|
||||
|
||||
let did_overflow = (a_before < 0 && value < 0 && a_after >= 0)
|
||||
|| (a_before > 0 && value > 0 && a_after <= 0);
|
||||
@ -914,6 +914,12 @@ mod tests {
|
||||
assert_eq!(cpu.registers.status.contains(Status::PS_ZERO), false);
|
||||
assert_eq!(cpu.registers.status.contains(Status::PS_NEGATIVE), true);
|
||||
assert_eq!(cpu.registers.status.contains(Status::PS_OVERFLOW), true);
|
||||
|
||||
let mut cpu = CPU::new();
|
||||
cpu.registers.status.or(Status::PS_CARRY);
|
||||
cpu.add_with_carry(-1);
|
||||
assert_eq!(cpu.registers.accumulator, 0);
|
||||
assert_eq!(cpu.registers.status.contains(Status::PS_CARRY), true);
|
||||
}
|
||||
|
||||
#[test]
|
||||
|
Loading…
Reference in New Issue
Block a user