⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 fftbook.s

📁 在ICCAVR 环境实现的fft,
💻 S
📖 第 1 页 / 共 2 页
字号:
	.module fftbook.c
	.area data(ram, con, rel)
_dataR::
	.blkb 2
	.area idata
	.word 5
	.area data(ram, con, rel)
	.blkb 2
	.area idata
	.word 5
	.area data(ram, con, rel)
	.blkb 2
	.area idata
	.word 5
	.area data(ram, con, rel)
	.blkb 2
	.area idata
	.word 5
	.area data(ram, con, rel)
	.blkb 2
	.area idata
	.word 0
	.area data(ram, con, rel)
	.blkb 2
	.area idata
	.word 0
	.area data(ram, con, rel)
	.blkb 2
	.area idata
	.word 0
	.area data(ram, con, rel)
	.blkb 2
	.area idata
	.word 0
	.area data(ram, con, rel)
	.blkb 2
	.area idata
	.word 5
	.area data(ram, con, rel)
	.blkb 2
	.area idata
	.word 5
	.area data(ram, con, rel)
	.blkb 2
	.area idata
	.word 5
	.area data(ram, con, rel)
	.blkb 2
	.area idata
	.word 5
	.area data(ram, con, rel)
	.blkb 2
	.area idata
	.word 0
	.area data(ram, con, rel)
	.blkb 2
	.area idata
	.word 0
	.area data(ram, con, rel)
	.blkb 2
	.area idata
	.word 0
	.area data(ram, con, rel)
	.blkb 2
	.area idata
	.word 0
	.area data(ram, con, rel)
	.dbfile D:\HJN\Design\AVR\fft\fftbook.c
	.dbsym e dataR _dataR A[32:16]I
	.area text(rom, con, rel)
	.dbfile D:\HJN\Design\AVR\fft\fftbook.c
	.dbfunc e CHANGE _CHANGE fV
;             b6 -> R22,R23
;             b5 -> R22,R23
;             b4 -> R22,R23
;            all -> R20,R21
;             b3 -> R22,R23
;             b2 -> R10,R11
;             b1 -> R14,R15
;             b0 -> R12,R13
	.even
_CHANGE::
	xcall push_gset5
	.dbline -1
	.dbline 15
