implement BRK

This commit is contained in:
Sam M W 2023-04-15 21:17:28 +01:00
parent 1c31a73a2b
commit a8d53f926d
1 changed files with 10 additions and 0 deletions

View File

@ -269,6 +269,16 @@ impl<M: Bus> CPU<M> {
self.branch_if_positive(addr);
}
(Instruction::BRK, OpInput::UseImplied) => {
for b in self.registers.program_counter.wrapping_sub(1).to_be_bytes() {
self.push_on_stack(b);
}
self.push_on_stack(self.registers.status.bits());
let pcl = self.memory.get_byte(0xfffe);
let pch = self.memory.get_byte(0xffff);
self.jump(((pch as u16) << 8) | pcl as u16);
}
(Instruction::BVC, OpInput::UseRelative(rel)) => {
let addr = self.registers.program_counter.wrapping_add(rel);
self.branch_if_overflow_clear(addr);