modfl.S 6.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263
  1. /*
  2. * Math library
  3. *
  4. * Copyright (C) 2016 Intel Corporation. All rights reserved.
  5. *
  6. * Redistribution and use in source and binary forms, with or without
  7. * modification, are permitted provided that the following conditions
  8. * are met:
  9. *
  10. * * Redistributions of source code must retain the above copyright
  11. * notice, this list of conditions and the following disclaimer.
  12. * * Redistributions in binary form must reproduce the above copyright
  13. * notice, this list of conditions and the following disclaimer in
  14. * the documentation and/or other materials provided with the
  15. * distribution.
  16. * * Neither the name of Intel Corporation nor the names of its
  17. * contributors may be used to endorse or promote products derived
  18. * from this software without specific prior written permission.
  19. *
  20. * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
  21. * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
  22. * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
  23. * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
  24. * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
  25. * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
  26. * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
  27. * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
  28. * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
  29. * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
  30. * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  31. *
  32. *
  33. * Author Name <jingwei.zhang@intel.com>
  34. * History:
  35. * 03-14-2016 Initial version. numerics svn rev. 12864
  36. */
  37. .file "modfl.c"
  38. .text
  39. ..TXTST0:
  40. # -- Begin modfl
  41. .text
  42. .align 16,0x90
  43. .globl modfl
  44. modfl:
  45. # parameter 1: 8 + %ebp
  46. # parameter 2: 20 + %ebp
  47. ..B1.1:
  48. ..L1:
  49. pushl %ebp
  50. movl %esp, %ebp
  51. andl $-16, %esp
  52. pushl %esi
  53. pushl %ebx
  54. subl $24, %esp
  55. movl 20(%ebp), %edx
  56. ..B1.2:
  57. fnstcw 14(%esp)
  58. ..B1.3:
  59. movzwl 16(%ebp), %ecx
  60. andl $32767, %ecx
  61. call ..L2
  62. ..L2:
  63. popl %eax
  64. lea _GLOBAL_OFFSET_TABLE_+[. - ..L2](%eax), %eax
  65. cmpl $16446, %ecx
  66. jge ..B1.21
  67. ..B1.4:
  68. cmpl $16383, %ecx
  69. jl ..B1.16
  70. ..B1.5:
  71. fldt 8(%ebp)
  72. cmpl $16415, %ecx
  73. fstpt (%esp)
  74. jge ..B1.7
  75. ..B1.6:
  76. negl %ecx
  77. movl $-1, %ebx
  78. addl $30, %ecx
  79. shll %cl, %ebx
  80. movl %ebx, %ecx
  81. notl %ecx
  82. movl 12(%ebp), %esi
  83. andl %esi, %ecx
  84. andl %ebx, %esi
  85. xorl %ebx, %ebx
  86. orl 8(%ebp), %ecx
  87. movl %esi, 12(%ebp)
  88. jmp ..B1.8
  89. ..B1.7:
  90. negl %ecx
  91. movl $-1, %ebx
  92. addl $30, %ecx
  93. shll %cl, %ebx
  94. movl %ebx, %ecx
  95. notl %ecx
  96. movl 8(%ebp), %esi
  97. andl %esi, %ecx
  98. andl %esi, %ebx
  99. ..B1.8:
  100. movl %ebx, 8(%ebp)
  101. testl %ecx, %ecx
  102. je ..B1.14
  103. ..B1.9:
  104. movzwl 14(%esp), %ecx
  105. movl %ecx, %eax
  106. andl $768, %eax
  107. cmpl $768, %eax
  108. je ..B1.23
  109. ..B1.10:
  110. orl $-64768, %ecx
  111. movw %cx, 12(%esp)
  112. ..B1.11:
  113. fldcw 12(%esp)
  114. ..B1.12:
  115. fldt 8(%ebp)
  116. fstpt (%edx)
  117. fldt (%edx)
  118. fldt (%esp)
  119. fsubp %st, %st(1)
  120. fstpt (%esp)
  121. ..B1.13:
  122. fldcw 14(%esp)
  123. jmp ..B1.15
  124. ..B1.14:
  125. fldt 8(%ebp)
  126. fstpt (%edx)
  127. movzbl 17(%ebp), %edx
  128. andl $128, %edx
  129. shrl $7, %edx
  130. fldl _zeros@GOTOFF(%eax,%edx,8)
  131. fstpt (%esp)
  132. ..B1.15:
  133. fldt (%esp)
  134. addl $24, %esp
  135. popl %ebx
  136. popl %esi
  137. movl %ebp, %esp
  138. popl %ebp
  139. ret
  140. ..B1.16:
  141. testl %ecx, %ecx
  142. jne ..B1.20
  143. ..B1.17:
  144. cmpl $0, 12(%ebp)
  145. jne ..B1.19
  146. ..B1.18:
  147. cmpl $0, 8(%ebp)
  148. je ..B1.20
  149. ..B1.19:
  150. fldl _smallest_value_64@GOTOFF(%eax)
  151. fstpl 16(%esp)
  152. ..B1.20:
  153. movzbl 17(%ebp), %ecx
  154. andl $128, %ecx
  155. shrl $7, %ecx
  156. fldl _zeros@GOTOFF(%eax,%ecx,8)
  157. fstpt (%edx)
  158. fldt 8(%ebp)
  159. addl $24, %esp
  160. popl %ebx
  161. popl %esi
  162. movl %ebp, %esp
  163. popl %ebp
  164. ret
  165. ..B1.21:
  166. cmpl $32767, %ecx
  167. je ..B1.24
  168. ..B1.22:
  169. fldt 8(%ebp)
  170. fstpt (%edx)
  171. movzbl 17(%ebp), %edx
  172. andl $128, %edx
  173. shrl $7, %edx
  174. fldl _zeros@GOTOFF(%eax,%edx,8)
  175. addl $24, %esp
  176. popl %ebx
  177. popl %esi
  178. movl %ebp, %esp
  179. popl %ebp
  180. ret
  181. ..B1.23:
  182. fldt 8(%ebp)
  183. fstpt (%edx)
  184. fldt (%edx)
  185. fldt (%esp)
  186. fsubp %st, %st(1)
  187. fstpt (%esp)
  188. jmp ..B1.15
  189. ..B1.24:
  190. cmpl $-2147483648, 12(%ebp)
  191. jne ..B1.26
  192. ..B1.25:
  193. cmpl $0, 8(%ebp)
  194. je ..B1.22
  195. ..B1.26:
  196. movzwl 14(%esp), %ebx
  197. movl %ebx, %ecx
  198. andl $768, %ecx
  199. cmpl $768, %ecx
  200. je ..B1.32
  201. ..B1.27:
  202. orl $-64768, %ebx
  203. movw %bx, 12(%esp)
  204. ..B1.28:
  205. fldcw 12(%esp)
  206. ..B1.29:
  207. fldt 8(%ebp)
  208. fmull _ones@GOTOFF(%eax)
  209. fstpt (%esp)
  210. fldt (%esp)
  211. fstpt (%edx)
  212. ..B1.30:
  213. fldcw 14(%esp)
  214. ..B1.31:
  215. fldt (%esp)
  216. addl $24, %esp
  217. popl %ebx
  218. popl %esi
  219. movl %ebp, %esp
  220. popl %ebp
  221. ret
  222. ..B1.32:
  223. fldt 8(%ebp)
  224. fmull _ones@GOTOFF(%eax)
  225. fstpt (%esp)
  226. fldt (%esp)
  227. fstpt (%edx)
  228. jmp ..B1.31
  229. .align 16,0x90
  230. .type modfl,@function
  231. .size modfl,.-modfl
  232. .data
  233. # -- End modfl
  234. .section .rodata, "a"
  235. .align 4
  236. .align 4
  237. _zeros:
  238. .long 0
  239. .long 0
  240. .long 0
  241. .long 2147483648
  242. .type _zeros,@object
  243. .size _zeros,16
  244. .align 4
  245. _smallest_value_64:
  246. .long 1
  247. .long 0
  248. .long 1
  249. .long 2147483648
  250. .type _smallest_value_64,@object
  251. .size _smallest_value_64,16
  252. .align 4
  253. _ones:
  254. .long 0
  255. .long 1072693248
  256. .long 0
  257. .long 3220176896
  258. .type _ones,@object
  259. .size _ones,16
  260. .data
  261. .section .note.GNU-stack, ""
  262. # End