📄 mmul.asm
字号:
;***********************************************************
; Version 2.20.01
;***********************************************************
;****************************************************************
; Function: mmul
; Description: matrix multiply implementation
;
; Copyright Texas instruments Inc, 1998
;----------------------------------------------------------------
; Revision History:
; 1.00, A. Aboagye, 8/31/98 - Original release. Started from
; summer coop code
;****************************************************************
.mmregs
.if __far_mode
OFFSET .set 1
.else
OFFSET .set 0
.endif
.text
.def _mmul
_mmul:
PSHM AR1
PSHM AR6
PSHM AR7
PSHM ST0 ; 1 cycle
PSHM ST1 ; 1 cycle
RSBX OVA ; 1 cycle
RSBX OVB ; 1 cycle
FRAME -1
SSBX FRCT
SSBX SXM
STLM A,AR2 ; AR2 -> input1 matrix
STL A,*SP(0) ; SP(0) = input1 matrix ptr
; Verify that the dimensions of the input matrices are legal, i.e. input1
; row size = input2 column size; else return input1 as output
LD *SP(8+OFFSET), A
SUB *SP(10+OFFSET), A
BC mulend,ANEQ
LD *SP(0),A
; Set up for multiplication
; Init mul1 loop counter (BRC = # of rows in input1 - 1),
; which counts the # of output rows computed
MVDK *SP(0),AR2 ; AR2 -> input1 col size
LD *SP(7+OFFSET),A
SUB #1,A
STLM A,BRC
; Init mul2 loop counter (SP(11+OFFSET) = input2 row size),
; which counts the # of elements computed in an output row
MVDK *SP(11+OFFSET),AR0 ; AR0 -> # cols in input2
LD *SP(11+OFFSET), A
SUB #1, A
STL A, *SP(11+OFFSET)
; Init mul3 loop counter (SP(8+OFFSET) = input1 row size - 1),
; which counts the # of products formed in a row-by-column multiply
LD *SP(8+OFFSET),A
LD A,B
SUB #1,A
STL A,*SP(8+OFFSET)
; Set ar4 = (SP(12+OFFSET) = ptr to output)
MVDK *SP(12+OFFSET), AR1
MVDK *SP(9+OFFSET), AR3 ; AR3 -> input 2
RPTB mul1end
; Matrix multiplication using 3 nested loops
mul1
LD *SP(11+OFFSET), A
STLM A, AR6 ; AR6 -> SP(5+OFFSET)
mul2 MVMM AR2, AR4
MVMM AR3, AR5
LD *SP(8+OFFSET), A
STLM A, AR7 ; AR7 -> SP(2+OFFSET)
LD #0, A
mul3 MAC *AR4+,*AR5,A,A
MAR *AR5+0
BANZ mul3,*AR7-
mul3end STH A,*AR1+ ; store output element
MAR *AR3+
BANZ mul2, *AR6-
mul2end
LDM AR2, A
ADD B, A
STLM A, AR2
MVDK *SP(9+OFFSET), AR3 ; AR3 -> input 2
mul1end NOP
mulend FRAME 1
LD #0, A ; 1 cycle
XC 1, AOV ; 1 cycle
LD #1, A ; 1 cycle
POPM ST1
POPM ST0
POPM AR7
POPM AR6
POPM AR1
.if __far_mode
FRETD
.else
RETD
.endif
NOP
NOP
;end of file. please do not remove. it is left here to ensure that no lines of code are removed by any editor
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -