Added hack to return instructions to correctly adjust PC

This commit is contained in:
transistor 2022-09-18 16:28:14 -07:00
parent fa3e484288
commit 1a65f50ba0

View File

@ -801,18 +801,27 @@ impl M68k {
} }
self.set_sr(sr); self.set_sr(sr);
self.set_pc(addr)?; if let Err(err) = self.set_pc(addr) {
self.state.pc -= 2;
return Err(err);
}
}, },
Instruction::RTR => { Instruction::RTR => {
let ccr = self.pop_word()?; let ccr = self.pop_word()?;
let addr = self.pop_long()?; let addr = self.pop_long()?;
self.set_sr((self.state.sr & 0xFF00) | (ccr & 0x00FF)); self.set_sr((self.state.sr & 0xFF00) | (ccr & 0x00FF));
self.set_pc(addr)?; if let Err(err) = self.set_pc(addr) {
self.state.pc -= 2;
return Err(err);
}
}, },
Instruction::RTS => { Instruction::RTS => {
self.debugger.stack_tracer.pop_return(); self.debugger.stack_tracer.pop_return();
let addr = self.pop_long()?; let addr = self.pop_long()?;
self.set_pc(addr)?; if let Err(err) = self.set_pc(addr) {
self.state.pc -= 2;
return Err(err);
}
}, },
//Instruction::RTD(i16) => { //Instruction::RTD(i16) => {
//}, //},