exp.s 1.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116
  1. .global expm1f
  2. .type expm1f,@function
  3. expm1f:
  4. flds 4(%esp)
  5. jmp 1f
  6. .global expm1l
  7. .type expm1l,@function
  8. expm1l:
  9. fldt 4(%esp)
  10. jmp 1f
  11. .global expm1
  12. .type expm1,@function
  13. expm1:
  14. fldl 4(%esp)
  15. 1: fldl2e
  16. fmulp
  17. fld1
  18. fld %st(1)
  19. fabs
  20. fucom %st(1)
  21. fnstsw %ax
  22. fstp %st(0)
  23. fstp %st(0)
  24. sahf
  25. ja 1f
  26. f2xm1
  27. ret
  28. 1: call 1f
  29. fld1
  30. fsubrp
  31. ret
  32. .global exp2f
  33. .type exp2f,@function
  34. exp2f:
  35. flds 4(%esp)
  36. jmp 1f
  37. .global exp2l
  38. .type exp2l,@function
  39. exp2l:
  40. fldt 4(%esp)
  41. jmp 1f
  42. .global expf
  43. .type expf,@function
  44. expf:
  45. flds 4(%esp)
  46. jmp 2f
  47. .global expl
  48. .type expl,@function
  49. expl:
  50. fldt 4(%esp)
  51. jmp 2f
  52. .global exp
  53. .type exp,@function
  54. exp:
  55. fldl 4(%esp)
  56. 2: fldl2e
  57. fmulp
  58. jmp 1f
  59. .global exp2
  60. .type exp2,@function
  61. exp2:
  62. fldl 4(%esp)
  63. 1: pushl $0x467ff000
  64. flds (%esp) # 16380
  65. xorl %eax,%eax
  66. pushl $0x80000000
  67. push %eax
  68. fld %st(1)
  69. fabs
  70. fucomp %st(1)
  71. fnstsw
  72. fstp %st(0)
  73. sahf
  74. ja 3f # |x| > 16380
  75. jp 2f # x is nan (avoid invalid except in fistp)
  76. fld %st(0)
  77. fistpl 8(%esp)
  78. fildl 8(%esp)
  79. fxch %st(1)
  80. fsub %st(1)
  81. mov $0x3fff,%eax
  82. add %eax,8(%esp)
  83. f2xm1
  84. fld1
  85. faddp # 2^(x-rint(x))
  86. fldt (%esp) # 2^rint(x)
  87. fmulp
  88. fstp %st(1)
  89. 2: add $12,%esp
  90. ret
  91. 3: fld %st(0)
  92. fstpt (%esp)
  93. fld1
  94. mov 8(%esp),%ax
  95. and $0x7fff,%ax
  96. cmp $0x7fff,%ax
  97. je 1f # x = +-inf
  98. fld %st(1)
  99. frndint
  100. fxch %st(2)
  101. fsub %st(2) # st(0)=x-rint(x), st(1)=1, st(2)=rint(x)
  102. f2xm1
  103. faddp # 2^(x-rint(x))
  104. 1: fscale
  105. fstp %st(1)
  106. add $12,%esp
  107. ret