ARM application development SDK for MNT ZZ9000 graphics and coprocessor card for classic Amiga computers.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

idiv.S 1.6KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566
  1. /* Runtime ABI for the ARM Cortex-M0
  2. * idiv.S: signed 32 bit division (only quotient)
  3. *
  4. * Copyright (c) 2012-2017 Jörg Mische <bobbl@gmx.de>
  5. *
  6. * Permission to use, copy, modify, and/or distribute this software for any
  7. * purpose with or without fee is hereby granted, provided that the above
  8. * copyright notice and this permission notice appear in all copies.
  9. *
  10. * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
  11. * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
  12. * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
  13. * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
  14. * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
  15. * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT
  16. * OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
  17. */
  18. .syntax unified
  19. .text
  20. .thumb
  21. .cpu cortex-a9
  22. @ int __divsi3(int num, int denom)
  23. @
  24. @ libgcc wrapper: just an alias for __aeabi_idivmod(), the remainder is ignored
  25. @
  26. .thumb_func
  27. .global __divsi3
  28. __divsi3:
  29. @ int __aeabi_idiv(int num:r0, int denom:r1)
  30. @
  31. @ Divide r0 by r1 and return quotient in r0 (all signed).
  32. @ Use __aeabi_uidivmod() but check signs before and change signs afterwards.
  33. @
  34. .thumb_func
  35. .global __aeabi_idiv
  36. __aeabi_idiv:
  37. cmp r0, #0
  38. bge .Lnumerator_pos
  39. rsbs r0, r0, #0 @ num = -num
  40. cmp r1, #0
  41. bge .Lneg_result
  42. rsbs r1, r1, #0 @ den = -den
  43. .Luidivmod:
  44. b __aeabi_uidivmod
  45. .Lnumerator_pos:
  46. cmp r1, #0
  47. bge .Luidivmod
  48. rsbs r1, r1, #0 @ den = -den
  49. .Lneg_result:
  50. push {lr}
  51. bl __aeabi_uidivmod
  52. rsbs r0, r0, #0 @ quot = -quot
  53. pop {pc}