; #include <math.h>
; #define uint unsigned int
; #define uchar unsigned char
; #define PI 3.1415926
; 
; uint x0,x1,x2,x3,x4,x5,x6;
; int L,i,j,k,b,p;
; uchar w[32];
; uint TR,TI,temp;
; 
; int dataR[]={5,5,5,5,0,0,0,0,5,5,5,5,0,0,0,0};
; int dataI[16];
; 
; void CHANGE()
;  {                              //i为原始存放位置,最后得invert_pos为倒位序存放位置
	.dbline 17
;   int b0 , b1 , b2 , b3 , b4 , b5 , b6 , all;
;       b0 = b1 = b2 = b3 = b4 = b5 = b6 = all = 0;
	clr R20
	clr R21
	clr R22
	clr R23
	clr R10
	clr R11
	clr R14
	clr R15
	clr R12
	clr R13
	.dbline 18
;   b0  = i&0x01; 
	lds R24,_i
	lds R25,_i+1
	andi R24,1
	andi R25,0
	movw R12,R24
	.dbline 19
;   b1  = (i>>1)&0x01; 
	lds R24,_i
	lds R25,_i+1
	asr R25
	ror R24
	andi R24,1
	andi R25,0
	movw R14,R24
	.dbline 20
;   b2  = (i>>2)&0x01;
	lds R24,_i
	lds R25,_i+1
	asr R25
	ror R24
	asr R25
	ror R24
	andi R24,1
	andi R25,0
	movw R10,R24
	.dbline 21
;   b3  = (i>>3)&0x01;
	lds R22,_i
	lds R23,_i+1
	asr R23
	ror R22
	asr R23
	ror R22
	asr R23
	ror R22
	andi R22,1
	andi R23,0
	.dbline 25
;  // b4  = (i>>4)&0x01;
;   //b5  = (i>>5)&0x01;
;  // b6  = (i>>6)&0x01;
;   all = b0*8 + b1*4 + b2*2 + b3;   //*8 + b4*4 + b5*2 + b6;
	ldi R16,4
	ldi R17,0
	movw R18,R14
	xcall empy16s
	movw R2,R16
	ldi R16,8
	ldi R17,0
	movw R18,R12
	xcall empy16s
	movw R20,R16
	add R20,R2
	adc R21,R3
	ldi R16,2
	ldi R17,0
	movw R18,R10
	xcall empy16s
	add R20,R16
	adc R21,R17
	add R20,R22
	adc R21,R23
	.dbline 26
;   dataI[all] = dataR[i];
	lds R18,_i
	lds R19,_i+1
	ldi R16,2
	ldi R17,0
	xcall empy16s
	movw R30,R16
	ldi R24,<_dataR
	ldi R25,>_dataR
	add R30,R24
	adc R31,R25
	ldd R2,z+0
	ldd R3,z+1
	ldi R16,2
	ldi R17,0
	movw R18,R20
	xcall empy16s
	movw R30,R16
	ldi R24,<_dataI
	ldi R25,>_dataI
	add R30,R24
	adc R31,R25
	std z+1,R3
	std z+0,R2
	.dbline -2
L1:
	xcall pop_gset5
	.dbline 0 ; func end
	ret
	.dbsym r b6 22 I
	.dbsym r b5 22 I
	.dbsym r b4 22 I
	.dbsym r all 20 I
	.dbsym r b3 22 I
	.dbsym r b2 10 I
	.dbsym r b1 14 I
	.dbsym r b0 12 I
	.dbend
	.dbfunc e FFTT _FFTT fV
	.even
_FFTT::
	.dbline -1
	.dbline 31
;  }
; 
;  
; void FFTT()
;  {  TR=dataR[k]; 
	.dbline 31
	lds R18,_k
	lds R19,_k+1
	ldi R16,2
	ldi R17,0
	xcall empy16s
	movw R30,R16
	ldi R24,<_dataR
	ldi R25,>_dataR
	add R30,R24
	adc R31,R25
	ldd R2,z+0
	ldd R3,z+1
	sts _TR+1,R3
	sts _TR,R2
	.dbline 32
;     TI=dataI[k];
	lds R18,_k
	lds R19,_k+1
	ldi R16,2
	ldi R17,0
	xcall empy16s
	movw R30,R16
	ldi R24,<_dataI
	ldi R25,>_dataI
	add R30,R24
	adc R31,R25
	ldd R2,z+0
	ldd R3,z+1
	sts _TI+1,R3
	sts _TI,R2
	.dbline 33
;     temp=dataR[k+b]; 
	lds R2,_b
	lds R3,_b+1
	lds R18,_k
	lds R19,_k+1
	add R18,R2
	adc R19,R3
	ldi R16,2
	ldi R17,0
	xcall empy16s
	movw R30,R16
	ldi R24,<_dataR
	ldi R25,>_dataR
	add R30,R24
	adc R31,R25
	ldd R2,z+0
	ldd R3,z+1
	sts _temp+1,R3
	sts _temp,R2
	.dbline 34
;     dataR[k]=dataR[k]+dataR[k+b]*cos(2*PI*p/16)+dataI[k+b]*sin(2*PI*p/16);
	ldi R16,<L3
	ldi R17,>L3
	xcall lpm32
	st -y,R19
	st -y,R18
	st -y,R17
	st -y,R16
	lds R16,_p
	lds R17,_p+1
	xcall int2fp
	st -y,R19
	st -y,R18
	st -y,R17
	st -y,R16
	xcall empy32fs
	ldi R16,<L4
	ldi R17,>L4
	xcall lpm32
	st -y,R19
	st -y,R18
	st -y,R17
	st -y,R16
	xcall div32f
	xcall _cos
	movw R2,R16
	movw R4,R18
	ldi R16,<L3
	ldi R17,>L3
	xcall lpm32
	st -y,R19
	st -y,R18
	st -y,R17
	st -y,R16
	lds R16,_p
	lds R17,_p+1
	xcall int2fp
	st -y,R19
	st -y,R18
	st -y,R17
	st -y,R16
	xcall empy32fs
	ldi R16,<L4
	ldi R17,>L4
	xcall lpm32
	st -y,R19
	st -y,R18
	st -y,R17
	st -y,R16
	xcall div32f
	push R2
	push R3
	push R4
	push R5
	xcall _sin
	pop R5
	pop R4
	pop R3
	pop R2
	movw R6,R16
	movw R8,R18
	lds R18,_k
	lds R19,_k+1
	ldi R16,2
	ldi R17,0
	xcall empy16s
	ldi R24,<_dataR
	ldi R25,>_dataR
	movw R30,R16
	add R30,R24
	adc R31,R25
	movw R24,R30
	ldd R16,z+0
	ldd R17,z+1
	xcall int2fp
	st -y,R19
	st -y,R18
	st -y,R17
	st -y,R16
	lds R30,_b
	lds R31,_b+1
	lds R18,_k
	lds R19,_k+1
	add R18,R30
	adc R19,R31
	ldi R16,2
	ldi R17,0
	xcall empy16s
	movw R30,R16
	ldi R26,<_dataR
	ldi R27,>_dataR
	add R30,R26
	adc R31,R27
	ldd R16,z+0
	ldd R17,z+1
	xcall int2fp
	st -y,R19
	st -y,R18
	st -y,R17
	st -y,R16
	st -y,R5
	st -y,R4
	st -y,R3
	st -y,R2
	xcall empy32fs
	xcall add32fs
	lds R2,_b
	lds R3,_b+1
	lds R18,_k
	lds R19,_k+1
	add R18,R2
	adc R19,R3
	ldi R16,2
	ldi R17,0
	xcall empy16s
	movw R30,R16
	ldi R26,<_dataI
	ldi R27,>_dataI
	add R30,R26
	adc R31,R27
	ldd R16,z+0
	ldd R17,z+1
	xcall int2fp
	st -y,R19
	st -y,R18
	st -y,R17
	st -y,R16
	st -y,R9
	st -y,R8
	st -y,R7
	st -y,R6
	xcall empy32fs
	xcall add32f
	xcall fp2int
	movw R30,R24
	std z+1,R17
	std z+0,R16
	.dbline 35
;     dataI[k]=dataI[k]-dataR[k+b]*sin(2*PI*p/16)+dataI[k+b]*cos(2*PI*p/16);
	ldi R16,<L3
	ldi R17,>L3
	xcall lpm32
	st -y,R19
	st -y,R18
	st -y,R17
	st -y,R16
	lds R16,_p
	lds R17,_p+1
	xcall int2fp
	st -y,R19
	st -y,R18
	st -y,R17
	st -y,R16
	xcall empy32fs
	ldi R16,<L4
	ldi R17,>L4
	xcall lpm32
	st -y,R19
	st -y,R18
	st -y,R17
	st -y,R16
	xcall div32f
	xcall _sin
	movw R2,R16
	movw R4,R18
	ldi R16,<L3
	ldi R17,>L3
	xcall lpm32
	st -y,R19
	st -y,R18
	st -y,R17
	st -y,R16
	lds R16,_p
	lds R17,_p+1
	xcall int2fp
	st -y,R19
	st -y,R18
	st -y,R17
	st -y,R16
	xcall empy32fs
	ldi R16,<L4
	ldi R17,>L4
	xcall lpm32
	st -y,R19
	st -y,R18
	st -y,R17
	st -y,R16
	xcall div32f
	push R2
	push R3
	push R4
	push R5
	xcall _cos
	pop R5
	pop R4
	pop R3
	pop R2
	movw R6,R16
	movw R8,R18
	lds R18,_k
	lds R19,_k+1
	ldi R16,2
	ldi R17,0
	xcall empy16s
	ldi R24,<_dataI
	ldi R25,>_dataI
	movw R30,R16
	add R30,R24
	adc R31,R25
	movw R24,R30
	ldd R16,z+0
	ldd R17,z+1
	xcall int2fp
	st -y,R19
	st -y,R18
	st -y,R17
	st -y,R16
	lds R30,_b
	lds R31,_b+1
	lds R18,_k
	lds R19,_k+1
	add R18,R30
	adc R19,R31
	ldi R16,2
	ldi R17,0
	xcall empy16s
	movw R30,R16
	ldi R26,<_dataR
	ldi R27,>_dataR
	add R30,R26
	adc R31,R27
	ldd R16,z+0
	ldd R17,z+1
	xcall int2fp
	st -y,R19
	st -y,R18
	st -y,R17
	st -y,R16
	st -y,R5
	st -y,R4
	st -y,R3
	st -y,R2
	xcall empy32fs
	xcall sub32fs
	lds R2,_b
	lds R3,_b+1
	lds R18,_k
	lds R19,_k+1
	add R18,R2
	adc R19,R3
	ldi R16,2
	ldi R17,0
	xcall empy16s
	movw R30,R16
	ldi R26,<_dataI
	ldi R27,>_dataI
	add R30,R26
	adc R31,R27
	ldd R16,z+0
	ldd R17,z+1
	xcall int2fp
	st -y,R19
	st -y,R18
	st -y,R17
	st -y,R16
	st -y,R9
	st -y,R8
	st -y,R7
	st -y,R6
	xcall empy32fs
	xcall add32f
	xcall fp2int
	movw R30,R24
	std z+1,R17
	std z+0,R16
	.dbline 36
;     dataR[k+b]=TR-dataR[k+b]*cos(2*PI*p/16)-dataI[k+b]*sin(2*PI*p/16);
	ldi R16,<L3
	ldi R17,>L3
	xcall lpm32
	st -y,R19
	st -y,R18
	st -y,R17
	st -y,R16
	lds R16,_p
	lds R17,_p+1
	xcall int2fp
	st -y,R19
	st -y,R18
	st -y,R17
	st -y,R16
	xcall empy32fs
	ldi R16,<L4
	ldi R17,>L4
	xcall lpm32
	st -y,R19
	st -y,R18
	st -y,R17
	st -y,R16
	xcall div32f
	xcall _cos
	movw R2,R16
	movw R4,R18
	ldi R16,<L3
	ldi R17,>L3
	xcall lpm32
	st -y,R19
	st -y,R18
	st -y,R17
	st -y,R16
	lds R16,_p
	lds R17,_p+1
	xcall int2fp
	st -y,R19
	st -y,R18
	st -y,R17
	st -y,R16
	xcall empy32fs
	ldi R16,<L4
	ldi R17,>L4
	xcall lpm32
	st -y,R19
	st -y,R18
	st -y,R17
	st -y,R16
	xcall div32f
	push R2
	push R3
	push R4
	push R5
	xcall _sin
	pop R5
	pop R4
	pop R3
	pop R2
	movw R6,R16
	movw R8,R18
	lds R24,_b
	lds R25,_b+1
	lds R18,_k
	lds R19,_k+1
	add R18,R24
	adc R19,R25
	ldi R16,2
	ldi R17,0
	xcall empy16s
	movw R24,R16
	ldi R30,<_dataR
	ldi R31,>_dataR
	add R24,R30
	adc R25,R31
	ldi R16,<L5
	ldi R17,>L5
	xcall lpm32
	st -y,R19
	st -y,R18
	st -y,R17
	st -y,R16
	lds R16,_TR
	lds R17,_TR+1
	lsr R17
	ror R16
	xcall int2fp
	st -y,R19
	st -y,R18
	st -y,R17
	st -y,R16
	xcall empy32fs
	lds R16,_TR
	lds R17,_TR+1
	andi R16,1
	andi R17,0
	xcall int2fp
	st -y,R19
	st -y,R18
	st -y,R17
	st -y,R16
	xcall add32fs
	movw R30,R24
	ldd R16,z+0
	ldd R17,z+1
	xcall int2fp
	st -y,R19
	st -y,R18
	st -y,R17
	st -y,R16
	st -y,R5
	st -y,R4
	st -y,R3
	st -y,R2
	xcall empy32fs
	xcall sub32fs
	lds R2,_b
	lds R3,_b+1
	lds R18,_k
	lds R19,_k+1
	add R18,R2
	adc R19,R3
	ldi R16,2
	ldi R17,0
	xcall empy16s
	movw R30,R16
	ldi R26,<_dataI
	ldi R27,>_dataI
	add R30,R26
	adc R31,R27
	ldd R16,z+0
	ldd R17,z+1
	xcall int2fp
	st -y,R19
	st -y,R18
	st -y,R17

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -