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.

141 lines
4.2 KiB

  1. ; file: ceil_wmt.asm
  2. ; Copyright (C) 1985-2000 Intel Corporation.
  3. ;
  4. ; The information and source code contained herein is the exclusive property
  5. ; of Intel Corporation and may not be disclosed, examined, or reproduced in
  6. ; whole or in part without explicit written authorization from the Company.
  7. ;
  8. ; Implemented in VNIIEF-STL, july 2000
  9. ; double ceil (double x)
  10. ;
  11. ; Willamette specific version (MASM 6.15 required)
  12. ;
  13. ; Description:
  14. ; The ceil function returns the smallest integer value not less than x,
  15. ; expressed as a (double-precision) floating-point number.
  16. ;
  17. ; Special cases:
  18. ; ceil(NaN) = that NaN
  19. ; ceil(INF) = that INF
  20. ; ceil(0) = that 0
  21. ;
  22. ; Accuracy:
  23. ; The result is always exact.
  24. .xlist
  25. include cruntime.inc
  26. .list
  27. EXTRN C __libm_error_support : NEAR
  28. _FUNC_ equ <ceil>
  29. _FUNC_DEF_ equ <_ceil_default>
  30. _FUNC_P4_ equ <_ceil_pentium4>
  31. _FUNC_DEF_EXTERN_ equ 1
  32. include disp_pentium4.inc
  33. .const
  34. ALIGN 16
  35. ;-- 16x-aligned data --------------------------------------------------------
  36. _One DQ 03ff0000000000000H,03ff0000000000000H
  37. _Bns DQ 00000000000000433H,00000000000000433H
  38. _Zero DQ 00000000000000000H,00000000000000000H
  39. _S DQ 000000000000007ffH,00000000000000000H
  40. ;-- 8x-aligned data ---------------------------------------------------------
  41. _NegZero DQ 08000000000000000H
  42. codeseg
  43. ALIGN 16
  44. ; double ceil (double x);
  45. ; Stack frame locations
  46. ceil_x TEXTEQU <esp+4>
  47. XMMWORD TEXTEQU <OWORD>
  48. PUBLIC _ceil_pentium4
  49. _ceil_pentium4 PROC NEAR
  50. movq xmm0, QWORD PTR [ceil_x] ;
  51. movapd xmm2, XMMWORD PTR _Bns ;
  52. movapd xmm1, xmm0 ;
  53. movapd xmm7, xmm0 ;
  54. psrlq xmm0, 52 ; exp(x)
  55. movd eax, xmm0 ;
  56. andpd xmm0, XMMWORD PTR _S ;
  57. psubd xmm2, xmm0 ;
  58. psrlq xmm1, xmm2 ;
  59. test eax, 0800H ;
  60. je SHORT positive ;
  61. cmp eax, 0bffH ;
  62. jl SHORT ret_zero ;
  63. psllq xmm1, xmm2 ;
  64. cmp eax, 0c32H ;
  65. jg SHORT return_x ;
  66. movq QWORD PTR [ceil_x], xmm1 ;
  67. fld QWORD PTR [ceil_x] ;
  68. ret ;
  69. return_x:
  70. ucomisd xmm7, xmm7
  71. jnp not_nan
  72. mov edx, 1004
  73. ;call libm_error_support(void *arg1,void *arg2,void *retval,error_types input_tag)
  74. sub esp, 16
  75. mov DWORD PTR [esp+12],edx
  76. mov edx, esp
  77. add edx, 16+4
  78. mov DWORD PTR [esp+8],edx
  79. mov DWORD PTR [esp+4],edx
  80. mov DWORD PTR [esp],edx
  81. call NEAR PTR __libm_error_support
  82. add esp, 16
  83. not_nan:
  84. fld QWORD PTR [ceil_x] ;
  85. ret ;
  86. positive:
  87. movq xmm0, QWORD PTR [ceil_x] ;
  88. psllq xmm1, xmm2 ;
  89. movapd xmm3, xmm0 ;
  90. cmppd xmm0, xmm1, 6 ; !<=
  91. cmp eax, 03ffH ;
  92. jl SHORT ret_one ;
  93. cmp eax, 0432H ;
  94. jg SHORT return_x ;
  95. andpd xmm0, XMMWORD PTR _One ;
  96. addsd xmm1, xmm0 ;
  97. movq QWORD PTR [ceil_x], xmm1 ;
  98. fld QWORD PTR [ceil_x] ;
  99. ret ;
  100. ret_zero:
  101. fld QWORD PTR _NegZero ;
  102. ret ;
  103. ret_one:
  104. cmppd xmm3, XMMWORD PTR _Zero, 6 ; !<=
  105. andpd xmm3, XMMWORD PTR _One ;
  106. movq QWORD PTR [ceil_x], xmm3 ;
  107. fld QWORD PTR [ceil_x] ;
  108. ret ;
  109. _ceil_pentium4 ENDP
  110. END