	page 132,66,0,6
        opt     rc
;*******************************************
;Motorola Austin DSP Operation  June 30,1988
;*******************************************
;DSP96001/2
;8 pole cascaded transpose IIR filter
;File name: 6-96.asm
;**************************************************************************
;	Maximum sample rate: 421.9 KHz at 27.0 MHz
;	Memory Size: Prog: 6+14 words ; Data :4*(2+5) words
;	Number of clock cycles:	64 (32 instruction cycles)
;	Clock Frequency:	27.0 MHz
;	Cycle time:		74.1 ns
;**************************************************************************
;	This IIR filter reads the input sample
;	from the memory location Y:input
;	and writes the filtered output sample
;	to the memory location Y:output
;
;	The samples are stored in the X memory
;	The coefficients are stored in the Y memory
;**************************************************************************
;
;	initialization
;**********************
nsec	equ	4
start	equ	$40
w1	equ 	0	;w1,...
w2	equ 	8	;w2,...
cddr	equ 	0	;b0,b1,a1,b2,a2
input	equ	$ffe0
output	equ	$ffe1
;
;The cascaded transpose IIR filter has a filter section:
;
;
;    x  --------------bi0---->(+)--------------------> y
;                |             ^            |
;                |             | w1         |
;                |            1/z           |
;                |             |            |
;                |----bi1---->(+)<---ai1----|
;                |             ^            |
;                |             | w2         |
;                |            1/z           |
;                |             |            |
;                |----bi2---->(+)<---ai2----|
;
;The filter equations are:
;    y  = x*bi0 + w1
;    w1 = x*bi1 + y*ai1 + w2
;    w2 = x*bi2 + y*a2
;
;
;              Cascaded Transpose IIR Filter              Program  Icycles
;                                                          Words
    move    #coef,r0        ;point to coefficients	  ;    1     1
    move    #w1,r4          ;point to w1		  ;    1     1
    move    #w2,r5          ;point to w2		  ;    1     1

    move    #5*nsec-1,m0    ;mod 5*nsec on coefficients	  ;    1     1
    move    #nsec-1,m4      ;mod nsec on w1		  ;    1     1
    move    #nsec,m5        ;mod nsec+1 on w2		  ;    1     1
							  ;  ----   ----
;	filter loop: 5*nsec+12				      6	    6
;*******************************************
    fmovep  y:input,d7.l    ;get input x		  ;    1     2
    float   d7,d7                                         ;    1     1
    fmove   x:(r0)+,d6.s    ;load b0                      ;    1     1
;
    do      #nsec,fltend    ;do filter                    ;    2     3
;         x*b0       b2*x+a2*y           b1            w1	   
    fmpy  d7,d6,d0  faddr d0,d1  x:(r0)+,d6.s  y:(r4),d2.s ;   1     1
								    
;         x*b1       y=x*b0+w1           a1            w2 
    fmpy  d7,d6,d0  faddr d0,d2  x:(r0)+,d6.s  y:(r5),d3.s ;   1     1

;         y*a1       x*b1+w2             b2     new w2
    fmpy  d2,d6,d0  fadd  d0,d3  x:(r0)+,d6.s  d1.s,y:(r5)+ ;  1     1

;         x*b2     w1'=x*b1+w2+y*a1      a2    y->x
    fmpy  d7,d6,d0  faddr d0,d3  x:(r0)+,d6.s  d2.s,d7.s    ;  1     1

;         y*a2                           b0     w1
    fmpy  d2,d6,d1               x:(r0)+,d6.s  d3.s,y:(r4)+ ;  1     1
fltend

;                   b2*x+a2*y   point back to b0
                    faddr d0,d1    (r0)-                    ;  1     1

;                                              save last w2
    fmove                                      d1.s,y:(r5)+ ;  1     1
    int    d2,d2                                            ;  1     1
    fmovep d2.l,y:output				    ;  1     2
                                                            ; ---   ---
                                                            ; 14    32 
                                                            ;     5*nsec+12
                                                 ;   TOTAL    20  5*nsec+18
    end

