Source code of Windows XP (NT5)
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

46 lines
1.1 KiB

  1. #ifdef _X86_
  2. unsigned char _fltused;
  3. long __cdecl
  4. float2long(float arg)
  5. {
  6. long rval;
  7. __asm {
  8. fld arg ; Put <arg> into FPU
  9. fistp rval ; Write out the long version
  10. }
  11. return rval;
  12. }
  13. unsigned short
  14. __cdecl
  15. floatSetup(void)
  16. {
  17. unsigned short oldCWord;
  18. unsigned short newCWord;
  19. __asm {
  20. wait ; Let any pending FPU operations finish
  21. fnstcw word ptr oldCWord ; w/o blocking, store FPU Control word
  22. wait ; Wait for the store to complete
  23. mov ax,word ptr oldCWord ; Load the CW into AX
  24. or ah,0Ch ; Ensure the rounding bits are correct
  25. mov word ptr newCWord,ax ; Save the modified CW from AX
  26. fldcw word ptr newCWord ; Reset the control word with new value
  27. }
  28. return oldCWord;
  29. }
  30. void __cdecl
  31. floatRestore(unsigned short ctlWord)
  32. {
  33. __asm {
  34. wait ; Let any pending FPU operations finish
  35. fldcw word ptr ctlWord ; Restore the CW from the original
  36. }
  37. }
  38. #endif //_X86_