add more instructions

This commit is contained in:
Lauchmelder 2022-08-24 01:57:42 +02:00
parent be3ebe9041
commit a2695b5ca1
3 changed files with 178 additions and 16 deletions

View file

@ -22,7 +22,7 @@ macro_rules! instr
{
($instr: ident, $addr: ident, $cyc: literal, $len: literal) =>
{
Instruction
Option::Some(Instruction
{
action: CPU::$instr,
addressing: CPU::$addr,
@ -30,7 +30,7 @@ macro_rules! instr
length: $len,
name: s3::new(stringify!($instr)).unwrap()
}
})
}
}
@ -39,7 +39,7 @@ pub struct CPU
pub cycle: u8,
total_cycles: u64,
pub absolute_addr: u16,
pub relative_addr: u8,
pub relative_addr: i8,
pub acc: u8,
pub x: u8,
@ -60,9 +60,36 @@ impl CPU
const UNDEF_INSTR: Option<Instruction> = None;
let mut instr_set = [UNDEF_INSTR; 256];
instr_set[0x4C] = Option::Some(instr!(jmp, abs, 3, 3));
instr_set[0x86] = Option::Some(instr!(stx, zpg, 3, 2));
instr_set[0xA2] = Option::Some(instr!(ldx, imm, 2, 2));
instr_set[0x10] = instr!(bpl, rel, 2, 2);
instr_set[0x18] = instr!(clc, imp, 2, 1);
instr_set[0x20] = instr!(jsr, abs, 6, 3);
instr_set[0x24] = instr!(bit, zpg, 3, 2);
instr_set[0x30] = instr!(bmi, rel, 2, 2);
instr_set[0x38] = instr!(sec, imp, 2, 1);
instr_set[0x4C] = instr!(jmp, abs, 3, 3);
instr_set[0x50] = instr!(bvc, rel, 2, 2);
instr_set[0x70] = instr!(bvs, rel, 2, 2);
instr_set[0x85] = instr!(sta, zpg, 3, 2);
instr_set[0x86] = instr!(stx, zpg, 3, 2);
instr_set[0x90] = instr!(bcc, rel, 2, 2);
instr_set[0xA2] = instr!(ldx, imm, 2, 2);
instr_set[0xA9] = instr!(lda, imm, 2, 2);
instr_set[0xB0] = instr!(bcs, rel, 2, 2);
instr_set[0xD0] = instr!(bne, rel, 2, 2);
instr_set[0xEA] = instr!(nop, imp, 2, 1);
instr_set[0xF0] = instr!(beq, rel, 2, 2);
CPU {
cycle: 0,