This commit is contained in:
Logan McNaughton
2023-10-07 21:00:09 -06:00
parent 4a672bbbc3
commit a094b3a7d3
2 changed files with 17 additions and 15 deletions
+9 -8
View File
@@ -975,21 +975,22 @@ pub fn jr(device: &mut device::Device, opcode: u32) {
}
pub fn jalr(device: &mut device::Device, opcode: u32) {
let target = device.cpu.gpr[rs(opcode) as usize];
let in_delay_slot_taken = device::cpu::in_delay_slot_taken(device);
if !in_delay_slot_taken {
check_relative_idle_loop(device, opcode);
device.cpu.branch_state.state = device::cpu::State::Take;
device.cpu.branch_state.pc = device.cpu.gpr[rs(opcode) as usize];
} else if !device::cpu::in_delay_slot(device) {
device.cpu.branch_state.state = device::cpu::State::NotTaken;
}
if in_delay_slot_taken {
device.cpu.gpr[rd(opcode) as usize] = device.cpu.branch_state.pc + 4
} else {
device.cpu.gpr[rd(opcode) as usize] = device.cpu.pc + 8
}
if !in_delay_slot_taken {
check_relative_idle_loop(device, opcode);
device.cpu.branch_state.state = device::cpu::State::Take;
device.cpu.branch_state.pc = target;
} else if !device::cpu::in_delay_slot(device) {
device.cpu.branch_state.state = device::cpu::State::NotTaken;
}
}
pub fn sync(_device: &mut device::Device, _opcode: u32) {}
+8 -7
View File
@@ -306,21 +306,22 @@ pub fn jr(device: &mut device::Device, opcode: u32) {
}
pub fn jalr(device: &mut device::Device, opcode: u32) {
let target = device.rsp.cpu.gpr[rs(opcode) as usize];
let in_delay_slot_taken = device::rsp_cpu::in_delay_slot_taken(device);
if !in_delay_slot_taken {
device.rsp.cpu.branch_state.state = device::cpu::State::Take;
device.rsp.cpu.branch_state.pc = device.rsp.cpu.gpr[rs(opcode) as usize]
} else if !device::rsp_cpu::in_delay_slot(device) {
device.rsp.cpu.branch_state.state = device::cpu::State::NotTaken;
}
if in_delay_slot_taken {
device.rsp.cpu.gpr[rd(opcode) as usize] = (device.rsp.cpu.branch_state.pc + 4) & 0xFFF
} else {
device.rsp.cpu.gpr[rd(opcode) as usize] =
(device.rsp.regs2[device::rsp_interface::SP_PC_REG as usize] + 8) & 0xFFF
}
if !in_delay_slot_taken {
device.rsp.cpu.branch_state.state = device::cpu::State::Take;
device.rsp.cpu.branch_state.pc = target
} else if !device::rsp_cpu::in_delay_slot(device) {
device.rsp.cpu.branch_state.state = device::cpu::State::NotTaken;
}
}
pub fn break_(device: &mut device::Device, _opcode: u32) {