From 5b0b6191d8822609fd41856a5c2c8440c8e99ee3 Mon Sep 17 00:00:00 2001 From: Ty Lamontagne Date: Thu, 27 Apr 2023 22:45:53 -0400 Subject: [PATCH] iR5900: Fix memchecks that only log --- pcsx2/x86/ix86-32/iR5900-32.cpp | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/pcsx2/x86/ix86-32/iR5900-32.cpp b/pcsx2/x86/ix86-32/iR5900-32.cpp index 69852e14a6..97b50c840c 100644 --- a/pcsx2/x86/ix86-32/iR5900-32.cpp +++ b/pcsx2/x86/ix86-32/iR5900-32.cpp @@ -1627,10 +1627,23 @@ void recMemcheck(u32 op, u32 bits, bool store) if (checks[i].result & MEMCHECK_LOG) { xMOV(edx, store); - xFastCall((void*)dynarecMemLogcheck, ecx, edx); + // Preserve ecx (address) and edx (address+size) because we aren't breaking + // out of this loops iteration and dynarecMemLogcheck will clobber them + // Also keep 16 byte stack alignment + if(!(checks[i].result & MEMCHECK_BREAK)) + { + xPUSH(eax); xPUSH(ebx); xPUSH(ecx); xPUSH(edx); + xFastCall((void*)dynarecMemLogcheck, ecx, edx); + xPOP(edx); xPOP(ecx); xPOP(ebx); xPOP(eax); + } + else + { + xFastCall((void*)dynarecMemLogcheck, ecx, edx); + } } if (checks[i].result & MEMCHECK_BREAK) { + // Don't need to preserve edx and ecx, we don't return xFastCall((void*)dynarecMemcheck); }