dotp4clasmfunc.sa

来自「DSP的C程序源代码」· SA 代码 · 共 16 行

SA
16
字号
;Dotp4clasmfunc.sa  Linear assembly function to multiply two arrays
		     .ref	  _dotp4clasmfunc ;ASM func called from C
_dotp4clasmfunc: .cproc	  ap,bp,count     ;start section linear asm
	           .reg	  a,b,prod,sum    ;asm optimizer directive

	     	     zero  	  sum   	      ;init sum of products	
loop:	     	     ldh   	  *ap++,a         ;pointer to 1st array->a  
	           ldh   	  *bp++,b	      ;pointer to 2nd array->b 	
	           mpy   	  a,b,prod        ;product= a*b   
                 add   	  prod,sum,sum    ;sum of products-->sum    
	           sub   	  count,1,count   ;decrement counter  
  [count]        b     	  loop            ;loop back if count # 0
	
		     .return  sum		      ;return sum as result
		     .endproc 	            ;end linear asm function
				

⌨️ 快捷键说明

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