qrnnd.S 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164
  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. .set noreorder
  24. .set noat
  25. .text
  26. .globl __udiv_qrnnd
  27. .ent __udiv_qrnnd
  28. __udiv_qrnnd:
  29. .frame $30,0,$26,0
  30. .prologue 0
  31. #define cnt $2
  32. #define tmp $3
  33. #define rem_ptr $16
  34. #define n1 $17
  35. #define n0 $18
  36. #define d $19
  37. #define qb $20
  38. #define AT $at
  39. ldiq cnt,16
  40. blt d,$largedivisor
  41. $loop1: cmplt n0,0,tmp
  42. addq n1,n1,n1
  43. bis n1,tmp,n1
  44. addq n0,n0,n0
  45. cmpule d,n1,qb
  46. subq n1,d,tmp
  47. cmovne qb,tmp,n1
  48. bis n0,qb,n0
  49. cmplt n0,0,tmp
  50. addq n1,n1,n1
  51. bis n1,tmp,n1
  52. addq n0,n0,n0
  53. cmpule d,n1,qb
  54. subq n1,d,tmp
  55. cmovne qb,tmp,n1
  56. bis n0,qb,n0
  57. cmplt n0,0,tmp
  58. addq n1,n1,n1
  59. bis n1,tmp,n1
  60. addq n0,n0,n0
  61. cmpule d,n1,qb
  62. subq n1,d,tmp
  63. cmovne qb,tmp,n1
  64. bis n0,qb,n0
  65. cmplt n0,0,tmp
  66. addq n1,n1,n1
  67. bis n1,tmp,n1
  68. addq n0,n0,n0
  69. cmpule d,n1,qb
  70. subq n1,d,tmp
  71. cmovne qb,tmp,n1
  72. bis n0,qb,n0
  73. subq cnt,1,cnt
  74. bgt cnt,$loop1
  75. stq n1,0(rem_ptr)
  76. bis $31,n0,$0
  77. ret $31,($26),1
  78. $largedivisor:
  79. and n0,1,$4
  80. srl n0,1,n0
  81. sll n1,63,tmp
  82. or tmp,n0,n0
  83. srl n1,1,n1
  84. and d,1,$6
  85. srl d,1,$5
  86. addq $5,$6,$5
  87. $loop2: cmplt n0,0,tmp
  88. addq n1,n1,n1
  89. bis n1,tmp,n1
  90. addq n0,n0,n0
  91. cmpule $5,n1,qb
  92. subq n1,$5,tmp
  93. cmovne qb,tmp,n1
  94. bis n0,qb,n0
  95. cmplt n0,0,tmp
  96. addq n1,n1,n1
  97. bis n1,tmp,n1
  98. addq n0,n0,n0
  99. cmpule $5,n1,qb
  100. subq n1,$5,tmp
  101. cmovne qb,tmp,n1
  102. bis n0,qb,n0
  103. cmplt n0,0,tmp
  104. addq n1,n1,n1
  105. bis n1,tmp,n1
  106. addq n0,n0,n0
  107. cmpule $5,n1,qb
  108. subq n1,$5,tmp
  109. cmovne qb,tmp,n1
  110. bis n0,qb,n0
  111. cmplt n0,0,tmp
  112. addq n1,n1,n1
  113. bis n1,tmp,n1
  114. addq n0,n0,n0
  115. cmpule $5,n1,qb
  116. subq n1,$5,tmp
  117. cmovne qb,tmp,n1
  118. bis n0,qb,n0
  119. subq cnt,1,cnt
  120. bgt cnt,$loop2
  121. addq n1,n1,n1
  122. addq $4,n1,n1
  123. bne $6,$Odd
  124. stq n1,0(rem_ptr)
  125. bis $31,n0,$0
  126. ret $31,($26),1
  127. $Odd:
  128. /* q' in n0. r' in n1 */
  129. addq n1,n0,n1
  130. cmpult n1,n0,tmp # tmp := carry from addq
  131. subq n1,d,AT
  132. addq n0,tmp,n0
  133. cmovne tmp,AT,n1
  134. cmpult n1,d,tmp
  135. addq n0,1,AT
  136. cmoveq tmp,AT,n0
  137. subq n1,d,AT
  138. cmoveq tmp,AT,n1
  139. stq n1,0(rem_ptr)
  140. bis $31,n0,$0
  141. ret $31,($26),1
  142. .end __udiv_qrnnd