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.

lasr.S 1.5KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  1. /* Runtime ABI for the ARM Cortex-M0
  2. * lasr.S: 64 bit arithmetic shift right
  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 __ashrdi3(long long r1:r0, int r2)
  23. @
  24. @ libgcc wrapper: just an alias for __aeabi_lasr()
  25. @
  26. .thumb_func
  27. .global __ashrdi3
  28. __ashrdi3:
  29. @ long long __aeabi_lasr(long long r1:r0, int r2)
  30. @
  31. @ Arithmetic shift r1:r0 right by r2 bits
  32. @
  33. .thumb_func
  34. .global __aeabi_lasr
  35. __aeabi_lasr:
  36. cmp r2, #31
  37. bhi 1f
  38. movs r3, r1 @ n < 32:
  39. lsrs r0, r2
  40. asrs r1, r2 @ hi = hi >> n
  41. rsbs r2, r2, #0
  42. adds r2, #32
  43. lsls r3, r2
  44. orrs r0, r3 @ lo = lo >> n | hi << (32-n)
  45. bx lr
  46. 1: subs r2, #32 @ n >= 32:
  47. movs r0, r1
  48. asrs r0, r2 @ lo = hi >> (n-32)
  49. asrs r1, #31 @ hi = hi >> 31
  50. bx lr