@@ -726,11 +726,14 @@ void helper_fbst_ST0(CPUX86State *env, target_ulong ptr)
int v;
target_ulong mem_ref, mem_end;
int64_t val;
+ CPU_LDoubleU temp;
+
+ temp.d = ST0;
val = floatx80_to_int64(ST0, &env->fp_status);
mem_ref = ptr;
mem_end = mem_ref + 9;
- if (val < 0) {
+ if (SIGND(temp)) {
cpu_stb_data_ra(env, mem_end, 0x80, GETPC());
val = -val;
} else {
new file mode 100644
@@ -0,0 +1,25 @@
+/* Test fbstp instruction. */
+
+#include <stdio.h>
+#include <string.h>
+
+int main(void)
+{
+ int ret = 0;
+ unsigned char out[10];
+ memset(out, 0xfe, sizeof out);
+ __asm__ volatile ("fbstp %0" : "=m" (out) : "t" (-0.0L) : "st");
+ out[9] &= 0x80;
+ if (memcmp(out, "\0\0\0\0\0\0\0\0\0\x80", sizeof out) != 0) {
+ printf("FAIL: fbstp -0\n");
+ ret = 1;
+ }
+ memset(out, 0x12, sizeof out);
+ __asm__ volatile ("fbstp %0" : "=m" (out) : "t" (-0.1L) : "st");
+ out[9] &= 0x80;
+ if (memcmp(out, "\0\0\0\0\0\0\0\0\0\x80", sizeof out) != 0) {
+ printf("FAIL: fbstp -0.1\n");
+ ret = 1;
+ }
+ return ret;
+}