udiv_qrnnd.S 6.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286
  1. ;! HP-PA __udiv_qrnnd division support, used from longlong.h.
  2. ;! This version runs fast on pre-PA7000 CPUs.
  3. ;! Copyright (C) 1993, 1994 Free Software Foundation, Inc.
  4. ;! This file is part of the GNU MP Library.
  5. ;! The GNU MP Library is free software; you can redistribute it and/or modify
  6. ;! it under the terms of the GNU Lesser General Public License as published by
  7. ;! the Free Software Foundation; either version 2.1 of the License, or (at your
  8. ;! option) any later version.
  9. ;! The GNU MP Library is distributed in the hope that it will be useful, but
  10. ;! WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
  11. ;! or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
  12. ;! License for more details.
  13. ;! You should have received a copy of the GNU Lesser General Public License
  14. ;! along with the GNU MP Library; see the file COPYING.LIB. If not, write to
  15. ;! the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston,
  16. ;! MA 02111-1307, USA.
  17. ;! INPUT PARAMETERS
  18. ;! rem_ptr gr26
  19. ;! n1 gr25
  20. ;! n0 gr24
  21. ;! d gr23
  22. ;! The code size is a bit excessive. We could merge the last two ds;addc
  23. ;! sequences by simply moving the "bb,< Odd" instruction down. The only
  24. ;! trouble is the FFFFFFFF code that would need some hacking.
  25. .text
  26. .export __udiv_qrnnd
  27. __udiv_qrnnd:
  28. .proc
  29. .callinfo frame=0,no_calls
  30. .entry
  31. comb,< %r23,%r0,L$largedivisor
  32. sub %r0,%r23,%r1 ;! clear cy as side-effect
  33. ds %r0,%r1,%r0
  34. addc %r24,%r24,%r24
  35. ds %r25,%r23,%r25
  36. addc %r24,%r24,%r24
  37. ds %r25,%r23,%r25
  38. addc %r24,%r24,%r24
  39. ds %r25,%r23,%r25
  40. addc %r24,%r24,%r24
  41. ds %r25,%r23,%r25
  42. addc %r24,%r24,%r24
  43. ds %r25,%r23,%r25
  44. addc %r24,%r24,%r24
  45. ds %r25,%r23,%r25
  46. addc %r24,%r24,%r24
  47. ds %r25,%r23,%r25
  48. addc %r24,%r24,%r24
  49. ds %r25,%r23,%r25
  50. addc %r24,%r24,%r24
  51. ds %r25,%r23,%r25
  52. addc %r24,%r24,%r24
  53. ds %r25,%r23,%r25
  54. addc %r24,%r24,%r24
  55. ds %r25,%r23,%r25
  56. addc %r24,%r24,%r24
  57. ds %r25,%r23,%r25
  58. addc %r24,%r24,%r24
  59. ds %r25,%r23,%r25
  60. addc %r24,%r24,%r24
  61. ds %r25,%r23,%r25
  62. addc %r24,%r24,%r24
  63. ds %r25,%r23,%r25
  64. addc %r24,%r24,%r24
  65. ds %r25,%r23,%r25
  66. addc %r24,%r24,%r24
  67. ds %r25,%r23,%r25
  68. addc %r24,%r24,%r24
  69. ds %r25,%r23,%r25
  70. addc %r24,%r24,%r24
  71. ds %r25,%r23,%r25
  72. addc %r24,%r24,%r24
  73. ds %r25,%r23,%r25
  74. addc %r24,%r24,%r24
  75. ds %r25,%r23,%r25
  76. addc %r24,%r24,%r24
  77. ds %r25,%r23,%r25
  78. addc %r24,%r24,%r24
  79. ds %r25,%r23,%r25
  80. addc %r24,%r24,%r24
  81. ds %r25,%r23,%r25
  82. addc %r24,%r24,%r24
  83. ds %r25,%r23,%r25
  84. addc %r24,%r24,%r24
  85. ds %r25,%r23,%r25
  86. addc %r24,%r24,%r24
  87. ds %r25,%r23,%r25
  88. addc %r24,%r24,%r24
  89. ds %r25,%r23,%r25
  90. addc %r24,%r24,%r24
  91. ds %r25,%r23,%r25
  92. addc %r24,%r24,%r24
  93. ds %r25,%r23,%r25
  94. addc %r24,%r24,%r24
  95. ds %r25,%r23,%r25
  96. addc %r24,%r24,%r28
  97. ds %r25,%r23,%r25
  98. comclr,>= %r25,%r0,%r0
  99. addl %r25,%r23,%r25
  100. stws %r25,0(%r26)
  101. bv 0(%r2)
  102. addc %r28,%r28,%r28
  103. L$largedivisor:
  104. extru %r24,31,1,%r20 ;! r20 = n0 & 1
  105. bb,< %r23,31,L$odd
  106. extru %r23,30,31,%r22 ;! r22 = d >> 1
  107. shd %r25,%r24,1,%r24 ;! r24 = new n0
  108. extru %r25,30,31,%r25 ;! r25 = new n1
  109. sub %r0,%r22,%r21
  110. ds %r0,%r21,%r0
  111. addc %r24,%r24,%r24
  112. ds %r25,%r22,%r25
  113. addc %r24,%r24,%r24
  114. ds %r25,%r22,%r25
  115. addc %r24,%r24,%r24
  116. ds %r25,%r22,%r25
  117. addc %r24,%r24,%r24
  118. ds %r25,%r22,%r25
  119. addc %r24,%r24,%r24
  120. ds %r25,%r22,%r25
  121. addc %r24,%r24,%r24
  122. ds %r25,%r22,%r25
  123. addc %r24,%r24,%r24
  124. ds %r25,%r22,%r25
  125. addc %r24,%r24,%r24
  126. ds %r25,%r22,%r25
  127. addc %r24,%r24,%r24
  128. ds %r25,%r22,%r25
  129. addc %r24,%r24,%r24
  130. ds %r25,%r22,%r25
  131. addc %r24,%r24,%r24
  132. ds %r25,%r22,%r25
  133. addc %r24,%r24,%r24
  134. ds %r25,%r22,%r25
  135. addc %r24,%r24,%r24
  136. ds %r25,%r22,%r25
  137. addc %r24,%r24,%r24
  138. ds %r25,%r22,%r25
  139. addc %r24,%r24,%r24
  140. ds %r25,%r22,%r25
  141. addc %r24,%r24,%r24
  142. ds %r25,%r22,%r25
  143. addc %r24,%r24,%r24
  144. ds %r25,%r22,%r25
  145. addc %r24,%r24,%r24
  146. ds %r25,%r22,%r25
  147. addc %r24,%r24,%r24
  148. ds %r25,%r22,%r25
  149. addc %r24,%r24,%r24
  150. ds %r25,%r22,%r25
  151. addc %r24,%r24,%r24
  152. ds %r25,%r22,%r25
  153. addc %r24,%r24,%r24
  154. ds %r25,%r22,%r25
  155. addc %r24,%r24,%r24
  156. ds %r25,%r22,%r25
  157. addc %r24,%r24,%r24
  158. ds %r25,%r22,%r25
  159. addc %r24,%r24,%r24
  160. ds %r25,%r22,%r25
  161. addc %r24,%r24,%r24
  162. ds %r25,%r22,%r25
  163. addc %r24,%r24,%r24
  164. ds %r25,%r22,%r25
  165. addc %r24,%r24,%r24
  166. ds %r25,%r22,%r25
  167. addc %r24,%r24,%r24
  168. ds %r25,%r22,%r25
  169. addc %r24,%r24,%r24
  170. ds %r25,%r22,%r25
  171. addc %r24,%r24,%r24
  172. ds %r25,%r22,%r25
  173. addc %r24,%r24,%r24
  174. ds %r25,%r22,%r25
  175. comclr,>= %r25,%r0,%r0
  176. addl %r25,%r22,%r25
  177. sh1addl %r25,%r20,%r25
  178. stws %r25,0(%r26)
  179. bv 0(%r2)
  180. addc %r24,%r24,%r28
  181. L$odd: addib,sv,n 1,%r22,L$FF.. ;! r22 = (d / 2 + 1)
  182. shd %r25,%r24,1,%r24 ;! r24 = new n0
  183. extru %r25,30,31,%r25 ;! r25 = new n1
  184. sub %r0,%r22,%r21
  185. ds %r0,%r21,%r0
  186. addc %r24,%r24,%r24
  187. ds %r25,%r22,%r25
  188. addc %r24,%r24,%r24
  189. ds %r25,%r22,%r25
  190. addc %r24,%r24,%r24
  191. ds %r25,%r22,%r25
  192. addc %r24,%r24,%r24
  193. ds %r25,%r22,%r25
  194. addc %r24,%r24,%r24
  195. ds %r25,%r22,%r25
  196. addc %r24,%r24,%r24
  197. ds %r25,%r22,%r25
  198. addc %r24,%r24,%r24
  199. ds %r25,%r22,%r25
  200. addc %r24,%r24,%r24
  201. ds %r25,%r22,%r25
  202. addc %r24,%r24,%r24
  203. ds %r25,%r22,%r25
  204. addc %r24,%r24,%r24
  205. ds %r25,%r22,%r25
  206. addc %r24,%r24,%r24
  207. ds %r25,%r22,%r25
  208. addc %r24,%r24,%r24
  209. ds %r25,%r22,%r25
  210. addc %r24,%r24,%r24
  211. ds %r25,%r22,%r25
  212. addc %r24,%r24,%r24
  213. ds %r25,%r22,%r25
  214. addc %r24,%r24,%r24
  215. ds %r25,%r22,%r25
  216. addc %r24,%r24,%r24
  217. ds %r25,%r22,%r25
  218. addc %r24,%r24,%r24
  219. ds %r25,%r22,%r25
  220. addc %r24,%r24,%r24
  221. ds %r25,%r22,%r25
  222. addc %r24,%r24,%r24
  223. ds %r25,%r22,%r25
  224. addc %r24,%r24,%r24
  225. ds %r25,%r22,%r25
  226. addc %r24,%r24,%r24
  227. ds %r25,%r22,%r25
  228. addc %r24,%r24,%r24
  229. ds %r25,%r22,%r25
  230. addc %r24,%r24,%r24
  231. ds %r25,%r22,%r25
  232. addc %r24,%r24,%r24
  233. ds %r25,%r22,%r25
  234. addc %r24,%r24,%r24
  235. ds %r25,%r22,%r25
  236. addc %r24,%r24,%r24
  237. ds %r25,%r22,%r25
  238. addc %r24,%r24,%r24
  239. ds %r25,%r22,%r25
  240. addc %r24,%r24,%r24
  241. ds %r25,%r22,%r25
  242. addc %r24,%r24,%r24
  243. ds %r25,%r22,%r25
  244. addc %r24,%r24,%r24
  245. ds %r25,%r22,%r25
  246. addc %r24,%r24,%r24
  247. ds %r25,%r22,%r25
  248. addc %r24,%r24,%r24
  249. ds %r25,%r22,%r25
  250. addc %r24,%r24,%r28
  251. comclr,>= %r25,%r0,%r0
  252. addl %r25,%r22,%r25
  253. sh1addl %r25,%r20,%r25
  254. ;! We have computed (n1,,n0) / (d + 1), q' = r28, r' = r25
  255. add,nuv %r28,%r25,%r25
  256. addl %r25,%r1,%r25
  257. addc %r0,%r28,%r28
  258. sub,<< %r25,%r23,%r0
  259. addl %r25,%r1,%r25
  260. stws %r25,0(%r26)
  261. bv 0(%r2)
  262. addc %r0,%r28,%r28
  263. ;! This is just a special case of the code above.
  264. ;! We come here when d == 0xFFFFFFFF
  265. L$FF..: add,uv %r25,%r24,%r24
  266. sub,<< %r24,%r23,%r0
  267. ldo 1(%r24),%r24
  268. stws %r24,0(%r26)
  269. bv 0(%r2)
  270. addc %r0,%r25,%r28
  271. .exit
  272. .procend