1
0
mirror of https://github.com/mre/mos6502.git synced 2024-11-25 02:33:26 +00:00

Add and_test().

This commit is contained in:
Andrew Keeton 2014-11-06 18:58:09 -05:00
parent 6807b78a83
commit 5e0d151f12

View File

@ -628,6 +628,35 @@ fn add_with_carry_test() {
assert_eq!(machine.registers.status.contains(PS_OVERFLOW), true); assert_eq!(machine.registers.status.contains(PS_OVERFLOW), true);
} }
#[test]
fn and_test() {
let mut machine = Machine::new();
machine.registers.accumulator = 0;
machine.and(0xff);
assert_eq!(machine.registers.accumulator, 0);
assert_eq!(machine.registers.status.contains(PS_ZERO), true);
assert_eq!(machine.registers.status.contains(PS_NEGATIVE), false);
machine.registers.accumulator = 0xff;
machine.and(0);
assert_eq!(machine.registers.accumulator, 0);
assert_eq!(machine.registers.status.contains(PS_ZERO), true);
assert_eq!(machine.registers.status.contains(PS_NEGATIVE), false);
machine.registers.accumulator = 0xff;
machine.and(0x0f);
assert_eq!(machine.registers.accumulator, 0x0f);
assert_eq!(machine.registers.status.contains(PS_ZERO), false);
assert_eq!(machine.registers.status.contains(PS_NEGATIVE), false);
machine.registers.accumulator = 0xff;
machine.and(0xf0);
assert_eq!(machine.registers.accumulator, 0xf0);
assert_eq!(machine.registers.status.contains(PS_ZERO), false);
assert_eq!(machine.registers.status.contains(PS_NEGATIVE), true);
}
#[test] #[test]
fn subtract_with_carry_test() { fn subtract_with_carry_test() {
let mut machine = Machine::new(); let mut machine = Machine::new();