about summary refs log tree commit diff stats
path: root/src
diff options
context:
space:
mode:
authorYang Liu <numbksco@gmail.com>2024-04-06 14:48:00 +0800
committerGitHub <noreply@github.com>2024-04-06 08:48:00 +0200
commit3e412891674af3d4eb77675853c1f10715dfabce (patch)
tree7c6bfa82daab11b92537d2842c2ed07966bb61e5 /src
parent9cf53737240611b39f1e0b5f884b01990e43e9b1 (diff)
downloadbox64-3e412891674af3d4eb77675853c1f10715dfabce.tar.gz
box64-3e412891674af3d4eb77675853c1f10715dfabce.zip
[DYNAREC] Fixed REP opcodes for correct register state recovery (#1420)
Diffstat (limited to 'src')
-rw-r--r--src/dynarec/la64/dynarec_la64_00.c4
-rw-r--r--src/dynarec/rv64/dynarec_rv64_00_2.c8
-rw-r--r--src/dynarec/rv64/dynarec_rv64_66.c6
3 files changed, 9 insertions, 9 deletions
diff --git a/src/dynarec/la64/dynarec_la64_00.c b/src/dynarec/la64/dynarec_la64_00.c
index bdf04154..6940839d 100644
--- a/src/dynarec/la64/dynarec_la64_00.c
+++ b/src/dynarec/la64/dynarec_la64_00.c
@@ -666,8 +666,8 @@ uintptr_t dynarec64_00(dynarec_la64_t* dyn, uintptr_t addr, uintptr_t ip, int ni
                     BNEZ_MARK2(x1);
                     MARK; // Part with DF==0
                     LD_BU(x1, xRSI, 0);
-                    ADDI_D(xRSI, xRSI, 1);
                     LD_BU(x2, xRDI, 0);
+                    ADDI_D(xRSI, xRSI, 1);
                     ADDI_D(xRDI, xRDI, 1);
                     ADDI_D(xRCX, xRCX, -1);
                     if (rep == 1) {
@@ -679,8 +679,8 @@ uintptr_t dynarec64_00(dynarec_la64_t* dyn, uintptr_t addr, uintptr_t ip, int ni
                     B_MARK3_nocond;
                     MARK2; // Part with DF==1
                     LD_BU(x1, xRSI, 0);
-                    ADDI_D(xRSI, xRSI, -1);
                     LD_BU(x2, xRDI, 0);
+                    ADDI_D(xRSI, xRSI, -1);
                     ADDI_D(xRDI, xRDI, -1);
                     ADDI_D(xRCX, xRCX, -1);
                     if (rep == 1) {
diff --git a/src/dynarec/rv64/dynarec_rv64_00_2.c b/src/dynarec/rv64/dynarec_rv64_00_2.c
index 6dc4f3c5..e62c73e9 100644
--- a/src/dynarec/rv64/dynarec_rv64_00_2.c
+++ b/src/dynarec/rv64/dynarec_rv64_00_2.c
@@ -625,8 +625,8 @@ uintptr_t dynarec64_00_2(dynarec_rv64_t* dyn, uintptr_t addr, uintptr_t ip, int
                 BNEZ_MARK2(x1);
                 MARK;   // Part with DF==0
                 LBU(x1, xRSI, 0);
-                ADDI(xRSI, xRSI, 1);
                 LBU(x2, xRDI, 0);
+                ADDI(xRSI, xRSI, 1);
                 ADDI(xRDI, xRDI, 1);
                 SUBI(xRCX, xRCX, 1);
                 if (rep==1) {BEQ_MARK3(x1, x2);} else {BNE_MARK3(x1, x2);}
@@ -634,8 +634,8 @@ uintptr_t dynarec64_00_2(dynarec_rv64_t* dyn, uintptr_t addr, uintptr_t ip, int
                 B_MARK3_nocond;
                 MARK2;   // Part with DF==1
                 LBU(x1, xRSI, 0);
-                SUBI(xRSI, xRSI, 1);
                 LBU(x2, xRDI, 0);
+                SUBI(xRSI, xRSI, 1);
                 SUBI(xRDI, xRDI, 1);
                 SUBI(xRCX, xRCX, 1);
                 if (rep==1) {BEQ_MARK3(x1, x2);} else {BNE_MARK3(x1, x2);}
@@ -667,8 +667,8 @@ uintptr_t dynarec64_00_2(dynarec_rv64_t* dyn, uintptr_t addr, uintptr_t ip, int
                     BNEZ_MARK2(x1);
                     MARK; // Part with DF==0
                     LDxw(x1, xRSI, 0);
-                    ADDI(xRSI, xRSI, rex.w ? 8 : 4);
                     LDxw(x2, xRDI, 0);
+                    ADDI(xRSI, xRSI, rex.w ? 8 : 4);
                     ADDI(xRDI, xRDI, rex.w ? 8 : 4);
                     SUBI(xRCX, xRCX, 1);
                     if (rep == 1) { BEQ_MARK3(x1, x2); } else { BNE_MARK3(x1, x2); }
@@ -676,8 +676,8 @@ uintptr_t dynarec64_00_2(dynarec_rv64_t* dyn, uintptr_t addr, uintptr_t ip, int
                     B_MARK3_nocond;
                     MARK2; // Part with DF==1
                     LDxw(x1, xRSI, 0);
-                    SUBI(xRSI, xRSI, rex.w ? 8 : 4);
                     LDxw(x2, xRDI, 0);
+                    SUBI(xRSI, xRSI, rex.w ? 8 : 4);
                     SUBI(xRDI, xRDI, rex.w ? 8 : 4);
                     SUBI(xRCX, xRCX, 1);
                     if (rep == 1) { BEQ_MARK3(x1, x2); } else { BNE_MARK3(x1, x2); }
diff --git a/src/dynarec/rv64/dynarec_rv64_66.c b/src/dynarec/rv64/dynarec_rv64_66.c
index 06ac0fe1..a17aae3b 100644
--- a/src/dynarec/rv64/dynarec_rv64_66.c
+++ b/src/dynarec/rv64/dynarec_rv64_66.c
@@ -760,8 +760,8 @@ uintptr_t dynarec64_66(dynarec_rv64_t* dyn, uintptr_t addr, uintptr_t ip, int ni
                 B_NEXT_nocond;
                 MARK2;  // Part with DF==1
                 LH(x1, xRSI, 0);
-                SUBI(xRSI, xRSI, 2);
                 SH(x1, xRDI, 0);
+                SUBI(xRSI, xRSI, 2);
                 SUBI(xRDI, xRDI, 2);
                 SUBI(xRCX, xRCX, 1);
                 BNEZ_MARK2(xRCX);
@@ -787,8 +787,8 @@ uintptr_t dynarec64_66(dynarec_rv64_t* dyn, uintptr_t addr, uintptr_t ip, int ni
                     BNEZ_MARK2(x1);
                     MARK; // Part with DF==0
                     LHU(x1, xRSI, 0);
-                    ADDI(xRSI, xRSI, 2);
                     LHU(x2, xRDI, 0);
+                    ADDI(xRSI, xRSI, 2);
                     ADDI(xRDI, xRDI, 2);
                     SUBI(xRCX, xRCX, 1);
                     if (rep == 1) { BEQ_MARK3(x1, x2); } else { BNE_MARK3(x1, x2); }
@@ -796,8 +796,8 @@ uintptr_t dynarec64_66(dynarec_rv64_t* dyn, uintptr_t addr, uintptr_t ip, int ni
                     B_MARK3_nocond;
                     MARK2; // Part with DF==1
                     LHU(x1, xRSI, 0);
-                    SUBI(xRSI, xRSI, 2);
                     LHU(x2, xRDI, 0);
+                    SUBI(xRSI, xRSI, 2);
                     SUBI(xRDI, xRDI, 2);
                     SUBI(xRCX, xRCX, 1);
                     if (rep == 1) { BEQ_MARK3(x1, x2); } else { BNE_MARK3(x1, x2); }