udiv_qrnnd.s 6.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285
  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, see
  15. ;! <http://www.gnu.org/licenses/>.
  16. ;! INPUT PARAMETERS
  17. ;! rem_ptr gr26
  18. ;! n1 gr25
  19. ;! n0 gr24
  20. ;! d gr23
  21. ;! The code size is a bit excessive. We could merge the last two ds;addc
  22. ;! sequences by simply moving the "bb,< Odd" instruction down. The only
  23. ;! trouble is the FFFFFFFF code that would need some hacking.
  24. .text
  25. .export __udiv_qrnnd
  26. __udiv_qrnnd:
  27. .proc
  28. .callinfo frame=0,no_calls
  29. .entry
  30. comb,< %r23,%r0,L$largedivisor
  31. sub %r0,%r23,%r1 ;! clear cy as side-effect
  32. ds %r0,%r1,%r0
  33. addc %r24,%r24,%r24
  34. ds %r25,%r23,%r25
  35. addc %r24,%r24,%r24
  36. ds %r25,%r23,%r25
  37. addc %r24,%r24,%r24
  38. ds %r25,%r23,%r25
  39. addc %r24,%r24,%r24
  40. ds %r25,%r23,%r25
  41. addc %r24,%r24,%r24
  42. ds %r25,%r23,%r25
  43. addc %r24,%r24,%r24
  44. ds %r25,%r23,%r25
  45. addc %r24,%r24,%r24
  46. ds %r25,%r23,%r25
  47. addc %r24,%r24,%r24
  48. ds %r25,%r23,%r25
  49. addc %r24,%r24,%r24
  50. ds %r25,%r23,%r25
  51. addc %r24,%r24,%r24
  52. ds %r25,%r23,%r25
  53. addc %r24,%r24,%r24
  54. ds %r25,%r23,%r25
  55. addc %r24,%r24,%r24
  56. ds %r25,%r23,%r25
  57. addc %r24,%r24,%r24
  58. ds %r25,%r23,%r25
  59. addc %r24,%r24,%r24
  60. ds %r25,%r23,%r25
  61. addc %r24,%r24,%r24
  62. ds %r25,%r23,%r25
  63. addc %r24,%r24,%r24
  64. ds %r25,%r23,%r25
  65. addc %r24,%r24,%r24
  66. ds %r25,%r23,%r25
  67. addc %r24,%r24,%r24
  68. ds %r25,%r23,%r25
  69. addc %r24,%r24,%r24
  70. ds %r25,%r23,%r25
  71. addc %r24,%r24,%r24
  72. ds %r25,%r23,%r25
  73. addc %r24,%r24,%r24
  74. ds %r25,%r23,%r25
  75. addc %r24,%r24,%r24
  76. ds %r25,%r23,%r25
  77. addc %r24,%r24,%r24
  78. ds %r25,%r23,%r25
  79. addc %r24,%r24,%r24
  80. ds %r25,%r23,%r25
  81. addc %r24,%r24,%r24
  82. ds %r25,%r23,%r25
  83. addc %r24,%r24,%r24
  84. ds %r25,%r23,%r25
  85. addc %r24,%r24,%r24
  86. ds %r25,%r23,%r25
  87. addc %r24,%r24,%r24
  88. ds %r25,%r23,%r25
  89. addc %r24,%r24,%r24
  90. ds %r25,%r23,%r25
  91. addc %r24,%r24,%r24
  92. ds %r25,%r23,%r25
  93. addc %r24,%r24,%r24
  94. ds %r25,%r23,%r25
  95. addc %r24,%r24,%r28
  96. ds %r25,%r23,%r25
  97. comclr,>= %r25,%r0,%r0
  98. addl %r25,%r23,%r25
  99. stws %r25,0(%r26)
  100. bv 0(%r2)
  101. addc %r28,%r28,%r28
  102. L$largedivisor:
  103. extru %r24,31,1,%r20 ;! r20 = n0 & 1
  104. bb,< %r23,31,L$odd
  105. extru %r23,30,31,%r22 ;! r22 = d >> 1
  106. shd %r25,%r24,1,%r24 ;! r24 = new n0
  107. extru %r25,30,31,%r25 ;! r25 = new n1
  108. sub %r0,%r22,%r21
  109. ds %r0,%r21,%r0
  110. addc %r24,%r24,%r24
  111. ds %r25,%r22,%r25
  112. addc %r24,%r24,%r24
  113. ds %r25,%r22,%r25
  114. addc %r24,%r24,%r24
  115. ds %r25,%r22,%r25
  116. addc %r24,%r24,%r24
  117. ds %r25,%r22,%r25
  118. addc %r24,%r24,%r24
  119. ds %r25,%r22,%r25
  120. addc %r24,%r24,%r24
  121. ds %r25,%r22,%r25
  122. addc %r24,%r24,%r24
  123. ds %r25,%r22,%r25
  124. addc %r24,%r24,%r24
  125. ds %r25,%r22,%r25
  126. addc %r24,%r24,%r24
  127. ds %r25,%r22,%r25
  128. addc %r24,%r24,%r24
  129. ds %r25,%r22,%r25
  130. addc %r24,%r24,%r24
  131. ds %r25,%r22,%r25
  132. addc %r24,%r24,%r24
  133. ds %r25,%r22,%r25
  134. addc %r24,%r24,%r24
  135. ds %r25,%r22,%r25
  136. addc %r24,%r24,%r24
  137. ds %r25,%r22,%r25
  138. addc %r24,%r24,%r24
  139. ds %r25,%r22,%r25
  140. addc %r24,%r24,%r24
  141. ds %r25,%r22,%r25
  142. addc %r24,%r24,%r24
  143. ds %r25,%r22,%r25
  144. addc %r24,%r24,%r24
  145. ds %r25,%r22,%r25
  146. addc %r24,%r24,%r24
  147. ds %r25,%r22,%r25
  148. addc %r24,%r24,%r24
  149. ds %r25,%r22,%r25
  150. addc %r24,%r24,%r24
  151. ds %r25,%r22,%r25
  152. addc %r24,%r24,%r24
  153. ds %r25,%r22,%r25
  154. addc %r24,%r24,%r24
  155. ds %r25,%r22,%r25
  156. addc %r24,%r24,%r24
  157. ds %r25,%r22,%r25
  158. addc %r24,%r24,%r24
  159. ds %r25,%r22,%r25
  160. addc %r24,%r24,%r24
  161. ds %r25,%r22,%r25
  162. addc %r24,%r24,%r24
  163. ds %r25,%r22,%r25
  164. addc %r24,%r24,%r24
  165. ds %r25,%r22,%r25
  166. addc %r24,%r24,%r24
  167. ds %r25,%r22,%r25
  168. addc %r24,%r24,%r24
  169. ds %r25,%r22,%r25
  170. addc %r24,%r24,%r24
  171. ds %r25,%r22,%r25
  172. addc %r24,%r24,%r24
  173. ds %r25,%r22,%r25
  174. comclr,>= %r25,%r0,%r0
  175. addl %r25,%r22,%r25
  176. sh1addl %r25,%r20,%r25
  177. stws %r25,0(%r26)
  178. bv 0(%r2)
  179. addc %r24,%r24,%r28
  180. L$odd: addib,sv,n 1,%r22,L$FF.. ;! r22 = (d / 2 + 1)
  181. shd %r25,%r24,1,%r24 ;! r24 = new n0
  182. extru %r25,30,31,%r25 ;! r25 = new n1
  183. sub %r0,%r22,%r21
  184. ds %r0,%r21,%r0
  185. addc %r24,%r24,%r24
  186. ds %r25,%r22,%r25
  187. addc %r24,%r24,%r24
  188. ds %r25,%r22,%r25
  189. addc %r24,%r24,%r24
  190. ds %r25,%r22,%r25
  191. addc %r24,%r24,%r24
  192. ds %r25,%r22,%r25
  193. addc %r24,%r24,%r24
  194. ds %r25,%r22,%r25
  195. addc %r24,%r24,%r24
  196. ds %r25,%r22,%r25
  197. addc %r24,%r24,%r24
  198. ds %r25,%r22,%r25
  199. addc %r24,%r24,%r24
  200. ds %r25,%r22,%r25
  201. addc %r24,%r24,%r24
  202. ds %r25,%r22,%r25
  203. addc %r24,%r24,%r24
  204. ds %r25,%r22,%r25
  205. addc %r24,%r24,%r24
  206. ds %r25,%r22,%r25
  207. addc %r24,%r24,%r24
  208. ds %r25,%r22,%r25
  209. addc %r24,%r24,%r24
  210. ds %r25,%r22,%r25
  211. addc %r24,%r24,%r24
  212. ds %r25,%r22,%r25
  213. addc %r24,%r24,%r24
  214. ds %r25,%r22,%r25
  215. addc %r24,%r24,%r24
  216. ds %r25,%r22,%r25
  217. addc %r24,%r24,%r24
  218. ds %r25,%r22,%r25
  219. addc %r24,%r24,%r24
  220. ds %r25,%r22,%r25
  221. addc %r24,%r24,%r24
  222. ds %r25,%r22,%r25
  223. addc %r24,%r24,%r24
  224. ds %r25,%r22,%r25
  225. addc %r24,%r24,%r24
  226. ds %r25,%r22,%r25
  227. addc %r24,%r24,%r24
  228. ds %r25,%r22,%r25
  229. addc %r24,%r24,%r24
  230. ds %r25,%r22,%r25
  231. addc %r24,%r24,%r24
  232. ds %r25,%r22,%r25
  233. addc %r24,%r24,%r24
  234. ds %r25,%r22,%r25
  235. addc %r24,%r24,%r24
  236. ds %r25,%r22,%r25
  237. addc %r24,%r24,%r24
  238. ds %r25,%r22,%r25
  239. addc %r24,%r24,%r24
  240. ds %r25,%r22,%r25
  241. addc %r24,%r24,%r24
  242. ds %r25,%r22,%r25
  243. addc %r24,%r24,%r24
  244. ds %r25,%r22,%r25
  245. addc %r24,%r24,%r24
  246. ds %r25,%r22,%r25
  247. addc %r24,%r24,%r24
  248. ds %r25,%r22,%r25
  249. addc %r24,%r24,%r28
  250. comclr,>= %r25,%r0,%r0
  251. addl %r25,%r22,%r25
  252. sh1addl %r25,%r20,%r25
  253. ;! We have computed (n1,,n0) / (d + 1), q' = r28, r' = r25
  254. add,nuv %r28,%r25,%r25
  255. addl %r25,%r1,%r25
  256. addc %r0,%r28,%r28
  257. sub,<< %r25,%r23,%r0
  258. addl %r25,%r1,%r25
  259. stws %r25,0(%r26)
  260. bv 0(%r2)
  261. addc %r0,%r28,%r28
  262. ;! This is just a special case of the code above.
  263. ;! We come here when d == 0xFFFFFFFF
  264. L$FF..: add,uv %r25,%r24,%r24
  265. sub,<< %r24,%r23,%r0
  266. ldo 1(%r24),%r24
  267. stws %r24,0(%r26)
  268. bv 0(%r2)
  269. addc %r0,%r25,%r28
  270. .exit
  271. .procend