srli.S 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165
  1. ; Copyright (C) 2012-2022 Free Software Foundation, Inc.
  2. ; Contributed by Red Hat.
  3. ;
  4. ; This file is free software; you can redistribute it and/or modify it
  5. ; under the terms of the GNU General Public License as published by the
  6. ; Free Software Foundation; either version 3, or (at your option) any
  7. ; later version.
  8. ;
  9. ; This file is distributed in the hope that it will be useful, but
  10. ; WITHOUT ANY WARRANTY; without even the implied warranty of
  11. ; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  12. ; General Public License for more details.
  13. ;
  14. ; Under Section 7 of GPL version 3, you are granted additional
  15. ; permissions described in the GCC Runtime Library Exception, version
  16. ; 3.1, as published by the Free Software Foundation.
  17. ;
  18. ; You should have received a copy of the GNU General Public License and
  19. ; a copy of the GCC Runtime Library Exception along with this program;
  20. ; see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
  21. ; <http://www.gnu.org/licenses/>.
  22. .text
  23. .section .text.__mspabi_srli_n
  24. .macro _srli n
  25. .global __mspabi_srli_\n
  26. __mspabi_srli_\n:
  27. CLRC
  28. RRC.W R12
  29. .endm
  30. /* Logical Right Shift - R12 -> R12. */
  31. _srli 15
  32. _srli 14
  33. _srli 13
  34. _srli 12
  35. _srli 11
  36. _srli 10
  37. _srli 9
  38. _srli 8
  39. _srli 7
  40. _srli 6
  41. _srli 5
  42. _srli 4
  43. _srli 3
  44. _srli 2
  45. _srli 1
  46. #ifdef __MSP430X_LARGE__
  47. RETA
  48. #else
  49. RET
  50. #endif
  51. .section .text.__mspabi_srli
  52. 1: ADD.W #-1,R13
  53. CLRC
  54. RRC.W R12,R12
  55. .global __mspabi_srli
  56. __mspabi_srli:
  57. CMP #0,R13
  58. JNZ 1b
  59. #ifdef __MSP430X_LARGE__
  60. RETA
  61. #else
  62. RET
  63. #endif
  64. #ifdef __MSP430X__
  65. .section .text.__gnu_mspabi_srlp
  66. 1: ADDA #-1,R13
  67. CLRC
  68. RRCX.A R12,R12
  69. .global __gnu_mspabi_srlp
  70. __gnu_mspabi_srlp:
  71. CMP #0,R13
  72. JNZ 1b
  73. #ifdef __MSP430X_LARGE__
  74. RETA
  75. #else
  76. RET
  77. #endif /* __MSP430X_LARGE__ */
  78. #endif /* __MSP430X__ */
  79. /* Logical Right Shift - R12:R13 -> R12:R13. */
  80. .section .text.__mspabi_srll_n
  81. .macro _srll n
  82. .global __mspabi_srll_\n
  83. __mspabi_srll_\n:
  84. CLRC
  85. RRC.W R13
  86. RRC.W R12
  87. .endm
  88. _srll 15
  89. _srll 14
  90. _srll 13
  91. _srll 12
  92. _srll 11
  93. _srll 10
  94. _srll 9
  95. _srll 8
  96. _srll 7
  97. _srll 6
  98. _srll 5
  99. _srll 4
  100. _srll 3
  101. _srll 2
  102. _srll 1
  103. #ifdef __MSP430X_LARGE__
  104. RETA
  105. #else
  106. RET
  107. #endif
  108. .section .text.__mspabi_srll
  109. 1: ADD.W #-1,R14
  110. CLRC
  111. RRC.W R13
  112. RRC.W R12
  113. .global __mspabi_srll
  114. __mspabi_srll:
  115. CMP #0,R14
  116. JNZ 1b
  117. #ifdef __MSP430X_LARGE__
  118. RETA
  119. #else
  120. RET
  121. #endif
  122. /* Logical Right Shift - R8:R11 -> R12:R15
  123. A 64-bit argument would normally be passed in R12:R15, but __mspabi_srlll has
  124. special conventions, so the 64-bit value to shift is passed in R8:R11.
  125. According to the MSPABI, the shift amount is a 64-bit value in R12:R15, but
  126. we only use the low word in R12. */
  127. .section .text.__mspabi_srlll
  128. .global __mspabi_srlll
  129. __mspabi_srlll:
  130. MOV R11, R15 ; Free up R11 first
  131. MOV R12, R11 ; Save the shift amount in R11
  132. MOV R10, R14
  133. MOV R9, R13
  134. MOV R8, R12
  135. CMP #0,R11
  136. JNZ 1f
  137. #ifdef __MSP430X_LARGE__
  138. RETA
  139. #else
  140. RET
  141. #endif
  142. 1:
  143. CLRC
  144. RRC R15
  145. RRC R14
  146. RRC R13
  147. RRC R12
  148. ADD #-1,R11
  149. JNZ 1b
  150. #ifdef __MSP430X_LARGE__
  151. RETA
  152. #else
  153. RET
  154. #endif