Push and pop trap information in supervisior mode

This commit is contained in:
pjht 2024-03-09 12:25:54 -06:00
parent d05eb249bb
commit 6bbc879244
Signed by: pjht
GPG Key ID: CA239FC6934E6F3A

View File

@ -1675,11 +1675,12 @@ impl M68K {
} }
fn trap(&mut self, vector: u8) -> Result<(), InsExecError> { fn trap(&mut self, vector: u8) -> Result<(), InsExecError> {
let orig_sr = self.sr;
self.sr |= 0x2000;
let new_pc = self.read_address((u32::from(vector) * 4) + self.vbr, Size::Long)?; let new_pc = self.read_address((u32::from(vector) * 4) + self.vbr, Size::Long)?;
self.push(u32::from(vector), Size::Word)?; self.push(u32::from(vector), Size::Word)?;
self.push(self.pc, Size::Long)?; self.push(self.pc, Size::Long)?;
self.push(u32::from(self.sr), Size::Word)?; self.push(u32::from(orig_sr), Size::Word)?;
self.sr |= 0x2000;
self.pc = new_pc; self.pc = new_pc;
Ok(()) Ok(())
} }
@ -1692,6 +1693,8 @@ impl M68K {
fault_addr: u32, fault_addr: u32,
write_data: u16, write_data: u16,
) -> Result<(), InsExecError> { ) -> Result<(), InsExecError> {
let orig_sr = self.sr;
self.sr |= 0x2000;
let new_pc = self.read_address(2 * 4 + self.vbr, Size::Long)?; let new_pc = self.read_address(2 * 4 + self.vbr, Size::Long)?;
// Version & internal information // Version & internal information
self.push(0, Size::Long)?; self.push(0, Size::Long)?;
@ -1729,8 +1732,7 @@ impl M68K {
// Program counter // Program counter
self.push(self.pc, Size::Long)?; self.push(self.pc, Size::Long)?;
// Status register // Status register
self.push(u32::from(self.sr), Size::Word)?; self.push(u32::from(orig_sr), Size::Word)?;
self.sr |= 0x2000;
self.pc = new_pc; self.pc = new_pc;
Ok(()) Ok(())
} }