;
	  .title	 "FIR.ASM - 41 point FIR filter"

B2	  .set	   0060h	; 32 words of data RAM
B1	  .set	   0300h	; 512 words of data RAM
B0_D	  .set	   0100h	; 512 words of data RAM
B0_P	  .set	   0FE00h	; 512 words of program RAM

;
	  .sect     "vectors"
;
          B         START
;
; START OF TMS32C05X INITIALIZATION
;
	  .text
;
START	  SETC	    SXM 	; Set sign extension mode
	  SETC	    OVM 	; Set overflow mode
	  CLRC	    CNF 	; Set block B0 at <dma> 100h
	  SPM	    0		; Set MPY output shifter to 0
	  LDP	    #TABLE	; Set Data Page pointer to top of B2
;
; Move INIT values to data memory block B2
;
	  LAR	   2,#B2	; Load AR2 with the address of B2
	  MAR	   *,2		; Use AR2 to point
	  RPT	   #INIT_LEN	; Repeat (N-1) times
	  BLPD	   #INIT_DATA,*+ ; Move the INIT data to block B2
;
; Move FIR coef. to data memory block B0
;
	  LAR	    2,#B0_D	; Load AR2 with the address B0_D
	  RPT	    #FIR_LEN	; Repeat (N-1) times
	  BLPD	    #FIR_DATA,*+ ; Move the coef. to block B0
	  SETC	    CNF 	; Set block B0_D to B0_P at <dma> 0FE00h
;
; Zero delay line, Block B1 <dma> 300h
;
	  LAR	    1,#B1	; Load AR1 with the address B1
	  MAR	    *,1 	; Set AR(ARP) to 1
	  ZAP			; Zero accumulator and P register
	  RPT	    #FIR_LEN	;
	  SACH	    *+		; Save the upper accumulator (0)
	  LAR	    1,#B1-1	; Point to the x(0) entry + 1 <dma>
;
; Initialize for FIR filter
;

WAIT	  MAR	    *+		; Point to the first value
	  IN	    *,PA2	; Read the value into x(0) location

	  LAR	    1,#B1+(FIR_LEN); Set AR(ARP) to x(n-m)
	  ZAP			; Zero accumulator and P register

	  RPT	    #FIR_LEN
	  MACD	    0FE00h,*-
          APAC
	  ADD	    ONE,14	     ;ROUND OFF
;	  BD	    WAIT	; Branched delayed in two cycles
	  SACH	    YN,1
	  OUT	    YN,PA4
	  B	    WAIT	; Branch occures here
;
; Initialize variable names and size
;
TABLE	  .bss	    ONE,1	    ; <dma> 60h
	  .bss	    YN,1	    ; <dma> 61h

	  .page

	  .data
;
INIT_DATA .word     0001h	;ONE
INIT_END  .word     0000h	;RATE
;
INIT_LEN  .set (INIT_END - INIT_DATA)
;
XN	  .usect ramb1,FIR_LEN; Reserve <dma> 0300h
;
;*************************************************************************
;       Coefficient initialization -- Q15 Scaling
;*************************************************************************
;
FIR_DATA
 .word -5
 .word -2
 .word 11
 .word -20
 .word 45
 .word 235
 .word 103
 .word -255
 .word -130
 .word -40
 .word -727
 .word -638
 .word 985
 .word 1345
 .word 21
 .word 790
 .word 2009
 .word -2421
 .word -7742
 .word -2393
 .word 8838
 .word 8838
 .word -2393
 .word -7742
 .word -2421
 .word 2009
 .word 790
 .word 21
 .word 1345
 .word 985
 .word -638
 .word -727
 .word -40
 .word -130
 .word -255
 .word 103
 .word 235
 .word 45
 .word -20
 .word 11
 .word -2
 .word -5
FIR_END  
;
FIR_LEN .set (FIR_END - FIR_DATA)
;
        .end
