问题描述
我可以通过以下方式重置FPU的CTRL寄存器:
但是如何保存当前的寄存器,然后再恢复? p>
来自.net代码..
我在做什么,是从Delphi调用.net dll一个COM模块。检查delphi中的寄存器产生一个值,检查.net代码中的controlfp是否提供另一个值。
我需要的是,必须做到这一点:
_controlfp(_CW_DEFAULT,0xfffff);
所以我的.net代码中的浮点计算不会崩溃,但是我想恢复返回时注册。
也许我没有? Delphi可能需要时重置它们?
我发表了关于这个问题的文章 here
使用
SysUtils;
var
SavedCW:Word;
begin
SavedCW:= Get8087CW;
try
Set8087CW($ 027f);
//调用.NET代码
finally
Set8087CW(SavedCW);
结束
结束
I can reset FPU's CTRL registers with this:
http://support.microsoft.com/kb/326219
But how can I save current registers, and restore them later?
It's from .net code..
What I'm doing, is from Delphi calling an .net dll as an COM module. Checking the registers in delphi yield one value, checking with controlfp in the .net code gives another value. What I need, is in essential is to do this:
_controlfp(_CW_DEFAULT, 0xfffff);
So my floatingpoint calculations in the .net code does not crash, but I want to restore the registers when returning.
Maybe I don't? Maybe Delphi is resetting them when needed?I blogged about this problem here.
uses
SysUtils;
var
SavedCW: Word;
begin
SavedCW := Get8087CW;
try
Set8087CW($027f);
// Call .NET code here
finally
Set8087CW(SavedCW);
end;
end;
这篇关于如何设置和恢复FPU CTRL寄存器?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!