udiv_qrnnd.S 2.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182
  1. /* Copyright (C) 1994, 1995, 1997, 1998, 1999, 2000, 2001, 2002, 2003,
  2. 2004, 2005, 2006
  3. Free Software Foundation, Inc.
  4. This file is free software; you can redistribute it and/or modify it
  5. under the terms of the GNU General Public License as published by the
  6. Free Software Foundation; either version 2, or (at your option) any
  7. 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 into combinations with other programs,
  11. and to distribute those combinations without any restriction coming
  12. from the use of this file. (The General Public License restrictions
  13. do apply in other respects; for example, they cover modification of
  14. the file, and distribution when not linked into a combine
  15. executable.)
  16. This file is distributed in the hope that it will be useful, but
  17. WITHOUT ANY WARRANTY; without even the implied warranty of
  18. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  19. General Public License for more details.
  20. You should have received a copy of the GNU General Public License
  21. along with this program; see the file COPYING. If not, write to
  22. the Free Software Foundation, 51 Franklin Street, Fifth Floor,
  23. Boston, MA 02110-1301, USA. */
  24. !! libgcc routines for the Renesas / SuperH SH CPUs.
  25. !! Contributed by Steve Chamberlain.
  26. !! sac@cygnus.com
  27. !! ashiftrt_r4_x, ___ashrsi3, ___ashlsi3, ___lshrsi3 routines
  28. !! recoded in assembly by Toshiyasu Morita
  29. !! tm@netcom.com
  30. /* SH2 optimizations for ___ashrsi3, ___ashlsi3, ___lshrsi3 and
  31. ELF local label prefixes by J"orn Rennecke
  32. amylaar@cygnus.com */
  33. /* r0: rn r1: qn */ /* r0: n1 r4: n0 r5: d r6: d1 */ /* r2: __m */
  34. /* n1 < d, but n1 might be larger than d1. */
  35. .global __udiv_qrnnd_16
  36. .balign 8
  37. __udiv_qrnnd_16:
  38. div0u
  39. cmp/hi r6,r0
  40. bt .Lots
  41. .rept 16
  42. div1 r6,r0
  43. .endr
  44. extu.w r0,r1
  45. bt 0f
  46. add r6,r0
  47. 0: rotcl r1
  48. mulu.w r1,r5
  49. xtrct r4,r0
  50. swap.w r0,r0
  51. sts macl,r2
  52. cmp/hs r2,r0
  53. sub r2,r0
  54. bt 0f
  55. addc r5,r0
  56. add #-1,r1
  57. bt 0f
  58. 1: add #-1,r1
  59. rts
  60. add r5,r0
  61. .balign 8
  62. .Lots:
  63. sub r5,r0
  64. swap.w r4,r1
  65. xtrct r0,r1
  66. clrt
  67. mov r1,r0
  68. addc r5,r0
  69. mov #-1,r1
  70. bf/s 1b
  71. shlr16 r1
  72. 0: rts
  73. nop