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.

lmul.S 1.6KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374
  1. /* Runtime ABI for the ARM Cortex-M0
  2. * lmul.S: 64 bit multiplication
  3. *
  4. * Copyright (c) 2013 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 __muldi3(long long, long long)
  23. @
  24. @ libgcc wrapper: just an alias for __aeabi_lmul()
  25. @
  26. .thumb_func
  27. .global __muldi3
  28. __muldi3:
  29. @ long long __aeabi_lmul(long long r1:r0, long long r3:r2)
  30. @
  31. @ Multiply r1:r0 and r3:r2 and return the product in r1:r0
  32. @ Can also be used for unsigned long product
  33. @
  34. .thumb_func
  35. .global __aeabi_lmul
  36. __aeabi_lmul:
  37. push {r4, lr}
  38. muls r1, r2
  39. muls r3, r0
  40. adds r1, r3
  41. lsrs r3, r0, #16
  42. lsrs r4, r2, #16
  43. muls r3, r4
  44. adds r1, r3
  45. lsrs r3, r0, #16
  46. uxth r0, r0
  47. uxth r2, r2
  48. muls r3, r2
  49. muls r4, r0
  50. muls r0, r2
  51. movs r2, #0
  52. adds r3, r4
  53. adcs r2, r2
  54. lsls r2, #16
  55. adds r1, r2
  56. lsls r2, r3, #16
  57. lsrs r3, #16
  58. adds r0, r2
  59. adcs r1, r3
  60. pop {r4, pc}