div.S 1.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586
  1. /* Copyright (C) 1996-2026 Free Software Foundation, Inc.
  2. This file is part of the GNU C Library.
  3. The GNU C Library is free software; you can redistribute it and/or
  4. modify it under the terms of the GNU Lesser General Public
  5. License as published by the Free Software Foundation; either
  6. version 2.1 of the License, or (at your option) any later version.
  7. The GNU C Library is distributed in the hope that it will be useful,
  8. but WITHOUT ANY WARRANTY; without even the implied warranty of
  9. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  10. Lesser General Public License for more details.
  11. You should have received a copy of the GNU Lesser General Public
  12. License along with the GNU C Library. If not, see
  13. <https://www.gnu.org/licenses/>. */
  14. #include "div_libc.h"
  15. #undef FRAME
  16. #ifdef __alpha_fix__
  17. #define FRAME 0
  18. #else
  19. #define FRAME 16
  20. #endif
  21. .set noat
  22. .align 4
  23. .globl div
  24. .ent div
  25. div:
  26. .frame sp, FRAME, ra
  27. #if FRAME > 0
  28. lda sp, -FRAME(sp)
  29. #endif
  30. #ifdef PROF
  31. .set macro
  32. ldgp gp, 0(pv)
  33. lda AT, _mcount
  34. jsr AT, (AT), _mcount
  35. .set nomacro
  36. .prologue 1
  37. #else
  38. .prologue 0
  39. #endif
  40. beq $18, $divbyzero
  41. excb
  42. mf_fpcr $f10
  43. _ITOFT2 $17, $f0, 0, $18, $f1, 8
  44. cvtqt $f0, $f0
  45. cvtqt $f1, $f1
  46. divt/c $f0, $f1, $f0
  47. cvttq/c $f0, $f0
  48. excb
  49. mt_fpcr $f10
  50. _FTOIT $f0, $0, 0
  51. mull $0, $18, $1
  52. subl $17, $1, $1
  53. stl $0, 0(a0)
  54. stl $1, 4(a0)
  55. mov a0, v0
  56. #if FRAME > 0
  57. lda sp, FRAME(sp)
  58. #endif
  59. ret
  60. $divbyzero:
  61. mov a0, v0
  62. lda a0, GEN_INTDIV
  63. call_pal PAL_gentrap
  64. stl zero, 0(v0)
  65. stl zero, 4(v0)
  66. #if FRAME > 0
  67. lda sp, FRAME(sp)
  68. #endif
  69. ret
  70. .end div