挺好的,一个简单而非常合适的DSP的指令方式程序 ,结合注解的。
T .set 00EH
BRC .set 01AH
SWWSR .set 028H
CLKMD .set 058H
DAT0 .set 000H
DAT1 .set 001H
DAT2 .set 002H
DAT3 .set 003H
DDAT0 .set 02104H
DDAT1 .set 02105H
DDAT2 .set 02106H
DDAT3 .set 02107H
PDAT0 .set 01f00H
PDAT1 .set 01f01H
PDAT2 .set 01f02H
PDAT3 .set 01f03H
.def _main
.def _c_int00
.def _DELAY
.text
_c_int00:
RPT #1000H
NOP
LD #40H,DP
STM #4000H ,SP
ADDM #7FFH,*(SP)
ANDM #0FFFEH,*(SP)
SSBX INTM ;禁止中断
STM #07FFFH,SWWSR ;置外部等待时间
STM #06004H,CLKMD
LD #0FFFFH,A
CALL _DELAY
STM #087FBH,CLKMD
LD #0FFFFH,A
CALL _DELAY
B _main
_main:
RSBX CPL
NOP
NOP
LD #1234h,A ;立即数寻址
ST #5678h,*(DDAT1)
NOP
NOP
NOP
LD #PDAT1,A ;累加器寻址
READA DAT2
NOP
NOP
NOP
ST #3210h,DAT3 ;直接寻址(DP指针)
NOP
NOP
NOP
SSBX CPL
NOP
NOP
NOP
ST #9876h,DAT3 ;直接寻址(SP指针)
NOP
NOP
NOP
RSBX CPL
NOP
NOP
NOP
STM #DDAT3,AR0 ;间接寻址
ST #9876h,*AR0
NOP
NOP
NOP
MVDK DAT0,DDAT0 ;绝对地址(dmad)寻址
MVKD DDAT1,DAT1
NOP
NOP
NOP
MVDP DAT0,PDAT0 ;绝对地址(pmad)寻址
MVDP DAT1,PDAT1
NOP
NOP
NOP
STM #8888h,T ;存储器映射寄存器寻址
NOP
NOP
NOP
PSHM T ;堆栈寻址
POPM T
NOP
NOP
NOP
STM #4000h,AR0 ;程序存储器到数据存储器的复制
RPT #0xff
MVPD 1000H,*AR0+
NOP
NOP
NOP
STM #DDAT2,AR2
STM #DDAT3,AR2
SSBX FRCT
SSBX OVM
NOP
NOP
MVDD *AR2+,*AR3+
NOP
NOP ;双操作数寻址
MAC *AR2+,*AR3+,A
NOP
NOP
NOP
RSBX FRCT
RSBX OVM
NOP
NOP
SSBX CPL
B $
_DELAY: STLM A,BRC
RPTB _DELAY1-1
NOP
NOP
NOP
NOP
_DELAY1:RET
.end |