aboutsummaryrefslogtreecommitdiff
path: root/tests/tcg/i386/test-i386-fbstp.c
blob: d36894918857847255e8bc0e460186484a326e03 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
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;
}