Leaked source code of windows server 2003
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.

58 lines
1.2 KiB

  1. page ,132
  2. title 87ftol - truncate TOS to 32-bit integer
  3. ;***
  4. ;87ftol.asm - truncate TOS to 32-bit integer
  5. ;
  6. ; Copyright (c) 1985-2001, Microsoft Corporation. All rights reserved.
  7. ;
  8. ;Purpose:
  9. ;
  10. ;Revision History:
  11. ;
  12. ; 07/16/85 Greg Whitten
  13. ; save BX and CX for sloppy code generator
  14. ; 10/15/86 Greg Whitten
  15. ; in-line instructions rather than call _fpmath
  16. ; 08/24/87 Barry McCord
  17. ; expand the functionality of _ftol to handle
  18. ; unsigned long by using "fistp qword ptr"
  19. ; 11/24/87 Barry McCord
  20. ; added _loadds under ifdef DLL
  21. ;
  22. ; 08/26/88 Bill Johnston
  23. ; 386 version
  24. ;
  25. ;*******************************************************************************
  26. .xlist
  27. include cruntime.inc
  28. .list
  29. CODESEG
  30. public _ftol
  31. _ftol proc
  32. local oldcw:word
  33. local newcw:word
  34. local intval:qword
  35. fstcw [oldcw] ; get control word
  36. fwait ; synchronize
  37. mov ax, [oldcw] ; round mode saved
  38. or ah, 0ch ; set chop rounding mode
  39. mov [newcw], ax ; back to memory
  40. fldcw [newcw] ; reset rounding
  41. fistp qword ptr [intval] ; store chopped integer
  42. fldcw [oldcw] ; restore rounding
  43. mov eax, dword ptr [intval]
  44. mov edx, dword ptr [intval+4]
  45. ret
  46. _ftol endp
  47. end