add the cmos addressing mode, indirect unindexed

This commit is contained in:
Sam M W 2024-04-27 14:15:19 +01:00
parent 747d620943
commit 8704fd55bf
2 changed files with 22 additions and 0 deletions

View File

@ -201,6 +201,16 @@ impl<M: Bus, V: Variant> CPU<M, V> {
address_from_bytes(slice[0], slice[1]).wrapping_add(y.into()),
)
}
AddressingMode::ZeroPageIndirect => {
// Use [u8, ..1] from instruction
// This is where the absolute (16-bit) target address is stored.
// (Output: a 16-bit address)
let start = slice[0];
let slice = read_address(memory, u16::from(start));
OpInput::UseAddress(
address_from_bytes(slice[0], slice[1])
)
}
};
// Increment program counter

View File

@ -280,6 +280,9 @@ pub enum AddressingMode {
// load from (address stored at constant zero page address) plus Y register, e. g. `lda ($10),Y`.
IndirectIndexedY,
// Address stored at constant zero page address
ZeroPageIndirect,
}
impl AddressingMode {
@ -299,6 +302,7 @@ impl AddressingMode {
AddressingMode::BuggyIndirect => 2,
AddressingMode::IndexedIndirectX => 1,
AddressingMode::IndirectIndexedY => 1,
AddressingMode::ZeroPageIndirect => 1,
}
}
}
@ -628,6 +632,14 @@ impl crate::Variant for Cmos6502 {
0x14 => Some((Instruction::TRB, AddressingMode::ZeroPage)),
0x0c => Some((Instruction::TSB, AddressingMode::Absolute)),
0x1c => Some((Instruction::TRB, AddressingMode::Absolute)),
0x12 => Some((Instruction::ORA, AddressingMode::ZeroPageIndirect)),
0x32 => Some((Instruction::AND, AddressingMode::ZeroPageIndirect)),
0x52 => Some((Instruction::EOR, AddressingMode::ZeroPageIndirect)),
0x72 => Some((Instruction::ADC, AddressingMode::ZeroPageIndirect)),
0x92 => Some((Instruction::STA, AddressingMode::ZeroPageIndirect)),
0xb2 => Some((Instruction::LDA, AddressingMode::ZeroPageIndirect)),
0xd2 => Some((Instruction::CMP, AddressingMode::ZeroPageIndirect)),
0xf2 => Some((Instruction::SBC, AddressingMode::ZeroPageIndirect)),
_ => Nmos6502::decode(opcode),
}
}