本帖最后由 jihanxiaogo 于 2015-4-20 10:20 编辑
我只有快压,我就直接复制吧fft.asm如下:
.mmregs
.global reset,start,sav_sin,sav_idx,sav_grp
.def start,_c_int00
.data
DATA .space 1024
.copy "mdata.inc"
N .set 128
LOGN .set 7
sav_grp .usect "tempv",3
sav_sin .set sav_grp+1
sav_idx .set sav_grp+2
OUTPUT .usect "OUTPUT",256
BOS .usect "stack",0Fh
TOS .usect "stack",1
.copy "twiddle1.inc"
.copy "twiddle2.inc"
.text
_c_int00
b start
nop
nop
start:
STM #TOS,SP
LD #0,DP
SSBX FRCT
STM #2*N,BK
STM #INPUT,AR3
STM #DATA,AR7
MVMM AR7,AR2
STM #N-1,BRC
RPTBD plend-1
STM #N,AR0
LDM AR3,A
READA *AR2+
ADD #1,A
READA *AR2+
MAR *AR3+0B
plend:
STM #0,BK
LD #-1,ASM
MVMM AR7,AR2
STM #DATA+2,AR3
STM #N/2-1,BRC
LD *AR2,16,A
RPTBD s1end-1
STM #3,AR0
SUB *AR3,16,A,B
ADD *AR3,16,A
STH A,ASM,*AR2+
ST B,*AR3+
||LD *AR2,A
SUB *AR3,16,A,B
ADD *AR3,16,A
STH A,ASM,*AR2+0
ST B,*AR3+0%
||LD *AR2,A
s1end:
MVMM AR7,AR2
STM #DATA+4,AR3
STM #N/4-1,BRC
LD *AR2,16,A
RPTBD s2end-1
STM #5,AR0
SUB *AR3,16,A,B
ADD *AR3,16,A
STH A,ASM,*AR2+
ST B,*AR3+
||LD *AR2,A
SUB *AR3,16,A,B
ADD *AR3,16,A
STH A,ASM,*AR2+
STH B,ASM,*AR3+
MAR *AR3+
ADD *AR2,*AR3,A
SUB *AR2,*AR3-,B
STH A,ASM,*AR2+
SUB *AR2,*AR3,A
ST B,*AR3
||LD *AR3+,B
ST A,*AR2
||ADD *AR2+0%,A
ST A,*AR3+0%
||LD *AR2,A
s2end:
STM #512,BK
ST #128,@sav_sin
STM #128,AR0
STM #TWI2,AR4
STM #TWI1,AR5
STM #-3+LOGN,AR7
ST #-1+N/8,@sav_grp
STM #3,AR6
ST #8,@sav_idx
stage:
STM #DATA,AR2
LD @sav_idx,A
ADD *(AR2),A
STLM A,AR3
MVDK @sav_grp,AR1
group:
MVMD AR6,BRC
RPTBD bend-1
LD *AR4,T
MPY *AR3+,A
MACR *AR5+0%,*AR3-,A
ADD *AR2,16,A,B
ST B,*AR2
||SUB *AR2+,B
ST B,*AR3
||MPY *AR3+,A
MASR *AR3,*AR4+0%,A
ADD *AR2,16,A,B
ST B,*AR3+
||SUB *AR2,B
LD *AR4,T
ST B,*AR2+
||MPY *AR3+,A
bend:
PSHM AR0
MVDK sav_idx,AR0
MAR *AR2+0
MAR *AR3+0
BANZD group,*AR1-
POPM AR0
MAR *AR3-
LD sav_idx,A
SUB #1,A,B
STLM B,AR6
STL A,1,sav_idx
LD sav_grp,A
STL A,ASM,sav_grp
LD sav_sin,A
STL A,ASM,sav_sin
BANZD stage,*AR7-
MVDK sav_sin,AR0
STM #DATA+2,AR2
STM #DATA+2*N-2,AR3
STM #DATA+2*N+3,AR7
STM #DATA+4*N-1,AR6
STM #-2+N/2,BRC
RPTBD p3end-1
STM #3,AR0
ADD *AR2,*AR3,A
SUB *AR2,*AR3,B
STH A,ASM,*AR2+
STH A,ASM,*AR3+
STH B,ASM,*AR6-
NEG B
STH B,ASM,*AR7-
ADD *AR2,*AR3,A
SUB *AR2,*AR3,B
STH A,ASM,*AR2+
STH A,ASM,*AR3-0
STH B,ASM,*AR6-
NEG B
STH B,ASM,*AR7+0
p3end:
ST #0,*AR6-
ST #0,*AR6
p3test:
STM #DATA,AR2
STM #DATA+1,AR4
STM #DATA+2*N+1,AR5
ADD *AR2,*AR4,A
SUB *AR2,*AR4,B
STH A,ASM,*AR2+
ST #0,*AR2
MVDD *AR2+,*AR5-
STH B,ASM,*AR5
STM #DATA+4*N-1,AR3
STM #TWI2+512/N,AR4
STM #TWI1+512/N,AR5
STM #N-2,BRC
RPTBD p4end-1
STM #512/N,AR0
LD *AR2+,16,A
MACR *AR4,*AR2,A
MASR *AR5,*AR3-,A
LD *AR3+,16,B
MASR *AR5+0%,*AR2-,B
MASR *AR4+0%,*AR3,B
STH A,ASM,*AR2+
STH B,ASM,*AR2+
NEG B
STH B,ASM,*AR3-
STH A,ASM,*AR3-
p4end:
power: STM #OUTPUT,AR3 ;AR3指向输出缓冲地址
STM #255,BRC ;块循环计数器设置为255
RPTBD power_end-1 ;带延迟方式的重复执行指令
STM #DATA,AR2 ;AR2指向AR[0]
SQUR *AR2+,A ;A := AR2
SQURA *AR2+,A ;A := AR2 + AI2
STH A,7,*AR3 ;将A中的数据存入输出缓冲中,
ANDM #7FFFH,*AR3+ ;避免输出数据过大在虚拟示波器中显示错误
power_end: B power_end
.end
fft.cmd如下:
/*fft.cmd*/
fft.obj
-m fft.map
-o fft.out
MEMORY
{
PAGE 0: ROM(RIX) : origin=8000h,length=1000h
ROM1 : origin=9000h,length=0200h
PAGE 1: B2A(RW) : origin=0060h,length=10h
B2B(RW) : origin=0070h,length=10h
INTRAM1(RW) : origin=0400h,length=0200h
INTRAM2(RW) : origin=0800h,length=0200h
INTRAM3(RW) : origin=1400h,length=0800h
OTHER : origin=2000h,length=800h
}
SECTIONS
{
.text : {}>ROM PAGE 0
INPUT : {}>ROM1 PAGE 0
.data : {}>INTRAM3 PAGE 1
twiddle1: {}>INTRAM1 PAGE 1
twiddle2: {}>INTRAM2 PAGE 1
tempv : {}>B2A PAGE 1
stack : {}>B2B PAGE 1
OUTPUT : {}>OTHER PAGE 1
.stack : {}>OTHER PAGE 1
}
|