about summary refs log tree commit diff stats
path: root/src
diff options
context:
space:
mode:
authorptitSeb <sebastien.chev@gmail.com>2023-04-19 16:00:21 +0000
committerptitSeb <sebastien.chev@gmail.com>2023-04-19 16:00:21 +0000
commit206b8bc899a5747b87e2671a81de11a056bb9644 (patch)
treef2abca691aff45f0a86c24e0ca7fad309ec8bc38 /src
parenta0ea94b531733ed8965d9000f8717b83ad589cfc (diff)
downloadbox64-206b8bc899a5747b87e2671a81de11a056bb9644.tar.gz
box64-206b8bc899a5747b87e2671a81de11a056bb9644.zip
[RV64_DYNAREC] More fixes to a few opcodes
Diffstat (limited to 'src')
-rw-r--r--src/dynarec/rv64/dynarec_rv64_00_1.c2
-rw-r--r--src/dynarec/rv64/dynarec_rv64_0f.c33
2 files changed, 34 insertions, 1 deletions
diff --git a/src/dynarec/rv64/dynarec_rv64_00_1.c b/src/dynarec/rv64/dynarec_rv64_00_1.c
index e30c75bd..ee1e554f 100644
--- a/src/dynarec/rv64/dynarec_rv64_00_1.c
+++ b/src/dynarec/rv64/dynarec_rv64_00_1.c
@@ -137,7 +137,7 @@ uintptr_t dynarec64_00_1(dynarec_rv64_t* dyn, uintptr_t addr, uintptr_t ip, int
                 // 64bits imul
                 UFLAG_IF {
                     MULH(x3, ed, x4);
-                    MULW(gd, ed, x4);
+                    MUL(gd, ed, x4);
                     UFLAG_OP1(x3);
                     UFLAG_RES(gd);
                     UFLAG_DF(x3, d_imul64);
diff --git a/src/dynarec/rv64/dynarec_rv64_0f.c b/src/dynarec/rv64/dynarec_rv64_0f.c
index 6f356ff4..adcfc5fe 100644
--- a/src/dynarec/rv64/dynarec_rv64_0f.c
+++ b/src/dynarec/rv64/dynarec_rv64_0f.c
@@ -1014,6 +1014,38 @@ uintptr_t dynarec64_0F(dynarec_rv64_t* dyn, uintptr_t addr, uintptr_t ip, int ni
         case 0xCF:                  /* BSWAP reg */
             INST_NAME("BSWAP Reg");
             gd = xRAX+(opcode&7)+(rex.b<<3);
+            #if 1
+            ANDI(x1, gd, 0xff);
+            SLLI(x1, x1, (rex.w?64:32)-8);
+            SRLI(x2, gd, 8);
+            ANDI(x3, x2, 0xff);
+            SLLI(x3, x3, (rex.w?64:32)-16);
+            OR(x1, x1, x3);
+            SRLI(x2, gd, 16);
+            ANDI(x3, x2, 0xff);
+            SLLI(x3, x3, (rex.w?64:32)-24);
+            OR(x1, x1, x3);
+            SRLI(x2, gd, 24);
+            if(rex.w) {
+                ANDI(x3, x2, 0xff);
+                SLLI(x3, x3, (rex.w?64:32)-32);
+                OR(x1, x1, x3);
+                SRLI(x2, gd, 32);
+                ANDI(x3, x2, 0xff);
+                SLLI(x3, x3, 64-40);
+                OR(x1, x1, x3);
+                SRLI(x2, gd, 40);
+                ANDI(x3, x2, 0xff);
+                SLLI(x3, x3, 64-48);
+                OR(x1, x1, x3);
+                SRLI(x2, gd, 48);
+                ANDI(x3, x2, 0xff);
+                SLLI(x3, x3, 64-56);
+                OR(x1, x1, x3);
+                SRLI(x2, gd, 56);
+            }
+            OR(gd, x1, x2);
+            #else
             MOV_U12(x1, 0xff);
             SLLI(x4, x1, 8); // mask 0xff00
             if (rex.w) {
@@ -1063,6 +1095,7 @@ uintptr_t dynarec64_0F(dynarec_rv64_t* dyn, uintptr_t addr, uintptr_t ip, int ni
                 SLLI(x3, x3, 24);
                 OR(gd, x2, x3);
             }
+            #endif
             break;
 
         default: