📄 dot4.asm
字号:
;
; dot_4.asm
;
; calculates dot product of two 4-vectors
;
; float dot_4();
;
; float a[4];
; float b[4];
; float c;
;
; c = dot_4( a, b );
;
;
; James M. Patterson
; Texas Instruments
; 370 South North Lake Boulevard
; Altamonte Springs, Florida 32701
;
;
.global _dot_4
.text
_dot_4:
;
; 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
addi 3, SP ;restore SP
ldi R0, ST ;restore status register
;
; do calculation
;
mpyf3 *AR0++, *AR1++, R0 ;a[0] * b[0] -> R0
mpyf3 *AR0++, *AR1++, R1 ;a[1] * b[1] -> R1
mpyf3 *AR0++, *AR1++, R0 ;a[2] * b[2] -> R0
|| addf3 R0, R1, R3 ;(a[0]*b[0]) + (a[1]*b[1]) -> R3
mpyf3 *AR0, *AR1, R0 ;a[3] * b[3] -> R0
|| addf3 R0, R3, R3 ;a[0]*b[0]+a[1]*b[1]+a[2]*b[2] ->R3
addf R3, R0 ;complete summation of dot product
rets ;the end
.end
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -