/* 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 #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 ___matmulDPD; ___matmulDPD: 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; dmpmdm_mul: pm_lnt=R5; dm_mdf=R7; R15=PASS R13, dmb_i=R12; /* Point to Z and start of Y */ LCNTR=R6, DO dmpmdm_row UNTIL LCE;/* Loop for each outrow */ pm_bse=R14; /* Point to X row */ LCNTR=R7, DO dmpmdm_column UNTIL LCE;/* Loop for each outcol*/ R12=R12-R12, dma_i=R15; /* Point to place in Y */ R8=R8-R8, F0=PM(pm_ptr, 1); /* Read first X */ R6=R5-1, F4=DM(dma_i, dm_mdf); /* Read first Y */ LCNTR=R6, DO dmpmdm_element UNTIL LCE; F8=F0*F4, F12=F8+F12, F0=PM(pm_ptr, pm_1); dmpmdm_element: F4=DM(dma_i, dm_mdf); F8=F0*F4, F12=F8+F12; /* Compute final mult */ F12=F8+F12; /* Compute final sum */ dmpmdm_column: R15=R15+1, DM(dmb_i,1)=F12; /* Advance Y ptr */ dmpmdm_row: R14=R14+R5, R15=R13; /* Point to next X, start of y */ R0=PASS R2, pm_lnt=pm_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;