	page 132,66,0,6
;********************************************
;Motorola Austin DSP Operation  June 30, 1988
;********************************************
;DSP96001/2
;Matrix Multiply, [3x3] times [3x1]
;File name: 9-96
;**************************************************************************
;	Maximum execution time:  1.185 us at 27.0MHz
;	Memory Size: Prog: 16 words ; Data: 12 words (if b and c occupy the 
;                                                    same space)
;	Number of clock cycles:	  32 (16 instruction cycles)
;	Clock Frequency:	27.0 MHz
;	Cycle time:		74.1 ns
;**************************************************************************
;       This routine computes the product of a [3x3] matrix and a
;       [3x1] column vector for the dsp 96000. 
;       
;       Matrix a is in X memory, 
;       vector b is in Y memory, 
;       the resulting vector c is stored in Y memory. 
;
;       All matrices are in "row major" format.
;
;**************************************************************************
;
;    X Memory         Y Memory
;
; |->| a33 |          |     |
; |  | a32 |          |     |
; |  | a31 |      |-->| b3  |
; |  | a23 |      |   | b2  |
; |  | a22 |      |-->| b1  |
; |  | a21 |      r4  |     |
; |  | a13 |          |     |
; |  | a12 |           
; |->| a11 |      |-->| c3  |
; r0 |     |      |   | c2  |
;    |     |      |-->| c1  |
;                 r5
;
;Note: the previous assumes that all immediate addressing is
;immediate short, i.e. all data is in internal memory.
;
mata    equ     $100
vecb    equ     $100
vecc    equ     $200

        org     x:mata
        dc      $700000
        dc      $600000
        dc      $500000
        dc      $400000
        dc      $300000
        dc      $200000
        dc      $100000
        dc      $0F0000
        dc      $0E0000

        org     y:vecb
        dc      $0C0000
        dc      $0B0000
        dc      $0A0000

        org     p:$40

;**************************************************************************
;
    move #mata,r0                                     ;point to matrix a
    move #vecb,r4                                     ;point to vector b
    move #2,m4                                        ;address b modulo 3
    move #vecc,r5                                     ;point to vector c
    fmove                     x:(r0)+,d4   y:(r4)+,d5  
    fmpy d4,d5,d3             x:(r0)+,d4   y:(r4)+,d5 ;a11*b1
    fmpy d4,d5,d0             x:(r0)+,d4   y:(r4)+,d5 ;a12*b2
    fmpy d4,d5,d3 fadd d3,d0  x:(r0)+,d4   y:(r4)+,d5 ;a13*b3,a11*b1+a12*b2->I
    fmpy d4,d5,d3 faddr d3,d0 x:(r0)+,d4   y:(r4)+,d5 ;a21*b1,I+a13*b3->c1
    fmpy d4,d5,d1             x:(r0)+,d4   y:(r4)+,d5 ;a22*b2
    fmpy d4,d5,d3 fadd d3,d1  x:(r0)+,d4   y:(r4)+,d5 ;a23*b3,a21*b1+a22*b2->I
    fmpy d4,d5,d3 faddr d3,d1 x:(r0)+,d4   y:(r4)+,d5 ;a31*b1,I+a23*b3->c2
    fmpy d4,d5,d2             x:(r0)+,d4   y:(r4)+,d5 ;a32*b2
    fmpy d4,d5,d3 fadd d3,d2               d0,y:(r5)+ ;a33*b3,a31*b1+a32*b2->I
                  faddr d3,d2              d1,y:(r5)+ ;I+a33*b3->c3
    fmove                                  d2,y:(r5)+ ;Last 3 instr. save res.
;**************************************************************************
    end



