__ashrdi3.S 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  1. /* MN10300 64-bit arithmetic right shift
  2. *
  3. * Copyright (C) 2007 Red Hat, Inc. All Rights Reserved.
  4. * Written by David Howells (dhowells@redhat.com)
  5. *
  6. * This program is free software; you can redistribute it and/or
  7. * modify it under the terms of the GNU General Public Licence
  8. * as published by the Free Software Foundation; either version
  9. * 2 of the Licence, or (at your option) any later version.
  10. */
  11. #include <asm/cache.h>
  12. .text
  13. .balign L1_CACHE_BYTES
  14. ###############################################################################
  15. #
  16. # unsigned long long __ashrdi3(unsigned long long value [D1:D0],
  17. # unsigned by [(12,SP)])
  18. #
  19. ###############################################################################
  20. .globl __ashrdi3
  21. .type __ashrdi3,@function
  22. __ashrdi3:
  23. mov (12,sp),a0
  24. and +63,a0
  25. beq __ashrdi3_zero
  26. cmp +31,a0
  27. bhi __ashrdi3_32plus
  28. # the count is in the range 1-31
  29. lsr a0,d0
  30. mov +32,a1
  31. sub a0,a1,a1 # a1 = 32 - count
  32. asl a1,d1,a1 # get underflow from MSW -> LSW
  33. or_asr a1,d0,a0,d1 # insert underflow into LSW and
  34. # shift the MSW
  35. rets
  36. .balign L1_CACHE_BYTES
  37. # the count is in the range 32-63
  38. __ashrdi3_32plus:
  39. asr a0,d1,d0
  40. ext d0 # sign-extend result through MDR
  41. mov mdr,d1
  42. __ashrdi3_zero:
  43. rets
  44. .size __ashrdi3, .-__ashrdi3