mirror of
https://github.com/liuk7071/ChonkyStation.git
synced 2024-05-20 12:57:52 -04:00
[CPU] Fix EPC
This commit is contained in:
parent
397b403a10
commit
56b802976d
|
@ -3,8 +3,8 @@
|
|||
|
||||
void Interpreter::step(CpuCore* core, Memory* mem, Disassembler* disassembler) {
|
||||
// Handle interrupts
|
||||
if (core->checkInterrupt(mem->interrupt))
|
||||
core->pc -= 4;
|
||||
core->checkInterrupt(mem->interrupt);
|
||||
// core->pc -= 4;
|
||||
|
||||
CpuCore::Instruction instr = { .raw = mem->read<u32>(core->pc) };
|
||||
|
||||
|
@ -73,13 +73,11 @@ void Interpreter::step(CpuCore* core, Memory* mem, Disassembler* disassembler) {
|
|||
break;
|
||||
}
|
||||
case CpuOpcodes::SPECIALOpcode::SYSCALL: {
|
||||
core->pc -= 4;
|
||||
core->exception(CpuCore::Exception::SysCall);
|
||||
core->exception(CpuCore::Exception::SysCall, true);
|
||||
break;
|
||||
}
|
||||
case CpuOpcodes::SPECIALOpcode::BREAK: {
|
||||
core->pc -= 4;
|
||||
core->exception(CpuCore::Exception::Break);
|
||||
core->exception(CpuCore::Exception::Break, true);
|
||||
break;
|
||||
}
|
||||
case CpuOpcodes::SPECIALOpcode::MFHI: {
|
||||
|
@ -428,5 +426,5 @@ void Interpreter::step(CpuCore* core, Memory* mem, Disassembler* disassembler) {
|
|||
Helpers::panic("[FATAL] Unimplemented primary instruction 0x%02x (raw: 0x%08x)\n", instr.primaryOpc.Value(), instr.raw);
|
||||
}
|
||||
|
||||
if (core->isDelaySlot) core->isDelaySlot = false;
|
||||
core->isDelaySlot = false;
|
||||
}
|
|
@ -125,7 +125,8 @@ public:
|
|||
Overflow = 0xC
|
||||
};
|
||||
|
||||
void exception(Exception exception) {
|
||||
// If decrementPc is true, epc will be set to pc - 4 instead of pc
|
||||
void exception(Exception exception, bool decrementPc = false) {
|
||||
if (isDelaySlot)
|
||||
cop0.cause.bd = true;
|
||||
else
|
||||
|
@ -144,6 +145,8 @@ public:
|
|||
cop0.cause.raw &= ~0xff;
|
||||
cop0.cause.raw |= (u32)exception << 2;
|
||||
cop0.epc = pc;
|
||||
if (decrementPc)
|
||||
cop0.epc -= 4;
|
||||
if (isDelaySlot)
|
||||
cop0.epc -= 4;
|
||||
pc = handler;
|
||||
|
|
Loading…
Reference in a new issue