Skip to contentSkip to conversation

target/i386: check for empty register in FXAM

PATCH New Paolo Bonzini 1 participant 1 message Feb 21, 2020

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 target/i386: check for empty register in FXAM

The fxam instruction returns the wrong result after fdecstp or after an underflow. Check fptags to handle this.

---
 target/i386/fpu_helper.c | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)
target/i386/fpu_helper.c +5 -1
index 99f28f267f..792a128a6d 100644
@@ -991,7 +991,11 @@ void helper_fxam_ST0(CPUX86State *env)
         env->fpus |= 0x200; /* C1 <-- 1 */
     }
 
-    /* XXX: test fptags too */
+    if (env->fptags[env->fpstt]) {
+        env->fpus |= 0x4100; /* Empty */
+        return;
+    }
+
     expdif = EXPD(temp);
     if (expdif == MAXEXPD) {
         if (MANTD(temp) == 0x8000000000000000ULL) {
Signature · 1 line
2.21.1