target/i386: check for empty register in FXAM
authorPaolo Bonzini <pbonzini@redhat.com>
Fri, 21 Feb 2020 16:20:17 +0000 (17:20 +0100)
committerPaolo Bonzini <pbonzini@redhat.com>
Tue, 25 Feb 2020 08:18:01 +0000 (09:18 +0100)
The fxam instruction returns the wrong result after fdecstp or after
an underflow.  Check fptags to handle this.

Reported-by: <chengang@emindsoft.com.cn>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
target/i386/fpu_helper.c

index 99f28f267f60f7b9b1b79bc5461bbcad71d50650..792a128a6da2d6cd2b6b99634c84fe615ef82972 100644 (file)
@@ -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) {