From 010a60c56a0c929c05051dbadc69eebfc5c1b3d1 Mon Sep 17 00:00:00 2001 From: pierre Date: Sun, 20 Mar 2011 23:30:24 +0000 Subject: [PATCH] Core/DSP/Jit: Fix instruction size retrieval in Branch emitters. Reading the instruction from memory at the given address and using that as index in the opTable leads to more correct results than using the address as index into opTable. Also assert when trying to execute a bad instruction instead of crashing without warning. git-svn-id: https://dolphin-emu.googlecode.com/svn/trunk@7384 8ced0084-cf51-0410-be5f-012b33b47a6e --- Source/Core/Core/Src/DSP/DSPEmitter.cpp | 1 + Source/Core/Core/Src/DSP/Jit/DSPJitBranch.cpp | 10 +++++----- 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/Source/Core/Core/Src/DSP/DSPEmitter.cpp b/Source/Core/Core/Src/DSP/DSPEmitter.cpp index b6fa5bb5a9..571276ef33 100644 --- a/Source/Core/Core/Src/DSP/DSPEmitter.cpp +++ b/Source/Core/Core/Src/DSP/DSPEmitter.cpp @@ -109,6 +109,7 @@ void DSPEmitter::Default(UDSPInstruction inst) // Fall back to interpreter gpr.pushRegs(); + _assert_msg_(DSPLLE, opTable[inst]->intFunc, "No function for %04x",inst); ABI_CallFunctionC16((void*)opTable[inst]->intFunc, inst); gpr.popRegs(); } diff --git a/Source/Core/Core/Src/DSP/Jit/DSPJitBranch.cpp b/Source/Core/Core/Src/DSP/Jit/DSPJitBranch.cpp index aceed3560c..9c9844051c 100644 --- a/Source/Core/Core/Src/DSP/Jit/DSPJitBranch.cpp +++ b/Source/Core/Core/Src/DSP/Jit/DSPJitBranch.cpp @@ -267,7 +267,7 @@ void r_ifcc(const UDSPInstruction opc, DSPEmitter& emitter) // NOTE: Cannot use Default(opc) here because of the need to write branch exit void DSPEmitter::ifcc(const UDSPInstruction opc) { - MOV(16, M(&g_dsp.pc), Imm16((compilePC + 1) + opTable[compilePC + 1]->size)); + MOV(16, M(&g_dsp.pc), Imm16((compilePC + 1) + opTable[dsp_imem_read(compilePC + 1)]->size)); ReJitConditional(opc, *this); WriteBranchExit(*this); } @@ -382,7 +382,7 @@ void DSPEmitter::loop(const UDSPInstruction opc) SetJumpTarget(cnt); // dsp_skip_inst(); - MOV(16, M(&g_dsp.pc), Imm16(loop_pc + opTable[loop_pc]->size)); + MOV(16, M(&g_dsp.pc), Imm16(loop_pc + opTable[dsp_imem_read(loop_pc)]->size)); WriteBranchExit(*this); gpr.flushRegs(c,false); SetJumpTarget(exit); @@ -415,7 +415,7 @@ void DSPEmitter::loopi(const UDSPInstruction opc) else { // dsp_skip_inst(); - MOV(16, M(&g_dsp.pc), Imm16(loop_pc + opTable[loop_pc]->size)); + MOV(16, M(&g_dsp.pc), Imm16(loop_pc + opTable[dsp_imem_read(loop_pc)]->size)); WriteBranchExit(*this); } } @@ -452,7 +452,7 @@ void DSPEmitter::bloop(const UDSPInstruction opc) SetJumpTarget(cnt); // g_dsp.pc = loop_pc; // dsp_skip_inst(); - MOV(16, M(&g_dsp.pc), Imm16(loop_pc + opTable[loop_pc]->size)); + MOV(16, M(&g_dsp.pc), Imm16(loop_pc + opTable[dsp_imem_read(loop_pc)]->size)); WriteBranchExit(*this); gpr.flushRegs(c,false); SetJumpTarget(exit); @@ -488,7 +488,7 @@ void DSPEmitter::bloopi(const UDSPInstruction opc) { // g_dsp.pc = loop_pc; // dsp_skip_inst(); - MOV(16, M(&g_dsp.pc), Imm16(loop_pc + opTable[loop_pc]->size)); + MOV(16, M(&g_dsp.pc), Imm16(loop_pc + opTable[dsp_imem_read(loop_pc)]->size)); WriteBranchExit(*this); } }