about summary refs log tree commit diff stats
path: root/src
diff options
context:
space:
mode:
authorptitSeb <sebastien.chev@gmail.com>2024-09-17 16:39:54 +0200
committerptitSeb <sebastien.chev@gmail.com>2024-09-17 16:39:54 +0200
commitd7c3c3fcf9079bcd24a4221842a8477b89754920 (patch)
tree56277ac561a863807dd0334b53d53c2ab7e00bb6 /src
parent7d77a4b31f222e337e8f873da670b6e5fcdeda57 (diff)
downloadbox64-d7c3c3fcf9079bcd24a4221842a8477b89754920.tar.gz
box64-d7c3c3fcf9079bcd24a4221842a8477b89754920.zip
Save flags and defered flags when runing EmuCall ([DYNAREC] Same for DynaCall)
Diffstat (limited to 'src')
-rw-r--r--src/dynarec/dynarec.c2
-rw-r--r--src/emu/x64emu.c23
2 files changed, 25 insertions, 0 deletions
diff --git a/src/dynarec/dynarec.c b/src/dynarec/dynarec.c
index a9708c84..5dddc23b 100644
--- a/src/dynarec/dynarec.c
+++ b/src/dynarec/dynarec.c
@@ -100,6 +100,7 @@ void DynaCall(x64emu_t* emu, uintptr_t addr)
     uint64_t old_rsi = R_RSI;
     uint64_t old_rbp = R_RBP;
     uint64_t old_rip = R_RIP;
+    x64flags_t old_eflags = emu->eflags;
     // save defered flags
     deferred_flags_t old_df = emu->df;
     multiuint_t old_op1 = emu->op1;
@@ -137,6 +138,7 @@ void DynaCall(x64emu_t* emu, uintptr_t addr)
         emu->res_sav = old_res_sav;
         emu->df_sav = old_df_sav;
         // and the old registers
+        emu->eflags = old_eflags;
         R_RBX = old_rbx;
         R_RDI = old_rdi;
         R_RSI = old_rsi;
diff --git a/src/emu/x64emu.c b/src/emu/x64emu.c
index ddfa0fc6..c37aad16 100644
--- a/src/emu/x64emu.c
+++ b/src/emu/x64emu.c
@@ -592,6 +592,18 @@ void EmuCall(x64emu_t* emu, uintptr_t addr)
     uint64_t old_rsi = R_RSI;
     uint64_t old_rbp = R_RBP;
     uint64_t old_rip = R_RIP;
+    x64flags_t old_eflags = emu->eflags;
+    // save defered flags
+    deferred_flags_t old_df = emu->df;
+    multiuint_t old_op1 = emu->op1;
+    multiuint_t old_op2 = emu->op2;
+    multiuint_t old_res = emu->res;
+    multiuint_t old_op1_sav= emu->op1_sav;
+    multiuint_t old_res_sav= emu->res_sav;
+    deferred_flags_t old_df_sav= emu->df_sav;
+    // uc_link
+    void* old_uc_link = emu->uc_link;
+    emu->uc_link = NULL;
     //Push64(emu, GetRBP(emu));   // set frame pointer
     //SetRBP(emu, GetRSP(emu));   // save RSP
     //R_RSP -= 200;
@@ -607,10 +619,21 @@ void EmuCall(x64emu_t* emu, uintptr_t addr)
     Run(emu, 0);
     emu->quit = 0;  // reset Quit flags...
     emu->df = d_none;
+    emu->uc_link = old_uc_link;
     if(emu->flags.quitonlongjmp && emu->flags.longjmp) {
         if(emu->flags.quitonlongjmp==1)
             emu->flags.longjmp = 0;   // don't change anything because of the longjmp
     } else {
+        // restore defered flags
+        emu->df = old_df;
+        emu->op1 = old_op1;
+        emu->op2 = old_op2;
+        emu->res = old_res;
+        emu->op1_sav = old_op1_sav;
+        emu->res_sav = old_res_sav;
+        emu->df_sav = old_df_sav;
+        // and the old registers
+        emu->eflags = old_eflags;
         R_RBX = old_rbx;
         R_RDI = old_rdi;
         R_RSI = old_rsi;