diff --git a/Core/MIPS/x86/CompLoadStore.cpp b/Core/MIPS/x86/CompLoadStore.cpp index 9ef4b0b206..603e3e367a 100644 --- a/Core/MIPS/x86/CompLoadStore.cpp +++ b/Core/MIPS/x86/CompLoadStore.cpp @@ -44,6 +44,7 @@ // #define CONDITIONAL_DISABLE(flag) { Comp_Generic(op); return; } #define CONDITIONAL_DISABLE(flag) if (jo.Disabled(JitDisable::flag)) { Comp_Generic(op); return; } #define DISABLE { Comp_Generic(op); return; } +#define INVALIDOP { Comp_Generic(op); return; } namespace MIPSComp { using namespace Gen; @@ -408,7 +409,37 @@ namespace MIPSComp { void Jit::Comp_StoreSync(MIPSOpcode op) { CONDITIONAL_DISABLE(LSU); - DISABLE; + int offset = _IMM16; + MIPSGPReg rt = _RT; + MIPSGPReg rs = _RS; + // Note: still does something even if loading to zero. + + CheckMemoryBreakpoint(0, rs, offset); + + FixupBranch skipStore; + FixupBranch finish; + switch (op >> 26) { + case 48: // ll + CompITypeMemRead(op, 32, &XEmitter::MOVZX, safeMemFuncs.readU32); + MOV(8, MDisp(X64JitConstants::CTXREG, -128 + offsetof(MIPSState, llBit)), Imm8(1)); + break; + + case 56: // sc + CMP(8, MDisp(X64JitConstants::CTXREG, -128 + offsetof(MIPSState, llBit)), Imm8(1)); + skipStore = J_CC(CC_NE); + + CompITypeMemWrite(op, 32, safeMemFuncs.writeU32); + MOV(32, gpr.R(rt), Imm32(1)); + finish = J(); + + SetJumpTarget(skipStore); + MOV(32, gpr.R(rt), Imm32(0)); + SetJumpTarget(finish); + break; + + default: + INVALIDOP; + } } void Jit::Comp_Cache(MIPSOpcode op) {