about summary refs log tree commit diff stats
path: root/src
diff options
context:
space:
mode:
authorptitSeb <sebastien.chev@gmail.com>2021-03-17 17:07:04 +0100
committerptitSeb <sebastien.chev@gmail.com>2021-03-17 17:07:04 +0100
commit5a07587437722c1e72d12022774613c9c8e52b45 (patch)
tree9d81b481c68bb63e20532be5f54af94938118c8e /src
parent6a14d26c1db433706a4c9ebb8728b4fc5954c76d (diff)
downloadbox64-5a07587437722c1e72d12022774613c9c8e52b45.tar.gz
box64-5a07587437722c1e72d12022774613c9c8e52b45.zip
[DYNAREC] Added C2 RETN and C3 RET opcodes
Diffstat (limited to 'src')
-rwxr-xr-xsrc/dynarec/dynarec_arm64_00.c21
-rwxr-xr-xsrc/dynarec/dynarec_arm64_helper.c2
2 files changed, 23 insertions, 0 deletions
diff --git a/src/dynarec/dynarec_arm64_00.c b/src/dynarec/dynarec_arm64_00.c
index 58207531..5c7cff03 100755
--- a/src/dynarec/dynarec_arm64_00.c
+++ b/src/dynarec/dynarec_arm64_00.c
@@ -326,6 +326,27 @@ uintptr_t dynarec64_00(dynarec_arm_t* dyn, uintptr_t addr, uintptr_t ip, int nin
             }
             break;
 
+        case 0xC2:
+            INST_NAME("RETN");
+            //SETFLAGS(X_ALL, SF_SET);    // Hack, set all flags (to an unknown state...)
+            READFLAGS(X_PEND);  // lets play safe here too
+            BARRIER(2);
+            i32 = F16;
+            retn_to_epilog(dyn, ninst, i32);
+            *need_epilog = 0;
+            *ok = 0;
+            break;
+        case 0xC3:
+            INST_NAME("RET");
+            // SETFLAGS(X_ALL, SF_SET);    // Hack, set all flags (to an unknown state...)
+            // ^^^ that hack break PlantsVsZombies and GOG Setup under wine....
+            READFLAGS(X_PEND);  // so instead, force the defered flags, so it's not too slow, and flags are not lost
+            BARRIER(2);
+            ret_to_epilog(dyn, ninst);
+            *need_epilog = 0;
+            *ok = 0;
+            break;
+
         case 0xE8:
             INST_NAME("CALL Id");
             i32 = F32S;
diff --git a/src/dynarec/dynarec_arm64_helper.c b/src/dynarec/dynarec_arm64_helper.c
index a48bd313..07c744e8 100755
--- a/src/dynarec/dynarec_arm64_helper.c
+++ b/src/dynarec/dynarec_arm64_helper.c
@@ -278,6 +278,7 @@ void ret_to_epilog(dynarec_arm_t* dyn, int ninst)
     LDRx_REG_LSL3(x2, x2, x3);
     UBFXx(x3, xRIP, 0, JMPTABL_SHIFT);
     LDRx_REG_LSL3(x2, x2, x3);
+    MOVx_REG(x1, xRIP);
     BR(x2);
 }
 
@@ -301,6 +302,7 @@ void retn_to_epilog(dynarec_arm_t* dyn, int ninst, int n)
     LDRx_REG_LSL3(x2, x2, x3);
     UBFXx(x3, xRIP, 0, JMPTABL_SHIFT);
     LDRx_REG_LSL3(x2, x2, x3);
+    MOVx_REG(x1, xRIP);
     BR(x2);
 }