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

📄 mat_matn.asm

📁 DSP程序TI常用例程MatRix,可以参考使用
💻 ASM
字号:
;
;   calculates c = a x b
;   where:  a is m x n
;	    b is n x k
;
;   calling from c:
;
;   float   a[m][n];
;   float   b[n][k];
;   float   c[m][k];
;
;   int     m;
;   int     n;
;   int     k;
;
;   void    mat_matn( m, n, k, c, a, b )
;
;      James M. Patterson
;      Texas Instruments
;      370 South North Lake Boulevard
;      Altamonte Springs, Florida 32701
;
;
	    .text

	    .global _mat_matn
FP	    .set    AR3 	;use AR3 as a frame pointer


_mat_matn:
	    ;	first, save some  registers
	    ;
	    push    FP		    ;save fp
	    ldi     SP, FP	    ;set FP to TOS

	    push    AR7 	    ;save the other ARs
	    push    AR6
	    push    AR5
	    push    AR4

	    ldi     *-FP(2), AR4    ;get m ( rows in a )
	    ldi     *-FP(3), IR1    ;get n ( columns in a, rows in b)
	    ldi     *-FP(4), IR0    ;get k ( columns in b )
	    ldi     *-FP(5), AR2    ;get address of c array
	    ldi     *-FP(6), AR1    ;get address of b array
	    ldi     *-FP(7), AR0    ;get address of a

	    ldi     IR0, AR3	;AR3 counts number of b columns

	    ldi     AR3, AR5	;calculate size of b
	    mpyi    IR1, AR5
	    nop     *AR5--
	    ldi     IR1, AR6	;set up AR6 to use as a counter
	    ldi     AR1, AR7	;save b address
	    nop     *AR6--
	    nop     *AR3--
	    nop     *AR4--

next:	    ldf 0.0, R0
	    ldf R0, R3		;clear R0, R3

	    rpts    AR6 	;IR1 has number of a columns

	    mpyf3   *AR0++, *AR1++(IR0), R0
	||  addf3   R0, R3, R3

	    addf    R0, R3
	    dbud    AR3, next	;done all b columns?
	    stf     R3, *AR2++
	    nop     *AR0--(IR1) ;set AR0 back to start of row
	    subi    AR5, AR1	;move to next column of b

	    ; branch occurs here if taken

	    ldi     AR7, AR1	;point AR1 back to start of B
	    dbud    AR4, next	;done with all a rows?
	    ldi     IR0, AR3	;reset b column count
	    nop     *AR3--
	    nop     *AR0++(IR1) ;point to start of next A row

	    ;	branch occurs here if taken

	    pop     AR4 	;restore ARs
	    pop     AR5
	    pop     AR6
	    pop     AR7
	    pop     FP		;restore caller's FP

	    rets		;return

	    .end

⌨️ 快捷键说明

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