From 4f09d6182596ee4060e5aa218ba5cb434b5f4e44 Mon Sep 17 00:00:00 2001 From: Connor McLaughlin Date: Tue, 15 Jun 2021 22:58:29 +1000 Subject: [PATCH] CPU: Don't panic on invalid instructions --- src/core/cpu_core.cpp | 14 ++++++++++---- src/core/cpu_disasm.cpp | 5 ++--- src/core/cpu_types.h | 1 - 3 files changed, 12 insertions(+), 8 deletions(-) diff --git a/src/core/cpu_core.cpp b/src/core/cpu_core.cpp index 0f42d60ab..5c6442e92 100644 --- a/src/core/cpu_core.cpp +++ b/src/core/cpu_core.cpp @@ -1421,7 +1421,7 @@ restart_instruction: break; default: - Panic("Missing implementation"); + Log_ErrorPrintf("Unhandled instruction at %08X: %08X", g_state.current_instruction_pc, inst.bits); break; } } @@ -1438,8 +1438,15 @@ restart_instruction: } break; + case Cop0Instruction::tlbr: + case Cop0Instruction::tlbwi: + case Cop0Instruction::tlbwr: + case Cop0Instruction::tlbp: + RaiseException(Exception::RI); + break; + default: - Panic("Missing implementation"); + Log_ErrorPrintf("Unhandled instruction at %08X: %08X", g_state.current_instruction_pc, inst.bits); break; } } @@ -1500,9 +1507,8 @@ restart_instruction: } break; - case CopCommonInstruction::bcnc: default: - Panic("Missing implementation"); + Log_ErrorPrintf("Unhandled instruction at %08X: %08X", g_state.current_instruction_pc, inst.bits); break; } } diff --git a/src/core/cpu_disasm.cpp b/src/core/cpu_disasm.cpp index 3e0baf246..6caacc409 100644 --- a/src/core/cpu_disasm.cpp +++ b/src/core/cpu_disasm.cpp @@ -158,12 +158,11 @@ static const std::array s_special_table = {{ "UNKNOWN" // 63 }}; -static const std::array, 5> s_cop_common_table = { +static const std::array, 4> s_cop_common_table = { {{CopCommonInstruction::mfcn, "mfc$cop $rt, $coprd"}, {CopCommonInstruction::cfcn, "cfc$cop $rt, $coprd"}, {CopCommonInstruction::mtcn, "mtc$cop $rt, $coprd"}, - {CopCommonInstruction::ctcn, "ctc$cop $rt, $coprd"}, - {CopCommonInstruction::bcnc, "bc$cop$copcc $rel"}}}; + {CopCommonInstruction::ctcn, "ctc$cop $rt, $coprd"}}}; static const std::array, 1> s_cop0_table = {{{Cop0Instruction::rfe, "rfe"}}}; diff --git a/src/core/cpu_types.h b/src/core/cpu_types.h index 5e840e4a3..f1fa878c4 100644 --- a/src/core/cpu_types.h +++ b/src/core/cpu_types.h @@ -154,7 +154,6 @@ enum class CopCommonInstruction : u32 cfcn = 0b0010, mtcn = 0b0100, ctcn = 0b0110, - bcnc = 0b1000, }; enum class Cop0Instruction : u32