📄 bit_reverse.lst
字号:
C166 COMPILER V6.04, BIT_REVERSE 09/04/2007 16:24:44 PAGE 1
C166 COMPILER V6.04, COMPILATION OF MODULE BIT_REVERSE
OBJECT MODULE PLACED IN Bit_reverse.OBJ
COMPILER INVOKED BY: C:\Keil\C166\BIN\C166.EXE Bit_reverse.c MODV2 BROWSE MODV2 DEBUG
stmt lvl source
1 /******************************************************************************
2 ; Module: Bit_reverse
3 ; Filename: Bit_reverse.c
4 ; Project: DSP library for XC166 microcontroller
5 ;------------------------------------------------------------------------------
6 ; Compiler: Keil
7 ;
8 ; Version: V1.2
9 ;
10 ; Description: Reversing the binary bit of the input indices during the
11 ; FFT operation. This routine is especially written for FFT.
12 ;
13 ; Date: May 2003
14 ;
15 ; Copyright: Infineon Technologies AG
16 ;*****************************************************************************/
17
18 /******************************************************************************
19 ; DataS Bit_reverse(DataS* X, DataS N);
20 ;
21 ; INPUTS:
22 ; X the input index vector
23 ; N the size of the vector
24 ;
25 ; RETURN:
26 ;
27 ; ALGORITHM: befor bit reverse: b7.b6.b5.b4.b3.b2.b1.b0
28 ; after bit reverse: b0.b1.b2.b3.b4.b5.b6.b7
29 ;
30 ; REGISTER USAGE:
31 ; 1. From .c file to .asm file:
32 ; defined by compiler
33 ;
34 ; 2. From .asm file to .c file:
35 ; (R4) = exponent of N
36 ;
37 ; Assumption: 1. N must be in the form 2^M, where M in an integer.
38 ; 2. 2 <= N <= 2048
39 ;
40 ;*****************************************************************************/
41
42 #include "DspLib_Keil.h"
43
44 DataS Bit_reverse(DataS* X, DataS N)
45 {
46 1 __asm
47 1 {
48 1
49 1 MOV R1,N ;(R1)=N
50 1 //determinate the exponent of N
51 1 MOV R2,#0ffffh ; clesr register R2=-1
52 1 next:
53 1 ADD R2,#01h ;(R2)=(R2)+1
54 1 SHR R1,#1h ;(R1)=N/2
55 1 JMPR cc_NZ, next ;if (R1)>0, jump
C166 COMPILER V6.04, BIT_REVERSE 09/04/2007 16:24:44 PAGE 2
56 1
57 1 //output the exponent of N to R4
58 1 MOV R4,R2 ;(R4)=(R2)=exponent of N
59 1
60 1 //bit reverse
61 1 //if N=2, one bit
62 1 CMP R2,#1
63 1 JMPR cc_NE,Neq2 ;if (R2) not equal to 1, jump
64 1
65 1 RET
66 1
67 1 //if N=4, 2 bits
68 1 Neq2:
69 1 CMP R2,#2
70 1 JMPR cc_NE,Neq3 ;if (R2) not equal to 2, jump
71 1 loop2:
72 1 MOV R3,[X] ;(R3)=x[i]
73 1 MOV R2,R3 ;(R2)=(R3)
74 1 BMOV R2.1,R3.0 ;bit reverse
75 1 BMOV R2.0,R3.1
76 1 MOV [X],R2 ;x[i]=(R2)
77 1 MOV R2,[X+] ;just increase the address of X
78 1 SUB N,#1 ;(N)=(N)-1
79 1 JMPR cc_NZ,loop2 ;if (N)>0, jump
80 1
81 1 RET
82 1
83 1 //if N=8, 3 bits
84 1 Neq3:
85 1 CMP R2,#3
86 1 JMPR cc_NE,Neq4 ;if (R2) not equal to 3, jump
87 1 loop3:
88 1 MOV R3,[X] ;(R3)=x[i]
89 1 MOV R2,R3 ;(R2)=(R3)
90 1 BMOV R2.2,R3.0 ;bit reverse
91 1 BMOV R2.0,R3.2 ;bit reverse
92 1 MOV [X],R2 ;x[i]=(R2)
93 1 MOV R2,[X+] ;increase the address
94 1 SUB N,#1 ;(N)=(N)-1
95 1 JMPR cc_NZ,loop3 ;if (N)>0, jump
96 1
97 1 RET
98 1
99 1 //if N=16, 4 bits
100 1 Neq4:
101 1 CMP R2,#4
102 1 JMPR cc_NE,Neq5 ;if (R2) not equal to 4, jump
103 1 loop4:
104 1 MOV R3,[X] ;(R3)=x[i]
105 1 MOV R2,R3 ;(R2)=(R3)
106 1 BMOV R2.3,R3.0 ;bit reverse
107 1 BMOV R2.2,R3.1 ;bit reverse
108 1 BMOV R2.1,R3.2 ;bit reverse
109 1 BMOV R2.0,R3.3 ;bit reverse
110 1 MOV [X],R2 ;x[i]=(R2)
111 1 MOV R2,[X+] ;increase the address
112 1 SUB N,#1 ;(X)=(X)-1
113 1 JMPR cc_NZ,loop4 ;if (N)>0, jump
114 1
115 1 RET
116 1
117 1 //if N=32, 5 bits
C166 COMPILER V6.04, BIT_REVERSE 09/04/2007 16:24:44 PAGE 3
118 1 Neq5:
119 1 CMP R2,#5
120 1 JMPR cc_NE,Neq6 ;if (R2) not equal to 5, jump
121 1 loop5:
122 1 MOV R3,[X] ;(R3)=x[i]
123 1 MOV R2,R3 ;(R2)=(R3)
124 1 BMOV R2.4,R3.0 ;bit reverse
125 1 BMOV R2.3,R3.1 ;bit reverse
126 1 BMOV R2.1,R3.3 ;bit reverse
127 1 BMOV R2.0,R3.4 ;bit reverse
128 1 MOV [X],R2 ;x[i]=(R2)
129 1 MOV R2,[X+] ;increase the address
130 1 SUB N,#1 ;(N)=(N)-1
131 1 JMPR cc_NZ,loop5 ;if (N)>0, jump
132 1
133 1 RET
134 1
135 1 //if N=64, 6 bits
136 1 Neq6:
137 1 CMP R2,#6
138 1 JMPR cc_NE,Neq7 ;if (R2) not equal to 6, jump
139 1 loop6:
140 1 MOV R3,[X] ;(R3)=x[i]
141 1 MOV R2,R3 ;(R2)=(R3)
142 1 BMOV R2.5,R3.0 ;bit reverse
143 1 BMOV R2.4,R3.1 ;bit reverse
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -