/[qemu]/qemu/tests/test-i386.c
ViewVC logotype

Diff of /qemu/tests/test-i386.c

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1.18 by bellard, Tue May 27 23:23:22 2003 UTC revision 1.19 by bellard, Thu May 29 20:06:57 2003 UTC
# Line 9  Line 9 
9  #include <sys/mman.h>  #include <sys/mman.h>
10  #include <asm/vm86.h>  #include <asm/vm86.h>
11    
12  #define TEST_CMOV 0  #define TEST_CMOV  0
13    #define TEST_FCOMI 0
14    
15  #define xglue(x, y) x ## y  #define xglue(x, y) x ## y
16  #define glue(x, y) xglue(x, y)  #define glue(x, y) xglue(x, y)
# Line 510  void test_fcmp(double a, double b) Line 511  void test_fcmp(double a, double b)
511             a, b, a > b);             a, b, a > b);
512      printf("(%f<=%f)=%d\n",      printf("(%f<=%f)=%d\n",
513             a, b, a >= b);             a, b, a >= b);
514        if (TEST_FCOMI) {
515            unsigned int eflags;
516            /* test f(u)comi instruction */
517            asm("fcomi %2, %1\n"
518                "pushf\n"
519                "pop %0\n"
520                : "=r" (eflags)
521                : "t" (a), "u" (b));
522            printf("fcomi(%f %f)=%08x\n", a, b, eflags & (CC_Z | CC_P | CC_C));
523        }
524  }  }
525    
526  void test_fcvt(double a)  void test_fcvt(double a)
# Line 556  void test_fbcd(double a) Line 567  void test_fbcd(double a)
567             a, bcd[4], bcd[3], bcd[2], bcd[1], bcd[0], b);             a, bcd[4], bcd[3], bcd[2], bcd[1], bcd[0], b);
568  }  }
569    
570    #define TEST_ENV(env, prefix)\
571    {\
572        memset((env), 0xaa, sizeof(*(env)));\
573        asm("fld1\n"\
574            prefix "fnstenv %1\n"\
575            prefix "fldenv %1\n"\
576            : "=t" (res) : "m" (*(env)) : "st");\
577        printf("res=%f\n", res);\
578        printf("fpuc=%04x fpus=%04x fptag=%04x\n",\
579               (env)->fpuc,\
580               (env)->fpus & 0xff00,\
581               (env)->fptag);\
582        memset((env), 0xaa, sizeof(*(env)));\
583        asm("fld1\n"\
584            prefix "fnsave %1\n"\
585            prefix "frstor %1\n"\
586            : "=t" (res) : "m" (*(env)) : "st");\
587        printf("res=%f\n", res);\
588        printf("fpuc=%04x fpus=%04x fptag=%04x\n",\
589               (env)->fpuc,\
590               (env)->fpus & 0xff00,\
591               (env)->fptag);\
592        printf("ST(0) = %Lf\n",\
593               (env)->fpregs[0]);\
594    }
595    
596    void test_fenv(void)
597    {
598        struct __attribute__((packed)) {
599            uint16_t fpuc;
600            uint16_t dummy1;
601            uint16_t fpus;
602            uint16_t dummy2;
603            uint16_t fptag;
604            uint16_t dummy3;
605            uint32_t ignored[4];
606            long double fpregs[8];
607        } float_env32;
608        struct __attribute__((packed)) {
609            uint16_t fpuc;
610            uint16_t fpus;
611            uint16_t fptag;
612            uint16_t ignored[4];
613            long double fpregs[8];
614        } float_env16;
615        double res;
616    
617        TEST_ENV(&float_env16, "data16 ");
618        TEST_ENV(&float_env32, "");
619    }
620    
621  void test_floats(void)  void test_floats(void)
622  {  {
623      test_fops(2, 3);      test_fops(2, 3);
# Line 569  void test_floats(void) Line 631  void test_floats(void)
631      test_fconst();      test_fconst();
632      test_fbcd(1234567890123456);      test_fbcd(1234567890123456);
633      test_fbcd(-123451234567890);      test_fbcd(-123451234567890);
634        test_fenv();
635  }  }
636    
637  /**********************************************/  /**********************************************/

Legend:
Removed from v.1.18  
changed lines
  Added in v.1.19

savannah-hackers-public@gnu.org
ViewVC Help
Powered by ViewVC 1.1.26