remquo.S 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573
  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 "remquo.c"
  38. .text
  39. ..TXTST0:
  40. # -- Begin remquo
  41. .text
  42. .align 16,0x90
  43. .globl remquo
  44. remquo:
  45. # parameter 1: 8 + %ebp
  46. # parameter 2: 16 + %ebp
  47. # parameter 3: 24 + %ebp
  48. ..B1.1:
  49. ..L1:
  50. pushl %ebp
  51. movl %esp, %ebp
  52. andl $-16, %esp
  53. pushl %esi
  54. pushl %edi
  55. pushl %ebx
  56. subl $84, %esp
  57. movl 24(%ebp), %ecx
  58. movl %ecx, 56(%esp)
  59. movl 12(%ebp), %ecx
  60. movl %ecx, %edx
  61. movl 20(%ebp), %esi
  62. movl %esi, %eax
  63. andl $-2147483648, %edx
  64. andl $-2147483648, %eax
  65. cmpl %edx, %eax
  66. movl $-1, %eax
  67. movl %edx, 48(%esp)
  68. jne ..L2
  69. movl $1, %eax
  70. ..L2:
  71. andl $2147483647, %ecx
  72. andl $2147483647, %esi
  73. movl %ecx, %edi
  74. movl %esi, %ebx
  75. andl $2146435072, %edi
  76. andl $2146435072, %ebx
  77. movl %eax, 52(%esp)
  78. shrl $20, %edi
  79. movl 8(%ebp), %eax
  80. movl 16(%ebp), %edx
  81. shrl $20, %ebx
  82. movl %eax, 8(%esp)
  83. cmpl $2047, %edi
  84. movl %ecx, 12(%esp)
  85. movl %edx, 68(%esp)
  86. movl %edx, 40(%esp)
  87. movl %esi, 44(%esp)
  88. movl %edi, 60(%esp)
  89. movl %ebx, 64(%esp)
  90. je ..B1.5
  91. ..B1.2:
  92. cmpl $2047, 64(%esp)
  93. je ..B1.5
  94. ..B1.3:
  95. movl %eax, %edx
  96. orl %ecx, %edx
  97. je ..B1.5
  98. ..B1.4:
  99. movl 68(%esp), %edx
  100. orl %esi, %edx
  101. jne ..B1.6
  102. ..B1.5:
  103. movl $1, %edi
  104. jmp ..B1.7
  105. ..B1.6:
  106. xorl %edi, %edi
  107. ..B1.7:
  108. fldl 8(%esp)
  109. movl %ecx, %ebx
  110. fldl 40(%esp)
  111. movl %esi, %edx
  112. andl $1048575, %ebx
  113. andl $1048575, %edx
  114. movl %edx, 16(%esp)
  115. testl %edi, %edi
  116. je ..B1.16
  117. ..B1.8:
  118. fstp %st(1)
  119. fstp %st(0)
  120. movl 56(%esp), %edx
  121. movl %ecx, %ebx
  122. movl $0, (%edx)
  123. movl $2146435072, %edx
  124. subl %edx, %ebx
  125. jb ..B1.9
  126. ..B1.86:
  127. orl %eax, %ebx
  128. jne ..B1.10
  129. ..B1.9:
  130. movl %esi, %ebx
  131. subl %edx, %ebx
  132. jb ..B1.11
  133. ..B1.87:
  134. orl 68(%esp), %ebx
  135. je ..B1.11
  136. ..B1.10:
  137. fldl 8(%ebp)
  138. faddl 16(%ebp)
  139. addl $84, %esp
  140. popl %ebx
  141. popl %edi
  142. popl %esi
  143. movl %ebp, %esp
  144. popl %ebp
  145. ret
  146. ..B1.11:
  147. movl 68(%esp), %ebx
  148. orl %esi, %ebx
  149. je ..B1.13
  150. ..B1.12:
  151. subl %edx, %ecx
  152. orl %ecx, %eax
  153. jne ..B1.14
  154. ..B1.13:
  155. fldz
  156. fdiv %st(0), %st
  157. addl $84, %esp
  158. popl %ebx
  159. popl %edi
  160. popl %esi
  161. movl %ebp, %esp
  162. popl %ebp
  163. ret
  164. ..B1.14:
  165. fldl 8(%ebp)
  166. ..B1.15:
  167. addl $84, %esp
  168. popl %ebx
  169. popl %edi
  170. popl %esi
  171. movl %ebp, %esp
  172. popl %ebp
  173. ret
  174. ..B1.16:
  175. movl 68(%esp), %edx
  176. movl %edx, 32(%esp)
  177. movl 60(%esp), %edx
  178. subl 64(%esp), %edx
  179. movl 16(%esp), %edi
  180. cmpl $31, %edx
  181. movl %edi, 36(%esp)
  182. fxch %st(1)
  183. fstpl 24(%esp)
  184. jle ..B1.21
  185. ..B1.17:
  186. cmpl $2016, 64(%esp)
  187. jge ..B1.21
  188. ..B1.18:
  189. movl %eax, 8(%esp)
  190. call ..L3
  191. ..L3:
  192. popl %eax
  193. lea _GLOBAL_OFFSET_TABLE_+[. - ..L3](%eax), %eax
  194. fstl 16(%esp)
  195. movl %ebx, 12(%esp)
  196. fldl .L_2il0floatpacket.0@GOTOFF(%eax)
  197. fmulp %st, %st(1)
  198. fstpl (%esp)
  199. ..B1.19:
  200. fldl (%esp)
  201. fldl 24(%esp)
  202. .L_2TAG_PACKET_0.0.2:
  203. fprem
  204. fstsw %ax
  205. sahf
  206. jp .L_2TAG_PACKET_0.0.2
  207. fstp %st(1)
  208. fstpl 24(%esp)
  209. ..B1.20:
  210. fldl 16(%esp)
  211. movl 28(%esp), %ecx
  212. movl %ecx, %ebx
  213. andl $2146435072, %ebx
  214. shrl $20, %ebx
  215. movl 40(%esp), %edx
  216. movl %ebx, 60(%esp)
  217. movl %ecx, %ebx
  218. movl 24(%esp), %eax
  219. andl $1048575, %ebx
  220. movl 44(%esp), %esi
  221. movl %edx, 68(%esp)
  222. ..B1.21:
  223. movl %eax, %edi
  224. movl %ecx, %edx
  225. subl 68(%esp), %edi
  226. sbbl %esi, %edx
  227. movl %edx, 16(%esp)
  228. jb ..B1.22
  229. ..B1.88:
  230. orl 16(%esp), %edi
  231. jne ..B1.34
  232. ..B1.22:
  233. subl 68(%esp), %eax
  234. subl %esi, %ecx
  235. orl %ecx, %eax
  236. je ..B1.33
  237. ..B1.23:
  238. fldl 24(%esp)
  239. cmpl $2046, 60(%esp)
  240. je ..B1.29
  241. ..B1.24:
  242. fld %st(0)
  243. fadd %st(1), %st
  244. fcomp %st(2)
  245. fnstsw %ax
  246. sahf
  247. ja ..B1.29
  248. jp ..B1.29
  249. ..B1.25:
  250. fstp %st(1)
  251. movl 56(%esp), %eax
  252. cmpl $0, 48(%esp)
  253. movl $0, (%eax)
  254. je ..B1.28
  255. ..B1.26:
  256. fchs
  257. ..B1.28:
  258. addl $84, %esp
  259. popl %ebx
  260. popl %edi
  261. popl %esi
  262. movl %ebp, %esp
  263. popl %ebp
  264. ret
  265. ..B1.29:
  266. movl 56(%esp), %edx
  267. movl 52(%esp), %eax
  268. movl %eax, (%edx)
  269. ..B1.30:
  270. cmpl $0, 48(%esp)
  271. fsubp %st, %st(1)
  272. je ..B1.32
  273. ..B1.31:
  274. fchs
  275. ..B1.32:
  276. addl $84, %esp
  277. popl %ebx
  278. popl %edi
  279. popl %esi
  280. movl %ebp, %esp
  281. popl %ebp
  282. ret
  283. ..B1.33:
  284. fstp %st(0)
  285. fldz
  286. fmull 8(%ebp)
  287. movl 56(%esp), %edx
  288. movl 52(%esp), %eax
  289. movl %eax, (%edx)
  290. addl $84, %esp
  291. popl %ebx
  292. popl %edi
  293. popl %esi
  294. movl %ebp, %esp
  295. popl %ebp
  296. ret
  297. ..B1.34:
  298. cmpl $0, 60(%esp)
  299. jne ..B1.43
  300. ..B1.35:
  301. movl %eax, %edx
  302. orl %ebx, %edx
  303. je ..B1.43
  304. ..B1.36:
  305. movl %eax, 8(%esp)
  306. testl %ebx, %ebx
  307. movl %ebx, 12(%esp)
  308. je ..B1.38
  309. ..B1.37:
  310. bsr %ebx, %edx
  311. negl %edx
  312. addl $20, %edx
  313. movl %edx, 60(%esp)
  314. jmp ..B1.39
  315. ..B1.38:
  316. bsr 8(%esp), %edx
  317. negl %edx
  318. addl $52, %edx
  319. movl %edx, 60(%esp)
  320. ..B1.39:
  321. cmpl $31, 60(%esp)
  322. jbe ..B1.41
  323. ..B1.40:
  324. movl %eax, %ebx
  325. xorl %esi, %esi
  326. movl %edx, %ecx
  327. shll %cl, %ebx
  328. ..B1.42:
  329. movl %edx, %eax
  330. negl %eax
  331. incl %eax
  332. movl %eax, 60(%esp)
  333. jmp ..B1.44
  334. ..B1.41:
  335. movl %eax, %esi
  336. movl %edx, %ecx
  337. shldl %cl, %eax, %ebx
  338. shll %cl, %esi
  339. jmp ..B1.42
  340. ..B1.43:
  341. movl %eax, %esi
  342. orl $1048576, %ebx
  343. ..B1.44:
  344. movl 36(%esp), %edx
  345. movl 32(%esp), %eax
  346. movl %edx, 20(%esp)
  347. cmpl $0, 64(%esp)
  348. jne ..B1.53
  349. ..B1.45:
  350. movl %eax, %edx
  351. orl 20(%esp), %edx
  352. je ..B1.53
  353. ..B1.46:
  354. cmpl $0, 20(%esp)
  355. je ..B1.48
  356. ..B1.47:
  357. bsr 20(%esp), %edx
  358. negl %edx
  359. addl $20, %edx
  360. movl %edx, 64(%esp)
  361. jmp ..B1.49
  362. ..B1.48:
  363. bsr 32(%esp), %edx
  364. negl %edx
  365. addl $52, %edx
  366. movl %edx, 64(%esp)
  367. ..B1.49:
  368. cmpl $31, 64(%esp)
  369. jbe ..B1.51
  370. ..B1.50:
  371. movl %edx, %ecx
  372. shll %cl, %eax
  373. movl $0, 16(%esp)
  374. movl %eax, 20(%esp)
  375. ..B1.52:
  376. movl %ecx, %eax
  377. negl %eax
  378. incl %eax
  379. movl %eax, 64(%esp)
  380. jmp ..B1.54
  381. ..B1.51:
  382. movl %edx, %ecx
  383. movl 20(%esp), %edx
  384. shldl %cl, %eax, %edx
  385. shll %cl, %eax
  386. movl %edx, 20(%esp)
  387. movl %eax, 16(%esp)
  388. jmp ..B1.52
  389. ..B1.53:
  390. movl %eax, 16(%esp)
  391. orl $1048576, 20(%esp)
  392. ..B1.54:
  393. movl 60(%esp), %eax
  394. xorl %edx, %edx
  395. subl 64(%esp), %eax
  396. xorl %ecx, %ecx
  397. movl %eax, 60(%esp)
  398. cmpl $-1, %eax
  399. je ..B1.60
  400. ..B1.56:
  401. movl %edx, %edi
  402. addl %ecx, %ecx
  403. shrl $31, %edi
  404. addl %edx, %edx
  405. orl %edi, %ecx
  406. movl %esi, %edi
  407. subl 16(%esp), %edi
  408. movl %ebx, %edi
  409. sbbl 20(%esp), %edi
  410. jb ..B1.58
  411. ..B1.57:
  412. subl 16(%esp), %esi
  413. sbbl 20(%esp), %ebx
  414. addl $1, %edx
  415. adcl $0, %ecx
  416. ..B1.58:
  417. movl %esi, %edi
  418. addl %ebx, %ebx
  419. shrl $31, %edi
  420. decl %eax
  421. addl %esi, %esi
  422. orl %edi, %ebx
  423. cmpl $-1, %eax
  424. jne ..B1.56
  425. ..B1.60:
  426. movl %esi, %eax
  427. orl %ebx, %eax
  428. je ..B1.83
  429. ..B1.61:
  430. movl %ebx, %eax
  431. shll $31, %eax
  432. shrl $1, %esi
  433. shrl $1, %ebx
  434. orl %esi, %eax
  435. testl %ebx, %ebx
  436. movl %eax, 8(%esp)
  437. movl %ebx, 12(%esp)
  438. je ..B1.63
  439. ..B1.62:
  440. bsr %ebx, %ecx
  441. negl %ecx
  442. addl $20, %ecx
  443. jmp ..B1.64
  444. ..B1.63:
  445. bsr 8(%esp), %ecx
  446. negl %ecx
  447. addl $52, %ecx
  448. ..B1.64:
  449. cmpl $31, %ecx
  450. jbe ..B1.66
  451. ..B1.65:
  452. movl %eax, %ebx
  453. xorl %eax, %eax
  454. shll %cl, %ebx
  455. jmp ..B1.67
  456. ..B1.66:
  457. shldl %cl, %eax, %ebx
  458. shll %cl, %eax
  459. ..B1.67:
  460. movl 64(%esp), %esi
  461. subl %ecx, %esi
  462. movl %esi, 64(%esp)
  463. testl %esi, %esi
  464. jle ..B1.69
  465. ..B1.68:
  466. movl %ebx, %esi
  467. andl $1048575, %esi
  468. jmp ..B1.73
  469. ..B1.69:
  470. movl %esi, %ecx
  471. negl %ecx
  472. incl %ecx
  473. movl %ecx, 64(%esp)
  474. cmpl $31, %ecx
  475. jbe ..B1.71
  476. ..B1.70:
  477. movl %ebx, %eax
  478. xorl %esi, %esi
  479. shrl %cl, %eax
  480. jmp ..B1.72
  481. ..B1.71:
  482. movl %ebx, %esi
  483. shrdl %cl, %ebx, %eax
  484. shrl %cl, %esi
  485. ..B1.72:
  486. movl $0, 64(%esp)
  487. ..B1.73:
  488. movl 64(%esp), %ecx
  489. shll $20, %ecx
  490. orl %ecx, %esi
  491. movl %eax, 8(%esp)
  492. movl %esi, 12(%esp)
  493. fldl 8(%esp)
  494. fld %st(0)
  495. fadd %st(1), %st
  496. fcom %st(2)
  497. fnstsw %ax
  498. sahf
  499. jb ..B1.89
  500. ..B1.74:
  501. fucomp %st(2)
  502. fnstsw %ax
  503. sahf
  504. jp ..B1.75
  505. je ..B1.81
  506. ..B1.75:
  507. incl %edx
  508. fsubp %st, %st(1)
  509. jmp ..B1.76
  510. ..B1.89:
  511. fstp %st(2)
  512. fstp %st(1)
  513. ..B1.76:
  514. andl $2147483647, %edx
  515. movl 52(%esp), %eax
  516. imull %edx, %eax
  517. movl 56(%esp), %edx
  518. cmpl $0, 48(%esp)
  519. movl %eax, (%edx)
  520. je ..B1.78
  521. ..B1.77:
  522. fchs
  523. ..B1.78:
  524. addl $84, %esp
  525. popl %ebx
  526. popl %edi
  527. popl %esi
  528. movl %ebp, %esp
  529. popl %ebp
  530. ret
  531. ..B1.81:
  532. fstp %st(1)
  533. movl %edx, %ecx
  534. xorl %eax, %eax
  535. andl $1, %ecx
  536. orl %eax, %ecx
  537. je ..B1.76
  538. ..B1.82:
  539. fchs
  540. incl %edx
  541. jmp ..B1.76
  542. ..B1.83:
  543. fstp %st(0)
  544. fldz
  545. andl $2147483647, %edx
  546. fmull 8(%ebp)
  547. movl 52(%esp), %eax
  548. imull %edx, %eax
  549. movl 56(%esp), %edx
  550. movl %eax, (%edx)
  551. addl $84, %esp
  552. popl %ebx
  553. popl %edi
  554. popl %esi
  555. movl %ebp, %esp
  556. popl %ebp
  557. ret
  558. .align 16,0x90
  559. .type remquo,@function
  560. .size remquo,.-remquo
  561. .data
  562. # -- End remquo
  563. .section .rodata, "a"
  564. .align 8
  565. .align 8
  566. .L_2il0floatpacket.0:
  567. .long 0x00000000,0xc1e00000
  568. .type .L_2il0floatpacket.0,@object
  569. .size .L_2il0floatpacket.0,8
  570. .data
  571. .section .note.GNU-stack, ""
  572. # End