mirror of
https://github.com/mre/mos6502.git
synced 2024-11-28 07:49:19 +00:00
implement RTI as well
This commit is contained in:
parent
1b90243738
commit
18164c7abf
12
src/cpu.rs
12
src/cpu.rs
@ -445,6 +445,18 @@ impl<M: Bus> CPU<M> {
|
||||
CPU::<M>::rotate_right_with_flags(&mut operand, &mut self.registers.status);
|
||||
self.memory.set_byte(addr, operand);
|
||||
}
|
||||
(Instruction::RTI, OpInput::UseImplied) => {
|
||||
// Pull status
|
||||
self.pull_from_stack();
|
||||
let val: u8 = self.pull_from_stack();
|
||||
// The `truncate` here won't do anything because we have a
|
||||
// constant for the single unused flags bit. This probably
|
||||
// corresponds to the behavior of the 6502...? FIXME: verify
|
||||
self.registers.status = Status::from_bits_truncate(val);
|
||||
let pcl: u8 = self.pull_from_stack();
|
||||
let pch: u8 = self.fetch_from_stack();
|
||||
self.registers.program_counter = ((pch as u16) << 8) | pcl as u16;
|
||||
}
|
||||
(Instruction::RTS, OpInput::UseImplied) => {
|
||||
self.pull_from_stack();
|
||||
let pcl: u8 = self.pull_from_stack();
|
||||
|
Loading…
Reference in New Issue
Block a user