about summary refs log tree commit diff stats
diff options
context:
space:
mode:
authorptitSeb <sebastien.chev@gmail.com>2023-10-23 16:07:40 +0200
committerptitSeb <sebastien.chev@gmail.com>2023-10-23 16:07:40 +0200
commitf9b54dab3186f4cdca6545a71eaf50089011255f (patch)
treefcae22cf4aa9a2de0d489cff7ea166af96d9978d
parent391cef85495674fe1abb5ef4ab815ba7ab5ebe02 (diff)
downloadbox64-f9b54dab3186f4cdca6545a71eaf50089011255f.tar.gz
box64-f9b54dab3186f4cdca6545a71eaf50089011255f.zip
Added a workaround for unalinged 32bits xchg
-rw-r--r--src/emu/x64run.c8
1 files changed, 7 insertions, 1 deletions
diff --git a/src/emu/x64run.c b/src/emu/x64run.c
index f9f6e14e..16a3a3b3 100644
--- a/src/emu/x64run.c
+++ b/src/emu/x64run.c
@@ -723,7 +723,13 @@ x64emurun:
                 if(rex.w) {
                     GD->q[0] = native_lock_xchg_dd(ED, GD->q[0]);
                 } else {
-                    GD->q[0] = native_lock_xchg_d(ED, GD->dword[0]);
+                    if((uintptr_t)ED&3) {
+                        // not aligned, dont't try to "LOCK"
+                        tmp32u = ED->dword[0];
+                        ED->dword[0] = GD->dword[0];
+                        GD->q[0] = tmp32u;
+                    } else
+                        GD->q[0] = native_lock_xchg_d(ED, GD->dword[0]);
                 }
             }
 #else