|
|
|
|
@ -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
|
|
|
|
|
#[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");
|
|
|
|
|
}
|