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.

divdi3.S 1.6KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172
  1. /* Runtime ABI for the ARM Cortex-M0
  2. * ldivmod.S: signed 64 bit division (only quotient)
  3. *
  4. * Copyright (c) 2012 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-m0
  22. @ long long __divdi3(long long numerator, long long denominator)
  23. @
  24. @ Divide r1:r0 by r3:r2 and return the quotient in r1:r0.
  25. @ Same as _aeabi_ldivmod(), but ignore remainder.
  26. @
  27. .thumb_func
  28. .global __divdi3
  29. __divdi3:
  30. cmp r1, #0
  31. bge L_num_pos
  32. push {r4, lr}
  33. movs r4, #0 @ num = -num
  34. rsbs r0, r0, #0
  35. sbcs r4, r1
  36. mov r1, r4
  37. cmp r3, #0
  38. bge L_neg_result
  39. movs r4, #0 @ den = -den
  40. rsbs r2, r2, #0
  41. sbcs r4, r3
  42. mov r3, r4
  43. bl __aeabi_uldivmod
  44. pop {r4, pc}
  45. L_num_pos:
  46. cmp r3, #0
  47. bge __aeabi_uldivmod
  48. push {r4, lr}
  49. movs r4, #0 @ den = -den
  50. rsbs r2, r2, #0
  51. sbcs r4, r3
  52. mov r3, r4
  53. L_neg_result:
  54. bl __aeabi_uldivmod
  55. movs r4, #0 @ quot = -quot
  56. rsbs r0, r0, #0
  57. sbcs r4, r1
  58. mov r1, r4
  59. pop {r4, pc}