|
|
|
|
@ -2,7 +2,7 @@
|
|
|
|
|
|
|
|
|
|
#![allow(dead_code, non_snake_case)]
|
|
|
|
|
|
|
|
|
|
use super::{R6502, Bus, Flags};
|
|
|
|
|
use super::{R6502, Bus, Flags, addressing_modes::{AddressingModes, ModeID}};
|
|
|
|
|
|
|
|
|
|
// Instruction decoding:
|
|
|
|
|
// https://llx.com/Neil/a2/opcodes.html
|
|
|
|
|
@ -31,6 +31,17 @@ impl Instructions
|
|
|
|
|
Instructions::CMP,
|
|
|
|
|
Instructions::SBC,
|
|
|
|
|
];
|
|
|
|
|
|
|
|
|
|
pub const GROUP_TWO_OPS: [fn(&mut R6502, &mut dyn Bus); 8] = [
|
|
|
|
|
Instructions::ASL, // 000
|
|
|
|
|
Instructions::ROL, // 001
|
|
|
|
|
Instructions::LSR, // 010
|
|
|
|
|
Instructions::ROR, // 011
|
|
|
|
|
Instructions::STX, // 100
|
|
|
|
|
Instructions::LDX, // 101
|
|
|
|
|
Instructions::DEC, // 110
|
|
|
|
|
Instructions::INC, // 111
|
|
|
|
|
];
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
impl Instructions
|
|
|
|
|
@ -213,6 +224,71 @@ impl Instructions
|
|
|
|
|
|
|
|
|
|
///////////////////////////////////////////////////////////
|
|
|
|
|
// GROUP TWO
|
|
|
|
|
pub fn ASL(cpu: &mut R6502, bus: &mut dyn Bus)
|
|
|
|
|
{
|
|
|
|
|
cpu.clear_flag(Flags::C);
|
|
|
|
|
if cpu.working_data as u8 & 0x80 > 0
|
|
|
|
|
{
|
|
|
|
|
cpu.set_flag(Flags::C);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
let result = cpu.working_data << 1;
|
|
|
|
|
|
|
|
|
|
cpu.clear_flag(Flags::Z);
|
|
|
|
|
if result == 0
|
|
|
|
|
{
|
|
|
|
|
cpu.set_flag(Flags::Z);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if result as u8 & 0x80 > 0
|
|
|
|
|
{
|
|
|
|
|
cpu.set_flag(Flags::N);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if cpu.addr_mode == ModeID::ACM
|
|
|
|
|
{
|
|
|
|
|
cpu.a = result as u8;
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
bus.write(cpu.working_addr, result as u8);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
pub fn ROL(cpu: &mut R6502, bus: &mut dyn Bus)
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
pub fn LSR(cpu: &mut R6502, bus: &mut dyn Bus)
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
pub fn ROR(cpu: &mut R6502, bus: &mut dyn Bus)
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
pub fn STX(cpu: &mut R6502, bus: &mut dyn Bus)
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
pub fn LDX(cpu: &mut R6502, bus: &mut dyn Bus)
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
pub fn DEC(cpu: &mut R6502, bus: &mut dyn Bus)
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
pub fn INC(cpu: &mut R6502, bus: &mut dyn Bus)
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
///////////////////////////////////////////////////////////
|
|
|
|
|
// GROUP THREE
|
|
|
|
|
|