lib1funcs.S 2.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192
  1. /* Copyright (C) 2009-2022 Free Software Foundation, Inc.
  2. This file is part of GCC.
  3. Contributed by Maciej W. Rozycki <macro@linux-mips.org>.
  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 3, or (at your option) any
  7. later version.
  8. This file is distributed in the hope that it will be useful, but
  9. WITHOUT ANY WARRANTY; without even the implied warranty of
  10. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  11. General Public License for more details.
  12. Under Section 7 of GPL version 3, you are granted additional
  13. permissions described in the GCC Runtime Library Exception, version
  14. 3.1, as published by the Free Software Foundation.
  15. You should have received a copy of the GNU General Public License and
  16. a copy of the GCC Runtime Library Exception along with this program;
  17. see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
  18. <http://www.gnu.org/licenses/>. */
  19. #ifdef L_udivsi3
  20. .text
  21. .globl __udivsi3
  22. .type __udivsi3, @function
  23. __udivsi3:
  24. .word 0
  25. movl 8(%ap), %r1
  26. blss 0f /* Check bit #31 of divisor. */
  27. movl 4(%ap), %r2
  28. blss 1f /* Check bit #31 of dividend. */
  29. /* Both zero, do a standard division. */
  30. divl3 %r1, %r2, %r0
  31. ret
  32. /* MSB of divisor set, only 1 or 0 may result. */
  33. 0:
  34. decl %r1
  35. clrl %r0
  36. cmpl %r1, 4(%ap)
  37. adwc $0, %r0
  38. ret
  39. /* MSB of dividend set, do an extended division. */
  40. 1:
  41. clrl %r3
  42. ediv %r1, %r2, %r0, %r3
  43. ret
  44. .size __udivsi3, . - __udivsi3
  45. .previous
  46. #endif
  47. #ifdef L_umodsi3
  48. .text
  49. .globl __umodsi3
  50. .type __umodsi3, @function
  51. __umodsi3:
  52. .word 0
  53. movl 8(%ap), %r1
  54. blss 0f /* Check bit #31 of divisor. */
  55. movl 4(%ap), %r2
  56. blss 1f /* Check bit #31 of dividend. */
  57. /* Both zero, do a standard division. */
  58. divl3 %r1, %r2, %r0
  59. mull2 %r0, %r1
  60. subl3 %r1, %r2, %r0
  61. ret
  62. /* MSB of divisor set, subtract the divisor at most once. */
  63. 0:
  64. movl 4(%ap), %r2
  65. clrl %r0
  66. cmpl %r2, %r1
  67. sbwc $0, %r0
  68. bicl2 %r0, %r1
  69. subl3 %r1, %r2, %r0
  70. ret
  71. /* MSB of dividend set, do an extended division. */
  72. 1:
  73. clrl %r3
  74. ediv %r1, %r2, %r3, %r0
  75. ret
  76. .size __umodsi3, . - __umodsi3
  77. .previous
  78. #endif