Advertisement
Guest User

Untitled

a guest
Jun 23rd, 2017
63
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.08 KB | None | 0 0
  1. unit Safe8087CWUtils;
  2.  
  3. interface
  4.  
  5. procedure SafeSet8087CW(ANewCW: Word); stdcall; export;
  6. procedure SafeSet8087CWEx(ANewCW: Word); register;
  7. function SafeGet8087CW :Word; stdcall; export;
  8. function SafeGet8087CWEx :Word; register;
  9.  
  10. implementation
  11.  
  12. function SafeGet8087CW :Word; stdcall; export;
  13. begin
  14. Result := SafeGet8087CWEx();
  15. end;
  16.  
  17. function SafeGet8087CWEx :Word; register;
  18. var
  19. localCurrentCW: Word;
  20. asm
  21. FNSTCW localCurrentCW // Store current FPU control word in to localCurrentCW
  22. MOV AX, localCurrentCW // Copy value in localCurrentCW to AX register for result
  23. end;
  24.  
  25. procedure SafeSet8087CW(ANewCW: Word);
  26. begin
  27. SafeSet8087CWEx(ANewCW);
  28. end;
  29.  
  30. procedure SafeSet8087CWEx(ANewCW: Word);
  31. var
  32. localNewCW: Word;
  33. asm
  34. MOV localNewCW, ANewCW // Copy ANewCW (in AX) to localNewCW so we can use localNewCW with FLDCW which requires a reference to memory
  35. FNCLEX // don't raise pending exceptions enabled by the new flags
  36. FLDCW localNewCW // Load FPU Control Word with value in localNewCW
  37. end;
  38.  
  39. exports
  40. SafeSet8087CW, SafeGet8087CW;
  41.  
  42. end.
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement