如果我在程序中使用fsin查找值的sin,我会发现表达式语法错误

Mad*_*dhu 2 assembly inline turbo-c++ x87 x86-16

如果我使用fsin查找实数的sin值。我发现和表达语法错误。我在Dos上使用Turbo C ++ 3.0。

我一直在寻找x87 fpu中的指令列表。我试图谷歌一些信息。并将我在编译器设置上的指令集参考从8087更改为80287。

 #include<stdio.h>
    #include<math.h>

void main(){
    double a = 1.98,val;
    asm{
    fld a
    fsin
    fstp val
    }
    printf("%f", val);
}
Run Code Online (Sandbox Code Playgroud)

表达式sntax错误:fsin

Mic*_*tch 5

fsin, fcos, and fsincos instructions were not available until the 80387. Your compiler is unaware of these instructions in the version of Turbo-C++ you are using. If you are running your program in an environment that emulates an 80387 or has a physical 80387 present then you can consider encoding the fsin instruction with a db directive. According to the Instruction Set Architecture reference The fsin instruction is encoded as D9 FE. Your code could look like:

#include<stdio.h>
#include<math.h>

void main(){
    double a = 1.98,val;
    asm{
        fld a
        db 0d9h, 0feh
        fstp val
    }
    printf("%f", val);
}
Run Code Online (Sandbox Code Playgroud)

Note: This code will not function correctly on a system with no FPU, nor will it run on a system with an 8087 or 80287 FPU.


The 80387 Programmers Reference Manual 1987 has a compatibility table for the 8087, 80287, and 80387 processors that describes the supported functionality for this processor family:

在此处输入图片说明