/* This C language subroutine computes the product of two matricies. s z(i,j) = SUMMATION[x(i,k)*y(k,j)] k=1 with i= 1 to r, and j=1 to t The Run Time Library for the C Language. Gordon A. Sterling (617) 461 - 3076 DSP Development Tools Engineering Created on 5/25/90 Updated on 5/94 by AS Updated on 1/95 by AS - separated polymorphic functions #include
float matmul(float z[][], float x[][], float y[][], int r, int s ,int t); */ #include "lib_glob.h" #include "mat_glob.h" .SEGMENT/CODE Code_Space_Name; .FILE RTL_FILENAME; .GLOBAL ___matmulPDP; ___matmulPDP: matmul_core: R2=dma_i; put(R2); R2=dmb_i; put(R2); R2=pma_i; put(R2); R2=pmb_i; put(R2); put(R5); put(R6); put(R7); put(R13); put(R14); put(R15); readparam4(R6); readparam5(R5); readparam6(R7); R13=PASS R12, R12=R4; R14=PASS R8, R2=R4; pmdmpm_mul: dm_lnt=R5; pm_mdf=R7; R15=PASS R13, pmb_i=R12; /* Point to Z and start of Y */ LCNTR=R6, DO pmdmpm_row UNTIL LCE;/* Loop for each outrow */ dm_bse=R14; /* Point to X row */ LCNTR=R7, DO pmdmpm_column UNTIL LCE;/* Loop for each outcol*/ R12=R12-R12, pma_i=R15; /* Point to place in Y */ R8=R8-R8, F0=DM(dm_ptr, 1); /* Read first X */ R6=R5-1, F4=PM(pma_i, pm_mdf); /* Read first Y */ LCNTR=R6, DO pmdmpm_element UNTIL LCE; F8=F0*F4, F12=F8+F12, F0=DM(dm_ptr, dm_1); pmdmpm_element: F4=PM(pma_i, pm_mdf); F8=F0*F4, F12=F8+F12; /* Compute final mult */ F12=F8+F12; /* Compute final sum */ pmdmpm_column: R15=R15+1, PM(pmb_i,1)=F12; /* Advance Y ptr */ pmdmpm_row: R14=R14+R5, R15=R13; /* Point to next X, start of y */ R0=PASS R2, dm_lnt=dm_0; /* Set return value */ restore_state: FETCH_RETURN get(R15,1); get(R14,2); get(R13,3); get(R7,4); get(R6,5); get(R5,6); get(pmb_i,7); get(pma_i,8); get(dmb_i,9); get(dma_i,10); RETURN (DB); RESTORE_STACK RESTORE_FRAME .ENDSEG;