我有一个函数是实用程序库的一部分,它在 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/