about summary refs log tree commit diff stats
path: root/src
diff options
context:
space:
mode:
authorptitSeb <sebastien.chev@gmail.com>2021-03-06 11:10:00 +0100
committerptitSeb <sebastien.chev@gmail.com>2021-03-06 11:10:00 +0100
commit036f8e47ab85406c5f55928f7157bd867068df17 (patch)
tree1cad970723c3b91aba8925c167fc529cf90e216c /src
parentfda3396140b7de91ab6a2a55e473f9f27634d6f0 (diff)
downloadbox64-036f8e47ab85406c5f55928f7157bd867068df17.tar.gz
box64-036f8e47ab85406c5f55928f7157bd867068df17.zip
Added REX 87 XCHG opcode
Diffstat (limited to 'src')
-rwxr-xr-xsrc/emu/x64run.c38
-rwxr-xr-xsrc/emu/x64run_private.h2
2 files changed, 39 insertions, 1 deletions
diff --git a/src/emu/x64run.c b/src/emu/x64run.c
index f80948ba..b2d2c01e 100755
--- a/src/emu/x64run.c
+++ b/src/emu/x64run.c
@@ -326,6 +326,44 @@ x64emurun:
                 test32(emu, ED->dword[0], GD->dword[0]);
             break;
 
+        case 0x87:                      /* XCHG Ed,Gd */
+            nextop = F8;
+#ifdef DYNAREC
+            GET_ED;
+            if((nextop&0xC0)==0xC0) {
+                tmp32u = GD.dword[0];
+                GD.dword[0] = ED->dword[0];
+                ED->dword[0] = tmp32u;
+            } else {
+                if(((uintptr_t)ED)&3)
+                {
+                    // not aligned, dont't try to "LOCK"
+                    tmp32u = ED->dword[0];
+                    ED->dword[0] = GD.dword[0];
+                    GD.dword[0] = tmp32u;
+                } else {
+                    // XCHG is supposed to automaticaly LOCK memory bus
+                    GD.dword[0] = arm_lock_xchg(ED, GD.dword[0]);
+                }
+            }
+#else
+            GETED;
+            GETGD;
+            if((nextop&0xC0)!=0xC0)
+                pthread_mutex_lock(&emu->context->mutex_lock); // XCHG always LOCK (but when accessing memory only)
+            if(rex.w) {
+                tmp64u = GD->q[0];
+                GD->q[0] = ED->q[0];
+                ED->q[0] = tmp64u;
+            } else {
+                tmp32u = GD->dword[0];
+                GD->dword[0] = ED->dword[0];
+                ED->dword[0] = tmp32u;
+            }
+            if((nextop&0xC0)!=0xC0)
+                pthread_mutex_unlock(&emu->context->mutex_lock);
+#endif
+            break;
         case 0x88:                      /* MOV Eb,Gb */
             nextop = F8;
             GETEB;
diff --git a/src/emu/x64run_private.h b/src/emu/x64run_private.h
index 4a79c1b5..8de7e90f 100755
--- a/src/emu/x64run_private.h
+++ b/src/emu/x64run_private.h
@@ -231,6 +231,7 @@ int Run66(x64emu_t *emu, rex_t rex);
 //int Run67(x64emu_t *emu, rex_t rex);
 int RunD9(x64emu_t *emu, rex_t rex);
 int RunDB(x64emu_t *emu, rex_t rex);
+int RunF0(x64emu_t *emu, rex_t rex);
 int RunF20F(x64emu_t *emu, rex_t rex);
 int RunF30F(x64emu_t *emu, rex_t rex);
 //void Run660F(x64emu_t *emu);
@@ -239,7 +240,6 @@ int RunF30F(x64emu_t *emu, rex_t rex);
 //void RunGS(x64emu_t *emu);
 //void RunFS(x64emu_t *emu);
 //void RunFS66(x64emu_t *emu, uintptr_t tlsdata);
-//void RunLock(x64emu_t *emu);
 //void RunLock66(x64emu_t *emu);
 
 void x64Syscall(x64emu_t *emu);