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

📄 matrixbymatrix.asm

📁 adsp2116x的矩阵乘运算
💻 ASM
字号:
/**************************************************************

File Name:		matrixbymatrix.asm

Based on: 		mxnxnxo.asm 4/25/91 SC	

Date Modified:	2/18/00 GGL modified for SIMD
				6/6/00	GGL	modified so that SIMD is enabled in
							matrixbyvector.asm instead of matrix_test.asm
				6/7/00	GGL verified on 0.1 Si; won't work in 0.0


Purpose:	Multiplication of a (MxN) matrix by a (NxP) matrix equals a (MxP) matrix

Calling Parameters:
			b0,i0 = address matrix A
			l0 = length of matrix A
			b1,i1 = address of matrix C
			b8,i8 = address of matrix B
			l8 = length of matrix B
			r15 = columns in Matrix A
			r14 = (rows in Matrix A or columns in Matrix B)/2
			r6 = rows in Matrix A and columns in Matrix B
			r7 = rows in Matrix B;
			m0 = 1
			m1,m9 = 2
			r5 = holds starting pointer i0

Assumptions:
			All arrays must start on even address boundaries.
			
Return Values:
			i8 = mat_c 

Registers Affected:
			f0,s0,f4,s4,f8,r5,s5,s8,f12,s12
			i0,i1,i8,

Cycle Count:
			M * {[P * (N/2 + 4)] + 3} + 5 + 3 cache misses 

Number of PM Locations:
			18 instrucation locations
			mat_b buffer
						
Number of DM Locations:
			mat_a buffer
			mat_c buffer

Notes:		Matrix A and matrix C are stored in row major order. 
			Matrix B is stored in column major order.
			N and M must be even numbers.  Matrix arrays 
			must be of even length (zero pad if necessary.) 	
			The last value in the output matrix is a dummy value. 

Silicon Revision Issue:
			This code will not function properly on silicon revision 0.0 
			due to an anomaly related to internal addressing in SIMD mode.
			For more information please refer to the anomaly list.

Circular Buffering Issue:
			Because SIMD or Long word access transfer two 32-bit words, programs
			must be careful when using these accesses in circular buffering.
			It is important that SIMD or Long word accesses do not cross a circular
		 	buffer boundary.  If a SIMD	mode access occurs using a circular buffer
			index register that points to the last location in the circular buffer
		 	(end of buffer), the resulting access transfers the last location in
		 	the circular buffer and the	first location outside the buffer (end of buffer + 1).


**************************************************************/


#include    "def21160.h"

.EXTERN mxnxnxp;

/* Program memory code */
.section/PM seg_pmco;

mxnxnxp:bit set MODE1 PEYEN | CBUFEN; /* enable SIMD mode, circular buffers */
lcntr=R15, do matrix until lce;		
		lcntr=r7, do column until lce;	
		r5=i0;	/*store i0 in r5*/
			lcntr=R14, do row until lce;	/*N/2 times*/
row:			f12=f0*f4, f8=f8+f12, f0=dm(i0,m1), f4=pm(i8,m9);  /*calc mat_A * mat_B,accumulate,read mat_A and mat_B */
		f12=f0*f4, f8=f8+f12;	/*multiply, accumulate*/
		f8=f8+f12;	/*final accumulate*/
		r4=r4 xor r4, r9<->s8; /*move Pey to Pex*/
		f8=f8+f9, r0=r4;	/*add values for result*/
		r8=r8 xor r8, dm(i1,m0)=r8;	/*clear r8, save values in mat_c */			
column:		r12=r12 xor r12, i0=r5; /*clear f12, restore i0 with r5*/
		r5=r5+r6;	/*accumulate r5 by N for next row of matrix B*/
matrix:	i0=r5;	/* loads i0 with a value which points to the next row for matrix B*/
		rts(db);
		bit clr mode1 PEYEN | CBUFEN;	/*disable SIMD and circular buffers*/
		dm(i1,m0)=0;	/*the last value in the buffer is a dummy value and here it is cleared*/
		


⌨️ 快捷键说明

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