about summary refs log tree commit diff stats
path: root/src/emu/x64runde.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/emu/x64runde.c')
-rw-r--r--src/emu/x64runde.c8
1 files changed, 7 insertions, 1 deletions
diff --git a/src/emu/x64runde.c b/src/emu/x64runde.c
index 4cb5e4a2..8b082aa5 100644
--- a/src/emu/x64runde.c
+++ b/src/emu/x64runde.c
@@ -1,4 +1,5 @@
 #define _GNU_SOURCE
+#include <fenv.h>
 #include <stdint.h>
 #include <stdio.h>
 #include <stdlib.h>
@@ -17,6 +18,7 @@
 #include "x64primop.h"
 #include "x64trace.h"
 #include "x87emu_private.h"
+#include "x87emu_setround.h"
 #include "box64context.h"
 #include "bridge.h"
 
@@ -34,6 +36,7 @@ uintptr_t RunDE(x64emu_t *emu, rex_t rex, uintptr_t addr)
     x64emu_t*emu = test->emu;
     #endif
 
+    int oldround = fpu_setround(emu);
     nextop = F8;
     if(MODREG)
     switch(nextop) {
@@ -126,6 +129,7 @@ uintptr_t RunDE(x64emu_t *emu, rex_t rex, uintptr_t addr)
             break;
 
         default:
+            fesetround(oldround);
             return 0;
     } else
         switch((nextop>>3)&7) {
@@ -154,7 +158,9 @@ uintptr_t RunDE(x64emu_t *emu, rex_t rex, uintptr_t addr)
                 ST0.d = (double)EW->sword[0] / ST0.d;
                 break;
            default:
+                fesetround(oldround);
                 return 0;
         }
-  return addr;
+    fesetround(oldround);
+    return addr;
 }
\ No newline at end of file