开发者

Problem setting FPU Control word

I have a function that is part of a utilities library and it is failing unit tests created when compiled and run in C++ Builder. The problem functi开发者_JAVA技巧on is below. When running the unit test the program seems to get stuck at the line fldcw controlWord and can't move past that. It seems to be waiting for something that will never occur. Any ideas?

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
}


Your code works fine for me (verified with C++ Builder 2007).

setControlWord(Default8087CW);

where Default8087CW is 4978.


@Zach: The code compiles and runs under C++Builder XE too. For the record, I did not include it as part of a class.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