From 6873443a9a9015f23dd6aeb59047464883ccca6a Mon Sep 17 00:00:00 2001 From: Pierre Date: Mon, 2 Apr 2012 21:02:46 +0200 Subject: [PATCH] DSPJIT: RegCache: Fix writing immediates to guest registers --- .../Core/Core/Src/DSP/Jit/DSPJitRegCache.cpp | 32 +++++++++++++++---- 1 file changed, 25 insertions(+), 7 deletions(-) diff --git a/Source/Core/Core/Src/DSP/Jit/DSPJitRegCache.cpp b/Source/Core/Core/Src/DSP/Jit/DSPJitRegCache.cpp index 7a4050afd8..6397172800 100644 --- a/Source/Core/Core/Src/DSP/Jit/DSPJitRegCache.cpp +++ b/Source/Core/Core/Src/DSP/Jit/DSPJitRegCache.cpp @@ -854,15 +854,33 @@ void DSPJitRegCache::writeReg(int dreg, OpArg arg) { OpArg reg; getReg(dreg, reg, false); - switch(regs[dreg].size) { - case 2: emitter.MOV(16, reg, arg); break; - case 4: emitter.MOV(32, reg, arg); break; + if (arg.IsImm()) { + switch(regs[dreg].size) { + case 2: emitter.MOV(16, reg, Imm16(arg.offset)); break; + case 4: emitter.MOV(32, reg, Imm32(arg.offset)); break; #ifdef _M_X64 - case 8: emitter.MOV(64, reg, arg); break; + case 8: + if ((s32)arg.offset == (s64)arg.offset) + emitter.MOV(64, reg, Imm32(arg.offset)); + else + emitter.MOV(64, reg, Imm64(arg.offset)); + break; #endif - default: - _assert_msg_(DSPLLE, 0, "unsupported memory size"); - break; + default: + _assert_msg_(DSPLLE, 0, "unsupported memory size"); + break; + } + } else { + switch(regs[dreg].size) { + case 2: emitter.MOV(16, reg, arg); break; + case 4: emitter.MOV(32, reg, arg); break; +#ifdef _M_X64 + case 8: emitter.MOV(64, reg, arg); break; +#endif + default: + _assert_msg_(DSPLLE, 0, "unsupported memory size"); + break; + } } putReg(dreg, true); }