c++ - FPU 控制字设置问题

标签 c++ c++builder inline-assembly

我有一个函数是实用程序库的一部分,它在 C++ Builder 中编译和运行时创建的单元测试失败。问题函数如下。运行单元测试时,程序似乎卡在 fldcw controlWord 行,无法越过该行。似乎在等待着永远不会发生的事情。有什么想法吗?

void FPUControl::setControlWord(short controlWord)
{
    // set the control word - note this assembly construct works on 
    // Visual C++ and Borland C++, but may need to be changed for other
    // compilers
#ifndef __GNUC__
    __asm
    {
        fldcw controlWord
    }
#else
    asm volatile
    (
        "fldcw %[controlWord]"
    :
    : [controlWord] "m" (controlWord)
    );
#endif
}

最佳答案

您的代码对我来说工作正常(使用 C++ Builder 2007 验证)。

setControlWord(Default8087CW);

其中 Default8087CW 是 4978。

关于c++ - FPU 控制字设置问题,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/4643841/

相关文章:

c++ - 在 Visual Studio 中编译时查找 C++ 平台目标

c++ - 适用于矩阵稀疏模式的哈希函数

c++ - 如何获取其他命令行界面程序的输出?

delphi - Embarcadero RAD Studio XE2 中是否有可能( native )嵌套表单?

c++ - 代码分析在 VS 2010 中不起作用

linker-errors - 如何解决 “LME288/Unknown heap name”警告?

c++ - CImg 在 Codegear 2009 中编译问题

c - 重写 GCC 内联汇编以不需要 volatile 或内存破坏

c - 尝试理解 C 中的内联汇编代码

c - GCC 内联汇编