1 /* Test fbstp instruction. */
8 struct { uint64_t sig
; uint16_t sign_exp
; } s
;
12 volatile union u ld_invalid_1
= { .s
= { 1, 1234 } };
13 volatile union u ld_invalid_2
= { .s
= { 0, 1234 } };
14 volatile union u ld_invalid_3
= { .s
= { 0, 0x7fff } };
15 volatile union u ld_invalid_4
= { .s
= { (UINT64_C(1) << 63) - 1, 0x7fff } };
20 unsigned char out
[10];
21 memset(out
, 0xfe, sizeof out
);
22 __asm__
volatile ("fbstp %0" : "=m" (out
) : "t" (-0.0L) : "st");
24 if (memcmp(out
, "\0\0\0\0\0\0\0\0\0\x80", sizeof out
) != 0) {
25 printf("FAIL: fbstp -0\n");
28 memset(out
, 0x12, sizeof out
);
29 __asm__
volatile ("fbstp %0" : "=m" (out
) : "t" (-0.1L) : "st");
31 if (memcmp(out
, "\0\0\0\0\0\0\0\0\0\x80", sizeof out
) != 0) {
32 printf("FAIL: fbstp -0.1\n");
35 memset(out
, 0x1f, sizeof out
);
36 __asm__
volatile ("fbstp %0" : "=m" (out
) : "t" (-987654321987654321.0L) :
39 if (memcmp(out
, "\x21\x43\x65\x87\x19\x32\x54\x76\x98\x80",
41 printf("FAIL: fbstp -987654321987654321\n");
44 memset(out
, 0x12, sizeof out
);
45 __asm__
volatile ("fbstp %0" : "=m" (out
) : "t" (999999999999999999.5L) :
47 if (memcmp(out
, "\0\0\0\0\0\0\0\xc0\xff\xff", sizeof out
) != 0) {
48 printf("FAIL: fbstp 999999999999999999.5\n");
51 memset(out
, 0x12, sizeof out
);
52 __asm__
volatile ("fbstp %0" : "=m" (out
) : "t" (1000000000000000000.0L) :
54 if (memcmp(out
, "\0\0\0\0\0\0\0\xc0\xff\xff", sizeof out
) != 0) {
55 printf("FAIL: fbstp 1000000000000000000\n");
58 memset(out
, 0x12, sizeof out
);
59 __asm__
volatile ("fbstp %0" : "=m" (out
) : "t" (1e30L
) : "st");
60 if (memcmp(out
, "\0\0\0\0\0\0\0\xc0\xff\xff", sizeof out
) != 0) {
61 printf("FAIL: fbstp 1e30\n");
64 memset(out
, 0x12, sizeof out
);
65 __asm__
volatile ("fbstp %0" : "=m" (out
) : "t" (-999999999999999999.5L) :
67 if (memcmp(out
, "\0\0\0\0\0\0\0\xc0\xff\xff", sizeof out
) != 0) {
68 printf("FAIL: fbstp -999999999999999999.5\n");
71 memset(out
, 0x12, sizeof out
);
72 __asm__
volatile ("fbstp %0" : "=m" (out
) : "t" (-1000000000000000000.0L) :
74 if (memcmp(out
, "\0\0\0\0\0\0\0\xc0\xff\xff", sizeof out
) != 0) {
75 printf("FAIL: fbstp -1000000000000000000\n");
78 memset(out
, 0x12, sizeof out
);
79 __asm__
volatile ("fbstp %0" : "=m" (out
) : "t" (-1e30L
) : "st");
80 if (memcmp(out
, "\0\0\0\0\0\0\0\xc0\xff\xff", sizeof out
) != 0) {
81 printf("FAIL: fbstp -1e30\n");
84 memset(out
, 0x12, sizeof out
);
85 __asm__
volatile ("fbstp %0" : "=m" (out
) : "t" (__builtin_infl()) : "st");
86 if (memcmp(out
, "\0\0\0\0\0\0\0\xc0\xff\xff", sizeof out
) != 0) {
87 printf("FAIL: fbstp inf\n");
90 memset(out
, 0x12, sizeof out
);
91 __asm__
volatile ("fbstp %0" : "=m" (out
) : "t" (-__builtin_infl()) :
93 if (memcmp(out
, "\0\0\0\0\0\0\0\xc0\xff\xff", sizeof out
) != 0) {
94 printf("FAIL: fbstp -inf\n");
97 memset(out
, 0x12, sizeof out
);
98 __asm__
volatile ("fbstp %0" : "=m" (out
) : "t" (__builtin_nanl("")) :
100 if (memcmp(out
, "\0\0\0\0\0\0\0\xc0\xff\xff", sizeof out
) != 0) {
101 printf("FAIL: fbstp nan\n");
104 memset(out
, 0x12, sizeof out
);
105 __asm__
volatile ("fbstp %0" : "=m" (out
) : "t" (-__builtin_nanl("")) :
107 if (memcmp(out
, "\0\0\0\0\0\0\0\xc0\xff\xff", sizeof out
) != 0) {
108 printf("FAIL: fbstp -nan\n");
111 memset(out
, 0x12, sizeof out
);
112 __asm__
volatile ("fbstp %0" : "=m" (out
) : "t" (ld_invalid_1
.ld
) :
114 if (memcmp(out
, "\0\0\0\0\0\0\0\xc0\xff\xff", sizeof out
) != 0) {
115 printf("FAIL: fbstp invalid 1\n");
118 memset(out
, 0x12, sizeof out
);
119 __asm__
volatile ("fbstp %0" : "=m" (out
) : "t" (ld_invalid_2
.ld
) :
121 if (memcmp(out
, "\0\0\0\0\0\0\0\xc0\xff\xff", sizeof out
) != 0) {
122 printf("FAIL: fbstp invalid 2\n");
125 memset(out
, 0x12, sizeof out
);
126 __asm__
volatile ("fbstp %0" : "=m" (out
) : "t" (ld_invalid_3
.ld
) :
128 if (memcmp(out
, "\0\0\0\0\0\0\0\xc0\xff\xff", sizeof out
) != 0) {
129 printf("FAIL: fbstp invalid 3\n");
132 memset(out
, 0x12, sizeof out
);
133 __asm__
volatile ("fbstp %0" : "=m" (out
) : "t" (ld_invalid_4
.ld
) :
135 if (memcmp(out
, "\0\0\0\0\0\0\0\xc0\xff\xff", sizeof out
) != 0) {
136 printf("FAIL: fbstp invalid 4\n");