udiv-qrnnd.S 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165
  1. # Alpha 21064 __udiv_qrnnd
  2. # Copyright (C) 1992, 1994, 1995, 2000 Free Software Foundation, Inc.
  3. # This file is part of GCC.
  4. # The GNU MP Library is free software; you can redistribute it and/or modify
  5. # it under the terms of the GNU General Public License as published by
  6. # the Free Software Foundation; either version 2 of the License, or (at your
  7. # option) any later version.
  8. # In addition to the permissions in the GNU General Public License, the
  9. # Free Software Foundation gives you unlimited permission to link the
  10. # compiled version of this file with other programs, and to distribute
  11. # those programs without any restriction coming from the use of this
  12. # file. (The General Public License restrictions do apply in other
  13. # respects; for example, they cover modification of the file, and
  14. # distribution when not linked into another program.)
  15. # This file is distributed in the hope that it will be useful, but
  16. # WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
  17. # or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library General Public
  18. # License for more details.
  19. # You should have received a copy of the GNU General Public License
  20. # along with GCC; see the file COPYING. If not, write to the
  21. # Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston,
  22. # MA 02111-1307, USA.
  23. #include <asm/export.h>
  24. .set noreorder
  25. .set noat
  26. .text
  27. .globl __udiv_qrnnd
  28. .ent __udiv_qrnnd
  29. __udiv_qrnnd:
  30. .frame $30,0,$26,0
  31. .prologue 0
  32. #define cnt $2
  33. #define tmp $3
  34. #define rem_ptr $16
  35. #define n1 $17
  36. #define n0 $18
  37. #define d $19
  38. #define qb $20
  39. #define AT $at
  40. ldiq cnt,16
  41. blt d,$largedivisor
  42. $loop1: cmplt n0,0,tmp
  43. addq n1,n1,n1
  44. bis n1,tmp,n1
  45. addq n0,n0,n0
  46. cmpule d,n1,qb
  47. subq n1,d,tmp
  48. cmovne qb,tmp,n1
  49. bis n0,qb,n0
  50. cmplt n0,0,tmp
  51. addq n1,n1,n1
  52. bis n1,tmp,n1
  53. addq n0,n0,n0
  54. cmpule d,n1,qb
  55. subq n1,d,tmp
  56. cmovne qb,tmp,n1
  57. bis n0,qb,n0
  58. cmplt n0,0,tmp
  59. addq n1,n1,n1
  60. bis n1,tmp,n1
  61. addq n0,n0,n0
  62. cmpule d,n1,qb
  63. subq n1,d,tmp
  64. cmovne qb,tmp,n1
  65. bis n0,qb,n0
  66. cmplt n0,0,tmp
  67. addq n1,n1,n1
  68. bis n1,tmp,n1
  69. addq n0,n0,n0
  70. cmpule d,n1,qb
  71. subq n1,d,tmp
  72. cmovne qb,tmp,n1
  73. bis n0,qb,n0
  74. subq cnt,1,cnt
  75. bgt cnt,$loop1
  76. stq n1,0(rem_ptr)
  77. bis $31,n0,$0
  78. ret $31,($26),1
  79. $largedivisor:
  80. and n0,1,$4
  81. srl n0,1,n0
  82. sll n1,63,tmp
  83. or tmp,n0,n0
  84. srl n1,1,n1
  85. and d,1,$6
  86. srl d,1,$5
  87. addq $5,$6,$5
  88. $loop2: cmplt n0,0,tmp
  89. addq n1,n1,n1
  90. bis n1,tmp,n1
  91. addq n0,n0,n0
  92. cmpule $5,n1,qb
  93. subq n1,$5,tmp
  94. cmovne qb,tmp,n1
  95. bis n0,qb,n0
  96. cmplt n0,0,tmp
  97. addq n1,n1,n1
  98. bis n1,tmp,n1
  99. addq n0,n0,n0
  100. cmpule $5,n1,qb
  101. subq n1,$5,tmp
  102. cmovne qb,tmp,n1
  103. bis n0,qb,n0
  104. cmplt n0,0,tmp
  105. addq n1,n1,n1
  106. bis n1,tmp,n1
  107. addq n0,n0,n0
  108. cmpule $5,n1,qb
  109. subq n1,$5,tmp
  110. cmovne qb,tmp,n1
  111. bis n0,qb,n0
  112. cmplt n0,0,tmp
  113. addq n1,n1,n1
  114. bis n1,tmp,n1
  115. addq n0,n0,n0
  116. cmpule $5,n1,qb
  117. subq n1,$5,tmp
  118. cmovne qb,tmp,n1
  119. bis n0,qb,n0
  120. subq cnt,1,cnt
  121. bgt cnt,$loop2
  122. addq n1,n1,n1
  123. addq $4,n1,n1
  124. bne $6,$Odd
  125. stq n1,0(rem_ptr)
  126. bis $31,n0,$0
  127. ret $31,($26),1
  128. $Odd:
  129. /* q' in n0. r' in n1 */
  130. addq n1,n0,n1
  131. cmpult n1,n0,tmp # tmp := carry from addq
  132. subq n1,d,AT
  133. addq n0,tmp,n0
  134. cmovne tmp,AT,n1
  135. cmpult n1,d,tmp
  136. addq n0,1,AT
  137. cmoveq tmp,AT,n0
  138. subq n1,d,AT
  139. cmoveq tmp,AT,n1
  140. stq n1,0(rem_ptr)
  141. bis $31,n0,$0
  142. ret $31,($26),1
  143. .end __udiv_qrnnd
  144. EXPORT_SYMBOL(__udiv_qrnnd)