srai.S 1.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107
  1. ; Copyright (C) 2012-2015 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. .macro _srai n
  24. .global __mspabi_srai_\n
  25. __mspabi_srai_\n:
  26. RRA.W R12
  27. .endm
  28. /* Logical Right Shift - R12 -> R12 */
  29. _srai 15
  30. _srai 14
  31. _srai 13
  32. _srai 12
  33. _srai 11
  34. _srai 10
  35. _srai 9
  36. _srai 8
  37. _srai 7
  38. _srai 6
  39. _srai 5
  40. _srai 4
  41. _srai 3
  42. _srai 2
  43. _srai 1
  44. #ifdef __MSP430X_LARGE__
  45. RETA
  46. #else
  47. RET
  48. #endif
  49. 1: ADD.W #-1,R13
  50. RRA.W R12,R12
  51. .global __mspabi_srai
  52. __mspabi_srai:
  53. CMP #0,R13
  54. JNZ 1b
  55. #ifdef __MSP430X_LARGE__
  56. RETA
  57. #else
  58. RET
  59. #endif
  60. /* Logical Right Shift - R12:R13 -> R12:R13 */
  61. .macro _sral n
  62. .global __mspabi_sral_\n
  63. __mspabi_sral_\n:
  64. RRA.W R13
  65. RRC.W R12
  66. .endm
  67. _sral 15
  68. _sral 14
  69. _sral 13
  70. _sral 12
  71. _sral 11
  72. _sral 10
  73. _sral 9
  74. _sral 8
  75. _sral 7
  76. _sral 6
  77. _sral 5
  78. _sral 4
  79. _sral 3
  80. _sral 2
  81. _sral 1
  82. #ifdef __MSP430X_LARGE__
  83. RETA
  84. #else
  85. RET
  86. #endif
  87. 1: ADD.W #-1,R14
  88. RRA.W R13
  89. RRC.W R12
  90. .global __mspabi_sral
  91. __mspabi_sral:
  92. CMP #0,R14
  93. JNZ 1b
  94. #ifdef __MSP430X_LARGE__
  95. RETA
  96. #else
  97. RET
  98. #endif