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.

123 lines
3.2 KiB

  1. ;***
  2. ;
  3. ; Copyright (c) 1984-2001, Microsoft Corporation. All rights reserved.
  4. ;
  5. ;Purpose:
  6. ; support for atan() function
  7. ;
  8. ;Revision History:
  9. ; 01-26-01 PML Pentium4 merge.
  10. ;
  11. ;*******************************************************************************
  12. .xlist
  13. include cruntime.inc
  14. include elem87.inc
  15. .list
  16. _FUNC_ equ <atan>
  17. _FUNC_DEF_ equ <_atan_default>
  18. _FUNC_P4_ equ <_atan_pentium4>
  19. _FUNC_P4_EXTERN_ equ 1
  20. include disp_pentium4.inc
  21. _FUNC_ equ <_CIatan>
  22. _FUNC_DEF_ equ <_CIatan_default>
  23. _FUNC_P4_ equ <_CIatan_pentium4>
  24. include disp_pentium4.inc
  25. .data
  26. _NAME_ db 'atan',0,0,0,0
  27. extrn _indefinite:tbyte
  28. extrn __fastflag:dword
  29. extrn _piby2:tbyte
  30. extrn _DEFAULT_CW_in_mem:word
  31. CODESEG
  32. extrn _startOneArgErrorHandling:near
  33. extrn _fload_withFB:near
  34. extrn _convertTOStoQNaN:near
  35. extrn _checkTOS_withFB:near
  36. extrn _math_exit:near
  37. extrn _fast_exit:near
  38. ; arg ErrorType result
  39. ;-------------------------------------------
  40. ;+infinity - pi/2
  41. ;-infinity - -pi/2
  42. ;QNaN DOMAIN_QNAN QNaN | ? to distinguish them???
  43. ;SNaN DOMAIN indefinite | ? it costs 14 bytes per function
  44. ;indefinite is like QNaN
  45. ;denormal fld converts it to normal (80 bits)
  46. public _atan_default,_CIatan_default
  47. _CIatan_default proc
  48. sub esp,DBLSIZE+4 ; for argument
  49. fst qword ptr [esp]
  50. call _checkTOS_withFB
  51. call start
  52. add esp, DBLSIZE+4
  53. ret
  54. _atan_default label proc
  55. lea edx, [esp+4]
  56. call _fload_withFB
  57. start:
  58. push edx ; allocate space for Control Word
  59. fstcw [esp] ; store Control Word
  60. ; at this point we have on stack: cw(4), ret_addr(4), arg1(8bytes)
  61. jz inf_or_nan
  62. cmp word ptr[esp], default_CW
  63. je CW_is_set_to_default
  64. ; fpatan is not affected by precision bits. So we may ignore user's CW
  65. fldcw _DEFAULT_CW_in_mem
  66. CW_is_set_to_default:
  67. fld1 ; load 1.0
  68. fpatan ; fpatan(x,1.0)
  69. exit:
  70. cmp __fastflag, 0
  71. jnz _fast_exit
  72. ; prepare in registers arguments for math_exit
  73. mov edx,OP_ATAN
  74. lea ecx,[_NAME_]
  75. jmp _math_exit
  76. not_infinity:
  77. call _convertTOStoQNaN ; eax MUST contain high dword
  78. jmp _Error_handling ; eax=error number
  79. inf_or_nan:
  80. test eax, 000fffffh
  81. jnz not_infinity
  82. cmp dword ptr[esp+8], 0
  83. jne not_infinity
  84. fstp st(0)
  85. fld [_piby2]
  86. test eax,80000000H
  87. jz exit ; return pi/2
  88. fchs
  89. jmp exit ; return -pi/2
  90. mov eax,DOMAIN
  91. _Error_handling:
  92. cmp __fastflag, 0
  93. jnz _fast_exit
  94. mov edx,OP_ATAN
  95. lea ecx,[_NAME_]
  96. call _startOneArgErrorHandling
  97. pop edx ; remove saved CW from stack
  98. ret
  99. _CIatan_default endp
  100. end