about summary refs log tree commit diff stats
diff options
context:
space:
mode:
authorptitSeb <sebastien.chev@gmail.com>2021-04-21 14:53:01 +0200
committerptitSeb <sebastien.chev@gmail.com>2021-04-21 14:53:01 +0200
commit0a2ea72d72109f82dea964461127619710428039 (patch)
tree61877728dba5e86ff1b5e983b1af6fb72b5b87aa
parent3b4de7152c82747526caa29ac5299ef318b77aa1 (diff)
downloadbox64-0a2ea72d72109f82dea964461127619710428039.tar.gz
box64-0a2ea72d72109f82dea964461127619710428039.zip
Added special case for unaligned LOCK INC QWord ptr[ED]
-rw-r--r--src/emu/x64runf0.c16
1 files changed, 13 insertions, 3 deletions
diff --git a/src/emu/x64runf0.c b/src/emu/x64runf0.c
index d126313f..5366e142 100644
--- a/src/emu/x64runf0.c
+++ b/src/emu/x64runf0.c
@@ -631,9 +631,19 @@ int RunF0(x64emu_t *emu, rex_t rex)
                 case 0:                 /* INC Ed */

 #ifdef DYNAREC

                     if(rex.w)

-                        do {

-                            tmp64u = arm64_lock_read_dd(ED);

-                        } while(arm64_lock_write_dd(ED, inc64(emu, tmp64u)));

+                        if(((uintptr_t)ED)&7) {

+                            // unaligned

+                            do {

+                                tmp64u = ED->q[0] & 0xffffffffffffff00LL;

+                                tmp64u |= arm64_lock_read_b(ED);

+                                tmp64u = inc64(emu, tmp64u);

+                            } while(arm64_lock_write_b(ED, tmp64u&0xff));

+                            ED->q[0] = tmp64u;

+                        }

+                        else

+                            do {

+                                tmp64u = arm64_lock_read_dd(ED);

+                            } while(arm64_lock_write_dd(ED, inc64(emu, tmp64u)));

                     else {

                         if((uintptr_t)ED&3) { 

                             //meh.