exp2l.s 1.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980
  1. .global expm1l
  2. .type expm1l,@function
  3. expm1l:
  4. fldt 8(%rsp)
  5. fldl2e
  6. fmulp
  7. fld1
  8. fld %st(1)
  9. fabs
  10. fucom %st(1)
  11. fnstsw %ax
  12. fstp %st(0)
  13. fstp %st(0)
  14. sahf
  15. ja 1f
  16. f2xm1
  17. ret
  18. 1: push %rax
  19. call 1f
  20. pop %rax
  21. fld1
  22. fsubrp
  23. ret
  24. .global exp2l
  25. .type exp2l,@function
  26. exp2l:
  27. fldt 8(%rsp)
  28. 1: fld %st(0)
  29. sub $16,%rsp
  30. fstpt (%rsp)
  31. mov 8(%rsp),%ax
  32. and $0x7fff,%ax
  33. cmp $0x3fff+13,%ax
  34. jb 4f # |x| < 8192
  35. cmp $0x3fff+15,%ax
  36. jae 3f # |x| >= 32768
  37. fsts (%rsp)
  38. cmpl $0xc67ff800,(%rsp)
  39. jb 2f # x > -16382
  40. movl $0x5f000000,(%rsp)
  41. flds (%rsp) # 0x1p63
  42. fld %st(1)
  43. fsub %st(1)
  44. faddp
  45. fucomp %st(1)
  46. fnstsw
  47. sahf
  48. je 2f # x - 0x1p63 + 0x1p63 == x
  49. movl $1,(%rsp)
  50. flds (%rsp) # 0x1p-149
  51. fdiv %st(1)
  52. fstps (%rsp) # raise underflow
  53. 2: fld1
  54. fld %st(1)
  55. frndint
  56. fxch %st(2)
  57. fsub %st(2) # st(0)=x-rint(x), st(1)=1, st(2)=rint(x)
  58. f2xm1
  59. faddp # 2^(x-rint(x))
  60. 1: fscale
  61. fstp %st(1)
  62. add $16,%rsp
  63. ret
  64. 3: xor %eax,%eax
  65. 4: cmp $0x3fff-64,%ax
  66. fld1
  67. jb 1b # |x| < 0x1p-64
  68. fstpt (%rsp)
  69. fistl 8(%rsp)
  70. fildl 8(%rsp)
  71. fsubrp %st(1)
  72. addl $0x3fff,8(%rsp)
  73. f2xm1
  74. fld1
  75. faddp # 2^(x-rint(x))
  76. fldt (%rsp) # 2^rint(x)
  77. fmulp
  78. add $16,%rsp
  79. ret