From e49438cdab6c94ae9371c908eb0b933113b266b4 Mon Sep 17 00:00:00 2001 From: zilmar Date: Wed, 30 Aug 2023 12:16:07 +0930 Subject: [PATCH] Core: Add exit reason exception --- Source/Project64-core/N64System/Recompiler/ExitInfo.h | 1 + .../N64System/Recompiler/x86/x86RecompilerOps.cpp | 11 +++++++++++ 2 files changed, 12 insertions(+) diff --git a/Source/Project64-core/N64System/Recompiler/ExitInfo.h b/Source/Project64-core/N64System/Recompiler/ExitInfo.h index 2904fecb3..7a01e172c 100644 --- a/Source/Project64-core/N64System/Recompiler/ExitInfo.h +++ b/Source/Project64-core/N64System/Recompiler/ExitInfo.h @@ -21,6 +21,7 @@ enum ExitReason ExitReason_AddressErrorExceptionRead32, ExitReason_AddressErrorExceptionRead64, ExitReason_IllegalInstruction, + ExitReason_Exception, }; struct CExitInfo diff --git a/Source/Project64-core/N64System/Recompiler/x86/x86RecompilerOps.cpp b/Source/Project64-core/N64System/Recompiler/x86/x86RecompilerOps.cpp index ebbaea37b..f93e98eaf 100644 --- a/Source/Project64-core/N64System/Recompiler/x86/x86RecompilerOps.cpp +++ b/Source/Project64-core/N64System/Recompiler/x86/x86RecompilerOps.cpp @@ -9559,6 +9559,17 @@ void CX86RecompilerOps::CompileExit(uint32_t JumpPC, uint32_t TargetPC, CRegInfo m_Assembler.MoveConstToVariable(&g_System->m_PipelineStage, "g_System->m_PipelineStage", PIPELINE_STAGE_NORMAL); ExitCodeBlock(); break; + case ExitReason_Exception: + m_Assembler.MoveVariableToX86reg(asmjit::x86::edx, &g_System->m_JumpToLocation, "System->m_JumpToLocation"); + m_Assembler.MoveX86regToVariable(&g_Reg->m_PROGRAM_COUNTER, "PROGRAM_COUNTER", asmjit::x86::edx); + m_Assembler.MoveConstToVariable(&g_System->m_PipelineStage, "g_System->m_PipelineStage", PIPELINE_STAGE_NORMAL); + if (TargetPC == (uint32_t)-1) + { + ExitRegSet.SetBlockCycleCount(0); + UpdateCounters(ExitRegSet, true, false, false); + } + ExitCodeBlock(); + break; default: WriteTrace(TraceRecompiler, TraceError, "How did you want to exit on reason (%d) ???", reason); g_Notify->BreakPoint(__FILE__, __LINE__);