/*
 * iir.dsp -- ADSP-2191 IIR biquad filter for open21xx.
 * Based on Analog Devices application note.
 */
	.section/PM program0;
	.global _start;
_start:
	/* Setup */
	i0 = 0x0100;	/* delay line */
	i1 = 0x0200;	/* input */
	i2 = 0x0300;	/* output */
	i4 = 0x0400;	/* coefficients (PM) */
	l0 = 4;	/* 2 * biquad_secs */
	l4 = 8;	/* 4 coeffs per biquad * 2 */
	m0 = 1;
	m1 = 1;
	m3 = -1;
	m4 = 1;

	se = 0;
	cntr = 256;
	do _filtering until ce;
	mx0 = dm(i1,m3);
	my0 = 0x2000;
	cntr = 2;
	mr = mx0*my0(su), mx0 = dm(i0,m3), my0 = pm(i4,m4);
	do _quads until ce;
	mr = mr+mx0*my0(ss), mx1 = dm(i0,m3), my0 = pm(i4,m4);
	mr = mr+mx1*my0(ss), my0 = pm(i4,m4);
	sr = ashift mr1 (hi), my1 = pm(i4,m4);
	mr = mr+mx0*my0(ss), mx0 = dm(i0,m0), my0 = pm(i4,m4);
_quads:
	dm(i0,m3) = sr1, mr = mr+mx1*my1(ss);
_filtering:
	dm(i2,m3) = mr1;
	rts (db);
	nop;
	nop;

_halt:
	jump _halt;
