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 31#if defined ( __CC_ARM ) /* Keil */ 32 #define CODESECT AREA ||.text||, CODE, READONLY, ALIGN=2 33 #define LABEL 34#elif defined ( __IASMARM__ ) /* IAR */ 35 #define CODESECT SECTION `.text`:CODE 36 #define PROC 37 #define LABEL 38 #define ENDP 39 #define EXPORT PUBLIC 40#elif defined ( __CSMC__ ) /* Cosmic */ 41 #define CODESECT switch .text 42 #define THUMB 43 #define EXPORT xdef 44 #define PROC : 45 #define LABEL : 46 #define ENDP 47 #define arm_bitreversal_32 _arm_bitreversal_32 48#elif defined ( __TI_ARM__ ) /* TI ARM */ 49 #define THUMB .thumb 50 #define CODESECT .text 51 #define EXPORT .global 52 #define PROC : .asmfunc 53 #define LABEL : 54 #define ENDP .endasmfunc 55 #define END 56#elif defined ( __GNUC__ ) /* GCC */ 57 #define THUMB .thumb 58 #define CODESECT .section .text 59 #define EXPORT .global 60 #define PROC : 61 #define LABEL : 62 #define ENDP 63 #define END 64 65 .syntax unified 66#endif 67 68 CODESECT 69 THUMB 70 71;/* 72;* @brief In-place bit reversal function. 73;* @param[in, out] *pSrc points to the in-place buffer of unknown 32-bit data type. 74;* @param[in] bitRevLen bit reversal table length 75;* @param[in] *pBitRevTab points to bit reversal table. 76;* @return none. 77;*/ 78 EXPORT arm_bitreversal_32 79 EXPORT arm_bitreversal_16 80 81#if defined ( __CC_ARM ) /* Keil */ 82#elif defined ( __IASMARM__ ) /* IAR */ 83#elif defined ( __CSMC__ ) /* Cosmic */ 84#elif defined ( __TI_ARM__ ) /* TI ARM */ 85#elif defined ( __GNUC__ ) /* GCC */ 86 .type arm_bitreversal_16, %function 87 .type arm_bitreversal_32, %function 88#endif 89 90#if defined(ARM_MATH_CM0) || defined(ARM_MATH_CM0PLUS) || defined(ARM_MATH_ARMV8MBL) 91 92arm_bitreversal_32 PROC 93 ADDS r3,r1,#1 94 PUSH {r4-r6} 95 ADDS r1,r2,#0 96 LSRS r3,r3,#1 97arm_bitreversal_32_0 LABEL 98 LDRH r2,[r1,#2] 99 LDRH r6,[r1,#0] 100 ADD r2,r0,r2 101 ADD r6,r0,r6 102 LDR r5,[r2,#0] 103 LDR r4,[r6,#0] 104 STR r5,[r6,#0] 105 STR r4,[r2,#0] 106 LDR r5,[r2,#4] 107 LDR r4,[r6,#4] 108 STR r5,[r6,#4] 109 STR r4,[r2,#4] 110 ADDS r1,r1,#4 111 SUBS r3,r3,#1 112 BNE arm_bitreversal_32_0 113 POP {r4-r6} 114 BX lr 115 ENDP 116 117arm_bitreversal_16 PROC 118 ADDS r3,r1,#1 119 PUSH {r4-r6} 120 ADDS r1,r2,#0 121 LSRS r3,r3,#1 122arm_bitreversal_16_0 LABEL 123 LDRH r2,[r1,#2] 124 LDRH r6,[r1,#0] 125 LSRS r2,r2,#1 126 LSRS r6,r6,#1 127 ADD r2,r0,r2 128 ADD r6,r0,r6 129 LDR r5,[r2,#0] 130 LDR r4,[r6,#0] 131 STR r5,[r6,#0] 132 STR r4,[r2,#0] 133 ADDS r1,r1,#4 134 SUBS r3,r3,#1 135 BNE arm_bitreversal_16_0 136 POP {r4-r6} 137 BX lr 138 ENDP 139 140#else 141 142arm_bitreversal_32 PROC 143 ADDS r3,r1,#1 144 CMP r3,#1 145 IT LS 146 BXLS lr 147 PUSH {r4-r9} 148 ADDS r1,r2,#2 149 LSRS r3,r3,#2 150arm_bitreversal_32_0 LABEL ;/* loop unrolled by 2 */ 151 LDRH r8,[r1,#4] 152 LDRH r9,[r1,#2] 153 LDRH r2,[r1,#0] 154 LDRH r12,[r1,#-2] 155 ADD r8,r0,r8 156 ADD r9,r0,r9 157 ADD r2,r0,r2 158 ADD r12,r0,r12 159 LDR r7,[r9,#0] 160 LDR r6,[r8,#0] 161 LDR r5,[r2,#0] 162 LDR r4,[r12,#0] 163 STR r6,[r9,#0] 164 STR r7,[r8,#0] 165 STR r5,[r12,#0] 166 STR r4,[r2,#0] 167 LDR r7,[r9,#4] 168 LDR r6,[r8,#4] 169 LDR r5,[r2,#4] 170 LDR r4,[r12,#4] 171 STR r6,[r9,#4] 172 STR r7,[r8,#4] 173 STR r5,[r12,#4] 174 STR r4,[r2,#4] 175 ADDS r1,r1,#8 176 SUBS r3,r3,#1 177 BNE arm_bitreversal_32_0 178 POP {r4-r9} 179 BX lr 180 ENDP 181 182arm_bitreversal_16 PROC 183 ADDS r3,r1,#1 184 CMP r3,#1 185 IT LS 186 BXLS lr 187 PUSH {r4-r9} 188 ADDS r1,r2,#2 189 LSRS r3,r3,#2 190arm_bitreversal_16_0 LABEL ;/* loop unrolled by 2 */ 191 LDRH r8,[r1,#4] 192 LDRH r9,[r1,#2] 193 LDRH r2,[r1,#0] 194 LDRH r12,[r1,#-2] 195 ADD r8,r0,r8,LSR #1 196 ADD r9,r0,r9,LSR #1 197 ADD r2,r0,r2,LSR #1 198 ADD r12,r0,r12,LSR #1 199 LDR r7,[r9,#0] 200 LDR r6,[r8,#0] 201 LDR r5,[r2,#0] 202 LDR r4,[r12,#0] 203 STR r6,[r9,#0] 204 STR r7,[r8,#0] 205 STR r5,[r12,#0] 206 STR r4,[r2,#0] 207 ADDS r1,r1,#8 208 SUBS r3,r3,#1 209 BNE arm_bitreversal_16_0 210 POP {r4-r9} 211 BX lr 212 ENDP 213 214#endif 215 216 END 217