[R] Questions about Preserving registers

Thomas Lumley tlumley at u.washington.edu
Thu Jun 10 18:12:05 CEST 2004


On Thu, 10 Jun 2004, Rui wrote:

> Hi folks,
>
> I tried to use Mirosoft Fortran Powerstation 4.0 to create a dll file.
> However, when I used the command dyn.load("test.dll"), I got the
> following message:
>
> NULL
> Warning message:
> DLL attempted to change FPU control word from 9001f to 90003
>
> I read the instruction on Duncan Murdoch’s website about preserving
> registers, but I still don’t understand it. For example,

This code is for Delphi.  You would need to see how to set the FPU control
work in Powerstation Fortran, which should be described in its manual.

The warning is harmless, so you could just ignore it.  The warning means
that R has done the change for you.

	-thomas



>
> 1. On first entry to the DLL, set the control word to the standard R
> value, then save that as the Delphi default. Put this code in the
> library module:
> ## My question: Is that mean put the following code in my Fortran
> routine without any change based on the message I got?
>
> procedure Rwin_fpset; cdecl; external 'R.dll';
>
> function Get8087CW:word;
> begin
>   asm
>     fstcw result
>   end;
> end;
>
> begin
>   Rwin_fpset();
>   Set8087CW(Get8087CW);
> end.
>
> 2. After any operation that may have changed the status word, put this
> call before returning to R:
> ##  My question: where do I put the line below?
>
>   Set8087CW(Default8087CW);
>
>
> 3. The following function may be useful in debugging; it returns false
> when the control word has been unexpectedly changed:
>
> function Okay8087CW:boolean;
> begin
>   result := ((Default8087CW xor Get8087CW) and not $E060) = 0;
> end;
>
> Thanks.
>
> Rui
>
> Phone: (403)220-4501
> Email: rwang at math.ucalgary.ca
> Department of Mathematics and Statistics
> University of Calgary
>
>
> 	[[alternative HTML version deleted]]
>
> ______________________________________________
> R-help at stat.math.ethz.ch mailing list
> https://www.stat.math.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
>

Thomas Lumley			Assoc. Professor, Biostatistics
tlumley at u.washington.edu	University of Washington, Seattle




More information about the R-help mailing list