资源描述:
《DSP算术运算程序及程序说明》由会员上传分享,免费在线阅读,更多相关内容在教育资源-天天文库。
1、DSP算术运算程序及程序说明.title"fortestADD,SUB,MPY...program...".mmregs.global_c_int00VAL1.set012h;18VAL2.set034h;52VAL3.set04000h;0.5VAL4.set02000h;0.25(fraction)&8192(integer)VAL5.set04ab8h;0.58374VAL6.set0ffeeh;-18VAL7.set0b548h;-0.58374.bsstemp,1;addressof0x080.bsstemp1,1;
2、addressof0x081.bsstemp2,1;addressof0x082.bsstemp3,1;addressof0x083.bsstemp4,1;addressof0x084.bsstemp5,1;addressof0x085.bsstemp6,1;addressof0x086.bsstemp7,1;addressof0x087;resultregister.bssadd_result,1;addressof0x088.bsssub_result,1;addressof0x089.bssmpy_i_h,1;addre
3、ssof0x08a.bssmpy_i_l,1;addressof0x08b.bssmpy_f,1;addressof0x08c.bssquot_i,1;addressof0x08d.bssremain_i,1;addressof0x08e.bssquot_f,1;addressof0x08f.text_c_int00:ld#temp,DP;loadDPoftemp1st#VAL1,temp1st#VAL2,temp2;inittemp1&temp2,18+52=70(0x46);--------testADD---------
4、------------------加法ldtemp1,a;loadtemp1->a//把变量temp1加载给寄存器Aaddtemp2,a;a+temp2->a//将变量temp2与寄存器A相加,结果放入A中stla,add_result;savea(low16bits)->add_result//将结果(低16位)存入变量add_result中。nop;setbreakpoint//设置断点st#VAL6,temp3//将#VLA6赋值temp3st#VAL1,temp4//将#VLA6赋值temp3inittemp3&te
5、mp4,(-18)-18=-36(0x0ffdc);--------testSUB---------------------------减法stm#temp3,ar2;addressoftemp3->ar2//将变量temp3的地址装入ar2寄存器stm#temp4,ar3;addressoftemp4->ar3//将变量temp4的地址装入ar3寄存器sub*ar2+,*ar3,b;(temp3<<16)-(temp4<<16)->b,ar2++//变量temp3和变量temp4分别同时左移16位,再相减,结果存到b寄存器中
6、,寄存器ar2的地址加1sthb,sub_result;resultinsub_result//将相减的结果(高16位)存入变量sub_resultnop;setbreakpoint//设置断点st#VAL1,temp1//将#VAL1赋值temp1st#VAL2,temp2//将#V2LA赋值temp2inittemp1&temp2,18*52=936(0x3a8);--------testMPY(integer)-----------------整数乘法rsbxFRCT;prepareforintegermpy//清FRC
7、T标志,准备整数乘ldtemp1,T;temp1->T//将变量temp1装入T寄存器mpytemp2,a;temp1*temp2->A(resultis32bit)//变量temp1与temp2相乘,结果装入A寄存器(结果是32位)stha,mpy_i_h;thehigh16bitinmpy_i_h//将寄存器A的高16位(结果)放入变量mpy_i_h中stla,mpy_i_l;thelow16bitinmpy_i_l//将寄存器A的低16位(结果)放入变量mpy_i_l中nop;setbreakpoint//设置断点st#
8、VAL3,temp3//将#VAL3赋值temp3st#VAL7,temp4//将#VAL7赋值temp4inittemp3&temp4,0.5*(-0.58374)=-0.29187(0x0daa4);--------testMPY(fraction)-----------