Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- unit Safe8087CWUtils;
- interface
- procedure SafeSet8087CW(ANewCW: Word); stdcall; export;
- procedure SafeSet8087CWEx(ANewCW: Word); register;
- function SafeGet8087CW :Word; stdcall; export;
- function SafeGet8087CWEx :Word; register;
- implementation
- function SafeGet8087CW :Word; stdcall; export;
- begin
- Result := SafeGet8087CWEx();
- end;
- function SafeGet8087CWEx :Word; register;
- var
- localCurrentCW: Word;
- asm
- FNSTCW localCurrentCW // Store current FPU control word in to localCurrentCW
- MOV AX, localCurrentCW // Copy value in localCurrentCW to AX register for result
- end;
- procedure SafeSet8087CW(ANewCW: Word);
- begin
- SafeSet8087CWEx(ANewCW);
- end;
- procedure SafeSet8087CWEx(ANewCW: Word);
- var
- localNewCW: Word;
- asm
- MOV localNewCW, ANewCW // Copy ANewCW (in AX) to localNewCW so we can use localNewCW with FLDCW which requires a reference to memory
- FNCLEX // don't raise pending exceptions enabled by the new flags
- FLDCW localNewCW // Load FPU Control Word with value in localNewCW
- end;
- exports
- SafeSet8087CW, SafeGet8087CW;
- end.
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement