#include <def21489.h>

.global IIR_IP_buff1;
.global IIR_OP_buff1;
.global IIR_CF_buff1;

.global _main;
.global _IIR_DMA_ISR;

.extern _Init_IIR;

#define WINDOW_SIZE	1024

#define BIQUADS		6


.section/dm seg_dmda;

	
	.var IIR_IP_buff1[WINDOW_SIZE] =	{
	
								#include "iir_input.dat"
	};
	
	
	.var IIR_OP_buff1[WINDOW_SIZE];
	
	.var IIR_OP1_buff1[WINDOW_SIZE];
	
	
	
	.var IIR_CF_buff1[7*BIQUADS]={
		
								#include "iir_coeffs.dat"
	};
	
					   
	.var gain={
				#include "gain.dat"
	};
	
	
.section/pm seg_pmco;

_main:

	bit set MODE1 IRPTEN;
	nop;
	
	call _Init_IIR;
			
	jump(pc,0);
	
_main.end:
		

_IIR_DMA_ISR:

	call apply_gain;
	
	
	nop;	//Put a breakpoint here
	nop;
	
	rti;
	
_IIR_DMA_ISR.end:


apply_gain:

	i0=IIR_OP_buff1;l0=0;m0=1;
	i1=IIR_OP1_buff1;l1=0;m1=1;
	
	lcntr= WINDOW_SIZE, do gain1 until lce;
	f0=dm(i0,m0);
	f1=dm(gain);
	f2=f0*f1;
	dm(i1,m1)=f2;
	gain1:
	nop;

	rts;	

