📄 mat_vecn.asm
字号:
;
; calculates c = a x b
; where: a is m x n
; b is n x 1
;
; calling from c:
;
; float a[m][n];
; float b[n];
; float c[n];
;
; int m;
; int n;
;
; void mat_vecn( m, n, c, a, b )
;
; James M. Patterson
; Texas Instruments
; 370 South North Lake Boulevard
; Altamonte Springs, Florida 32701
;
;
.text
.global _mat_vecn
FP .set AR3 ;use AR3 as a frame pointer
_mat_vecn:
push FP ;save caller's FP
ldi SP, FP ;set FP to TOS
push AR4 ;save AR4
ldi *-FP(2), AR4 ;get m ( rows in a )
ldi *-FP(3), IR0 ;get n ( length of b )
ldi *-FP(4), AR2 ;get address of c vector
ldi *-FP(5), AR0 ;get address of a matrix
ldi *-FP(6), AR1 ;get address of b vector
ldi IR0, R1
subi 1, R1 ;n - 1 to R1
nop *AR4-- ;decrement row counter
next: ldf 0.0, R0
ldf R0, R3 ;clear R0, R3
rpts R1 ;IR1 has number of a columns
mpyf3 *AR0++, *AR1++, R0
|| addf3 R0, R3, R3 ;calculate a c term
dbud AR4, next ;done with all a rows?
addf R0, R3 ;complete calculation of c term
stf R3, *AR2++ ;and store it
nop *AR1--(IR0) ;point AR1 back to start of B
; branch occurs here if taken
pop AR4
pop FP ;restore caller's FP
rets ;return
.end
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -