about summary refs log tree commit diff stats
path: root/src/dynarec
diff options
context:
space:
mode:
authorxctan <xctan@cirno.icu>2024-12-17 15:23:51 +0800
committerGitHub <noreply@github.com>2024-12-17 08:23:51 +0100
commitf65c22d329e0f2405e2b0f12bc349331b2e4d74b (patch)
treec468c26e25fba7a61caa342ec20edeb410a3f83e /src/dynarec
parent485959195ee9bcfd9049d19e215f2e40f60c83a8 (diff)
downloadbox64-f65c22d329e0f2405e2b0f12bc349331b2e4d74b.tar.gz
box64-f65c22d329e0f2405e2b0f12bc349331b2e4d74b.zip
[RV64_DYNAREC] Extended simple wrapper for more int types (#2160)
Diffstat (limited to 'src/dynarec')
-rw-r--r--src/dynarec/rv64/dynarec_rv64_00_3.c4
-rw-r--r--src/dynarec/rv64/dynarec_rv64_helper.c7
2 files changed, 9 insertions, 2 deletions
diff --git a/src/dynarec/rv64/dynarec_rv64_00_3.c b/src/dynarec/rv64/dynarec_rv64_00_3.c
index 35e9de8c..a0907f4d 100644
--- a/src/dynarec/rv64/dynarec_rv64_00_3.c
+++ b/src/dynarec/rv64/dynarec_rv64_00_3.c
@@ -436,7 +436,7 @@ uintptr_t dynarec64_00_3(dynarec_rv64_t* dyn, uintptr_t addr, uintptr_t ip, int
                     if (isRetX87Wrapper(*(wrapper_t*)(addr)))
                         // return value will be on the stack, so the stack depth needs to be updated
                         x87_purgecache(dyn, ninst, 0, x3, x1, x4);
-                    if (tmp < 0 || tmp > 1)
+                    if (tmp < 0 || (tmp & 15) > 1)
                         tmp = 0; // TODO: removed when FP is in place
                     if ((box64_log < 2 && !cycle_log) && tmp) {
                         // GETIP(ip+3+8+8); // read the 0xCC
@@ -932,7 +932,7 @@ uintptr_t dynarec64_00_3(dynarec_rv64_t* dyn, uintptr_t addr, uintptr_t ip, int
                         tmp = isSimpleWrapper(*(wrapper_t*)(dyn->insts[ninst].natcall + 2));
                     } else
                         tmp = 0;
-                    if (tmp < 0 || tmp > 1)
+                    if (tmp < 0 || (tmp & 15) > 1)
                         tmp = 0; // TODO: removed when FP is in place
                     if (dyn->insts[ninst].natcall && isRetX87Wrapper(*(wrapper_t*)(dyn->insts[ninst].natcall + 2)))
                         // return value will be on the stack, so the stack depth needs to be updated
diff --git a/src/dynarec/rv64/dynarec_rv64_helper.c b/src/dynarec/rv64/dynarec_rv64_helper.c
index a3df47d9..8aa14e53 100644
--- a/src/dynarec/rv64/dynarec_rv64_helper.c
+++ b/src/dynarec/rv64/dynarec_rv64_helper.c
@@ -844,6 +844,13 @@ void call_n(dynarec_rv64_t* dyn, int ninst, void* fnc, int w)
 {
     MAYUSE(fnc);
     fpu_pushcache(dyn, ninst, x3, 1);
+    // check if additional sextw needed
+    int sextw_mask = ((w > 0 ? w : -w) >> 4) & 0b111111;
+    for (int i = 0; i < 6; i++) {
+        if (sextw_mask & (1 << i)) {
+            SEXT_W(A0+i, A0+i);
+        }
+    }
     // native call
     TABLE64(x3, (uintptr_t)fnc);
     JALR(xRA, x3);