diff --git a/src/tests/instructions/mod.rs b/src/tests/instructions/mod.rs index 2d2bb09..5b9ceec 100644 --- a/src/tests/instructions/mod.rs +++ b/src/tests/instructions/mod.rs @@ -2,7 +2,7 @@ #![allow(dead_code, non_snake_case)] use crate::tests::test_bus::RAMBus; -use crate::r6502::{R6502, Bus, Registers}; +use crate::r6502::{R6502, Bus, Registers, Flags}; ///////////////////////////////////////////////////////////////////// // GROUP ONE @@ -172,4 +172,34 @@ mod SBC; // GROUP TWO ///////////////////////////////////////////////////////////////////// -// TODO: TEST ASL \ No newline at end of file +#[test] +fn ASL() +{ + let mut cpu = R6502::new(); + let mut bus = RAMBus::new(); + + // program address + let addr = 0x0020 as u16; + + // Set the program counter address + bus.write(0xFFFC, (addr & 0x00FF) as u8); // low byte + bus.write(0xFFFD, ((addr & 0xFF00) >> 8) as u8); // high byte + + // Program to left shift the value in the accumulator + bus.write(addr, 0x0A); // ASL - Accumulator mode + + // Restart cpu + cpu.reset(&mut bus); + + // manually setup the cpu registers + cpu.debug_set_reg(Registers::A, 0x98); + + // Clock the cpu to run the program (Clock essentially runs one full instruction) + cpu.clock(&mut bus); + + // Is 0x30 in the A register? + assert_eq!(0x30, cpu.debug_get_reg(Registers::A)); + assert_eq!(0, cpu.check_flag(Flags::Z), "Zero flag should not be set"); + assert_eq!(1, cpu.check_flag(Flags::C), "Carry flag should be set"); + assert_eq!(0, cpu.check_flag(Flags::N), "Negative flag should not be set"); +} \ No newline at end of file diff --git a/todo/todo.todo b/todo/todo.todo index a72a1fc..9a096cb 100644 --- a/todo/todo.todo +++ b/todo/todo.todo @@ -40,7 +40,7 @@ Instructions: ✔ 111 SBC @done(23-11-09 13:24) GROUP TWO: - ☐ 000 ASL + ✔ 000 ASL @done(23-11-30 17:31) ☐ 001 ROL ☐ 010 LSR ☐ 011 ROR