arm_bitreversal2.S 5.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216
  1. ;/* ----------------------------------------------------------------------
  2. ; * Project: CMSIS DSP Library
  3. ; * Title: arm_bitreversal2.S
  4. ; * Description: arm_bitreversal_32 function done in assembly for maximum speed.
  5. ; * Called after doing an fft to reorder the output.
  6. ; * The function is loop unrolled by 2. arm_bitreversal_16 as well.
  7. ; *
  8. ; * $Date: 27. January 2017
  9. ; * $Revision: V.1.5.1
  10. ; *
  11. ; * Target Processor: Cortex-M cores
  12. ; * -------------------------------------------------------------------- */
  13. ;/*
  14. ; * Copyright (C) 2010-2017 ARM Limited or its affiliates. All rights reserved.
  15. ; *
  16. ; * SPDX-License-Identifier: Apache-2.0
  17. ; *
  18. ; * Licensed under the Apache License, Version 2.0 (the License); you may
  19. ; * not use this file except in compliance with the License.
  20. ; * You may obtain a copy of the License at
  21. ; *
  22. ; * www.apache.org/licenses/LICENSE-2.0
  23. ; *
  24. ; * Unless required by applicable law or agreed to in writing, software
  25. ; * distributed under the License is distributed on an AS IS BASIS, WITHOUT
  26. ; * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  27. ; * See the License for the specific language governing permissions and
  28. ; * limitations under the License.
  29. ; */
  30. #if defined ( __CC_ARM ) /* Keil */
  31. #define CODESECT AREA ||.text||, CODE, READONLY, ALIGN=2
  32. #define LABEL
  33. #elif defined ( __IASMARM__ ) /* IAR */
  34. #define CODESECT SECTION `.text`:CODE
  35. #define PROC
  36. #define LABEL
  37. #define ENDP
  38. #define EXPORT PUBLIC
  39. #elif defined ( __CSMC__ ) /* Cosmic */
  40. #define CODESECT switch .text
  41. #define THUMB
  42. #define EXPORT xdef
  43. #define PROC :
  44. #define LABEL :
  45. #define ENDP
  46. #define arm_bitreversal_32 _arm_bitreversal_32
  47. #elif defined ( __TI_ARM__ ) /* TI ARM */
  48. #define THUMB .thumb
  49. #define CODESECT .text
  50. #define EXPORT .global
  51. #define PROC : .asmfunc
  52. #define LABEL :
  53. #define ENDP .endasmfunc
  54. #define END
  55. #elif defined ( __GNUC__ ) /* GCC */
  56. #define THUMB .thumb
  57. #define CODESECT .section .text
  58. #define EXPORT .global
  59. #define PROC :
  60. #define LABEL :
  61. #define ENDP
  62. #define END
  63. .syntax unified
  64. #endif
  65. CODESECT
  66. THUMB
  67. ;/*
  68. ;* @brief In-place bit reversal function.
  69. ;* @param[in, out] *pSrc points to the in-place buffer of unknown 32-bit data type.
  70. ;* @param[in] bitRevLen bit reversal table length
  71. ;* @param[in] *pBitRevTab points to bit reversal table.
  72. ;* @return none.
  73. ;*/
  74. EXPORT arm_bitreversal_32
  75. EXPORT arm_bitreversal_16
  76. #if defined ( __CC_ARM ) /* Keil */
  77. #elif defined ( __IASMARM__ ) /* IAR */
  78. #elif defined ( __CSMC__ ) /* Cosmic */
  79. #elif defined ( __TI_ARM__ ) /* TI ARM */
  80. #elif defined ( __GNUC__ ) /* GCC */
  81. .type arm_bitreversal_16, %function
  82. .type arm_bitreversal_32, %function
  83. #endif
  84. #if defined(ARM_MATH_CM0) || defined(ARM_MATH_CM0PLUS) || defined(ARM_MATH_ARMV8MBL)
  85. arm_bitreversal_32 PROC
  86. ADDS r3,r1,#1
  87. PUSH {r4-r6}
  88. ADDS r1,r2,#0
  89. LSRS r3,r3,#1
  90. arm_bitreversal_32_0 LABEL
  91. LDRH r2,[r1,#2]
  92. LDRH r6,[r1,#0]
  93. ADD r2,r0,r2
  94. ADD r6,r0,r6
  95. LDR r5,[r2,#0]
  96. LDR r4,[r6,#0]
  97. STR r5,[r6,#0]
  98. STR r4,[r2,#0]
  99. LDR r5,[r2,#4]
  100. LDR r4,[r6,#4]
  101. STR r5,[r6,#4]
  102. STR r4,[r2,#4]
  103. ADDS r1,r1,#4
  104. SUBS r3,r3,#1
  105. BNE arm_bitreversal_32_0
  106. POP {r4-r6}
  107. BX lr
  108. ENDP
  109. arm_bitreversal_16 PROC
  110. ADDS r3,r1,#1
  111. PUSH {r4-r6}
  112. ADDS r1,r2,#0
  113. LSRS r3,r3,#1
  114. arm_bitreversal_16_0 LABEL
  115. LDRH r2,[r1,#2]
  116. LDRH r6,[r1,#0]
  117. LSRS r2,r2,#1
  118. LSRS r6,r6,#1
  119. ADD r2,r0,r2
  120. ADD r6,r0,r6
  121. LDR r5,[r2,#0]
  122. LDR r4,[r6,#0]
  123. STR r5,[r6,#0]
  124. STR r4,[r2,#0]
  125. ADDS r1,r1,#4
  126. SUBS r3,r3,#1
  127. BNE arm_bitreversal_16_0
  128. POP {r4-r6}
  129. BX lr
  130. ENDP
  131. #else
  132. arm_bitreversal_32 PROC
  133. ADDS r3,r1,#1
  134. CMP r3,#1
  135. IT LS
  136. BXLS lr
  137. PUSH {r4-r9}
  138. ADDS r1,r2,#2
  139. LSRS r3,r3,#2
  140. arm_bitreversal_32_0 LABEL ;/* loop unrolled by 2 */
  141. LDRH r8,[r1,#4]
  142. LDRH r9,[r1,#2]
  143. LDRH r2,[r1,#0]
  144. LDRH r12,[r1,#-2]
  145. ADD r8,r0,r8
  146. ADD r9,r0,r9
  147. ADD r2,r0,r2
  148. ADD r12,r0,r12
  149. LDR r7,[r9,#0]
  150. LDR r6,[r8,#0]
  151. LDR r5,[r2,#0]
  152. LDR r4,[r12,#0]
  153. STR r6,[r9,#0]
  154. STR r7,[r8,#0]
  155. STR r5,[r12,#0]
  156. STR r4,[r2,#0]
  157. LDR r7,[r9,#4]
  158. LDR r6,[r8,#4]
  159. LDR r5,[r2,#4]
  160. LDR r4,[r12,#4]
  161. STR r6,[r9,#4]
  162. STR r7,[r8,#4]
  163. STR r5,[r12,#4]
  164. STR r4,[r2,#4]
  165. ADDS r1,r1,#8
  166. SUBS r3,r3,#1
  167. BNE arm_bitreversal_32_0
  168. POP {r4-r9}
  169. BX lr
  170. ENDP
  171. arm_bitreversal_16 PROC
  172. ADDS r3,r1,#1
  173. CMP r3,#1
  174. IT LS
  175. BXLS lr
  176. PUSH {r4-r9}
  177. ADDS r1,r2,#2
  178. LSRS r3,r3,#2
  179. arm_bitreversal_16_0 LABEL ;/* loop unrolled by 2 */
  180. LDRH r8,[r1,#4]
  181. LDRH r9,[r1,#2]
  182. LDRH r2,[r1,#0]
  183. LDRH r12,[r1,#-2]
  184. ADD r8,r0,r8,LSR #1
  185. ADD r9,r0,r9,LSR #1
  186. ADD r2,r0,r2,LSR #1
  187. ADD r12,r0,r12,LSR #1
  188. LDR r7,[r9,#0]
  189. LDR r6,[r8,#0]
  190. LDR r5,[r2,#0]
  191. LDR r4,[r12,#0]
  192. STR r6,[r9,#0]
  193. STR r7,[r8,#0]
  194. STR r5,[r12,#0]
  195. STR r4,[r2,#0]
  196. ADDS r1,r1,#8
  197. SUBS r3,r3,#1
  198. BNE arm_bitreversal_16_0
  199. POP {r4-r9}
  200. BX lr
  201. ENDP
  202. #endif
  203. END