Motorola DSP96002 User Manual
Page 717
B-198
DSP96002 USER’S MANUAL
MOTOROLA
move d0.d,l:ieee_out ;output as dp ieee number
move (r2)-n2 ;delete last sample
jmp _loop
;
NxN by NxN Matrix Multiplication Example
;
; Multiply Two Matrices: AB = C
;
; ***NOTE: All numbers are assumed to be in DPLIB format.
;
org x:0
order equ 3 ;Nth order system
elements equ order*order
a ds 4*elements ;matrix A stored starting at x:$00
org x:64
b ds 4*elements ;matrix B stored starting at x:$40
org x:128
c ds 4*elements ;matrix C stored starting at x:$80
;
org p:$100
start move #a,r2 ;r2 points to matrix A elements
move #b,r1 ;r1 points to matrix B elements
move #c,r0 ;r0 points to matrix C (the result)
move #4,n0 ;offset for 4 word numbers
move #order*4,n1 ;offset for one row
move #4,n2 ;offset for 4 word numbers
move #(elements-order+1)*4,n3
move #(order+1)*4,n4
move n1,n5
move #(elements*4)-1,m0
move #(elements*4)-1,m1
move #(elements*4)-1,m2
;
3x3mult do #order,rows ;calculate each row of the result
do #order,columns ;calculate each column of the result
jsr dp_mpy ;multiply the first row-column elements
move (r1)+n1 ;update B offset for next column element
move (r2)+n2 ;update A offset for next row element
jsr dp_mac ;accumulate the inner products
move (r1)+n1 ;update B offset for next column element
move (r2)+n2 ;update A offset for next row element
jsr dp_mac ;accumulate the inner products
move n3,n2 ;update A offset to return to column 1
move n4,n1 ;update B offset for next column
move (r0)+n0 ;update result matrix pointer
move (r1)+n1 ;point to a row 1 element
move (r2)+n2 ;point to a column 1 element
move n0,n2 ;restore A offset
move n5,n1 ;restore B offset
columns move n1,n2 ;update A offset for row shift
move #b,r1 ;point to B column 1
move (r2)+n2 ;point to the next A row
move n0,n2 ;restore A offset
rows stop ;resultant matrix finished
include "dplib"
end