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

📄 dot_n.asm

📁 TI DSP常用例程
💻 ASM
字号:
;
;   dot_n.asm
;
;   calculates dot product of two n vectors
;
;   float   dot_n();
;
;   float   *a;
;   float   *b;
;   float    c;
;   int      n;
;
;   c = dot_4( a, b, n );
;
;
;      James M. Patterson
;      Texas Instruments
;      370 South North Lake Boulevard
;      Altamonte Springs, Florida 32701
;
;
	.global _dot_n
	.text

_dot_n:

;
;   first, set up address pointers
;
;   AR0 points to A vector
;   AR1 points to B vector
;   dot product returned in R0
;

	ldi	ST, R0		    ;save status register
	and	~2000h, ST	    ;clear GIE bit
	pop	AR0		    ;bump stack pointer
	pop	AR0		    ;get A address
	pop	AR1		    ;get B address
	pop	R2		    ;get vector length
	addi	4, SP		    ;restore SP
	ldi	R0, ST		    ;restore status register

;
;   do calculation
;

	subi	1, R2		    ;set R2 to n - 1
	ldf	0.0, R0
	ldf	0.0, R3 	    ;initialize R0, R3

	rpts	R2		    ;repeat n times

	mpyf3	*AR0++, *AR1++, R0  ;product goes into R0
    ||	addf3	R0, R3, R3	    ;summation goes to R3

	addf	R3, R0		    ;complete summation of dot product

	rets			    ;the end

	.end

⌨️ 快捷键说明

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