1
0
mirror of https://github.com/mre/mos6502.git synced 2024-11-28 07:49:19 +00:00

Add inclusive_or_test().

This commit is contained in:
Andrew Keeton 2014-11-20 18:34:07 -05:00
parent aa7db5e623
commit d0c376ba90

View File

@ -1239,3 +1239,33 @@ fn exclusive_or_test() {
}
}
}
#[test]
fn inclusive_or_test() {
let mut machine = Machine::new();
for a_before in range(0u8, 255u8) {
for val in range(0u8, 255u8) {
machine.execute_instruction(
(instruction::LDA, instruction::UseImmediate(a_before))
);
machine.inclusive_or(val);
let a_after = a_before | val;
assert_eq!(machine.registers.accumulator, a_after as i8);
if a_after == 0 {
assert!(machine.registers.status.contains(PS_ZERO));
} else {
assert!(!machine.registers.status.contains(PS_ZERO));
}
if (a_after as i8) < 0 {
assert!(machine.registers.status.contains(PS_NEGATIVE));
} else {
assert!(!machine.registers.status.contains(PS_NEGATIVE));
}
}
}
}