about summary refs log tree commit diff stats
path: root/src
diff options
context:
space:
mode:
authorYang Liu <numbksco@gmail.com>2023-05-15 15:17:26 +0800
committerGitHub <noreply@github.com>2023-05-15 09:17:26 +0200
commit92ac8fed99f749db1fbe78c5f9384f9b1e9f1a57 (patch)
tree920dd86c6de3a6c7489aec1d692e1fd6b902545c /src
parent877d31fefb8a8d7afadd45ab5de9dc12decd8201 (diff)
downloadbox64-92ac8fed99f749db1fbe78c5f9384f9b1e9f1a57.tar.gz
box64-92ac8fed99f749db1fbe78c5f9384f9b1e9f1a57.zip
[RV64_DYNAREC] Added some missing fixes on GETEX (#785)
* [RV64_DYNAREC] Added some missing fixes on GETEX

* [RV64_DYNAREC] Fix BSWAP opcode
Diffstat (limited to 'src')
-rw-r--r--src/dynarec/rv64/dynarec_rv64_0f.c9
-rw-r--r--src/dynarec/rv64/dynarec_rv64_660f.c40
2 files changed, 27 insertions, 22 deletions
diff --git a/src/dynarec/rv64/dynarec_rv64_0f.c b/src/dynarec/rv64/dynarec_rv64_0f.c
index 4d538f60..654a8c1c 100644
--- a/src/dynarec/rv64/dynarec_rv64_0f.c
+++ b/src/dynarec/rv64/dynarec_rv64_0f.c
@@ -1507,6 +1507,11 @@ uintptr_t dynarec64_0F(dynarec_rv64_t* dyn, uintptr_t addr, uintptr_t ip, int ni
                 if(!rex.w)
                     SRLI(gd, gd, 32);
             } else {
+                gback = gd;
+                if (!rex.w) {
+                    AND(x4, gd, xMASK);
+                    gd = x4;
+                }
                 ANDI(x1, gd, 0xff);
                 SLLI(x1, x1, (rex.w?64:32)-8);
                 SRLI(x2, gd, 8);
@@ -1520,7 +1525,7 @@ uintptr_t dynarec64_0F(dynarec_rv64_t* dyn, uintptr_t addr, uintptr_t ip, int ni
                 SRLI(x2, gd, 24);
                 if(rex.w) {
                     ANDI(x3, x2, 0xff);
-                    SLLI(x3, x3, (rex.w?64:32)-32);
+                    SLLI(x3, x3, 64-32);
                     OR(x1, x1, x3);
                     SRLI(x2, gd, 32);
                     ANDI(x3, x2, 0xff);
@@ -1536,7 +1541,7 @@ uintptr_t dynarec64_0F(dynarec_rv64_t* dyn, uintptr_t addr, uintptr_t ip, int ni
                     OR(x1, x1, x3);
                     SRLI(x2, gd, 56);
                 }
-                OR(gd, x1, x2);
+                OR(gback, x1, x2);
             }
             break;
         case 0xE5:
diff --git a/src/dynarec/rv64/dynarec_rv64_660f.c b/src/dynarec/rv64/dynarec_rv64_660f.c
index de6684b0..ee84bd68 100644
--- a/src/dynarec/rv64/dynarec_rv64_660f.c
+++ b/src/dynarec/rv64/dynarec_rv64_660f.c
@@ -1647,24 +1647,24 @@ uintptr_t dynarec64_660F(dynarec_rv64_t* dyn, uintptr_t addr, uintptr_t ip, int
                     if(!u8) break;
                     if(u8>15) {
                         // just zero dest
-                        SD(xZR, x1, fixedaddress+0);
-                        SD(xZR, x1, fixedaddress+8);
+                        SD(xZR, wback, fixedaddress+0);
+                        SD(xZR, wback, fixedaddress+8);
                     } else {
                         u8*=8;
                         if (u8 < 64) {
-                            LD(x3, x1, fixedaddress+0);
-                            LD(x4, x1, fixedaddress+8);
+                            LD(x3, wback, fixedaddress+0);
+                            LD(x4, wback, fixedaddress+8);
                             SRLI(x3, x3, u8);
                             SLLI(x5, x4, 64-u8);
                             OR(x3, x3, x5);
-                            SD(x3, x1, fixedaddress+0);
+                            SD(x3, wback, fixedaddress+0);
                             SRLI(x4, x4, u8);
-                            SD(x4, x1, fixedaddress+8);
+                            SD(x4, wback, fixedaddress+8);
                         } else {
-                            LD(x3, x1, fixedaddress+8);
+                            LD(x3, wback, fixedaddress+8);
                             if (u8-64 > 0) { SRLI(x3, x3, u8-64); }
-                            SD(x3, x1, fixedaddress+0);
-                            SD(xZR, x1, fixedaddress+8);
+                            SD(x3, wback, fixedaddress+0);
+                            SD(xZR, wback, fixedaddress+8);
                         }
                     }
                     break;
@@ -1675,8 +1675,8 @@ uintptr_t dynarec64_660F(dynarec_rv64_t* dyn, uintptr_t addr, uintptr_t ip, int
                     if(!u8) break;
                     if(u8>63) {
                         // just zero dest
-                        SD(xZR, x1, fixedaddress+0);
-                        SD(xZR, x1, fixedaddress+8);
+                        SD(xZR, wback, fixedaddress+0);
+                        SD(xZR, wback, fixedaddress+8);
                     } else {
                         LD(x3, wback, fixedaddress+0);
                         LD(x4, wback, fixedaddress+8);
@@ -1693,24 +1693,24 @@ uintptr_t dynarec64_660F(dynarec_rv64_t* dyn, uintptr_t addr, uintptr_t ip, int
                     if(!u8) break;
                     if(u8>15) {
                         // just zero dest
-                        SD(xZR, x1, fixedaddress+0);
-                        SD(xZR, x1, fixedaddress+8);
+                        SD(xZR, wback, fixedaddress+0);
+                        SD(xZR, wback, fixedaddress+8);
                     } else {
                         u8*=8;
                         if (u8 < 64) {
-                            LD(x3, x1, fixedaddress+0);
-                            LD(x4, x1, fixedaddress+8);
+                            LD(x3, wback, fixedaddress+0);
+                            LD(x4, wback, fixedaddress+8);
                             SLLI(x4, x4, u8);
                             SRLI(x5, x3, 64-u8);
                             OR(x4, x4, x5);
-                            SD(x4, x1, fixedaddress+8);
+                            SD(x4, wback, fixedaddress+8);
                             SLLI(x3, x3, u8);
-                            SD(x3, x1, fixedaddress+0);
+                            SD(x3, wback, fixedaddress+0);
                         } else {
-                            LD(x3, x1, fixedaddress+0);
+                            LD(x3, wback, fixedaddress+0);
                             if (u8-64 > 0) { SLLI(x3, x3, u8-64); }
-                            SD(x3, x1, fixedaddress+8);
-                            SD(xZR, x1, fixedaddress+0);
+                            SD(x3, wback, fixedaddress+8);
+                            SD(xZR, wback, fixedaddress+0);
                         }
                     }
                     break;