; File name: myDF2IIR.asm ; ; 19Oct2003 .. created as a learning experience code study .. KM ; ; on call we have ; ar0 ptr_x ; ar1 ptr_h ; ar2 ptr_y ; ar3 ptr_d ; T0 nbiq ; T1 nx .c54cm_off ;don't want compatible with c54 .ARMS_on ;enable assembler for ARMS=1 .CPL_on ;enable assembler for CPL=1 .asg ar0,ptr_x .asg ar1,ptr_h .asg xar1,xptr_h .asg xar7,txptr_h .asg ar2,ptr_y .asg ar3,ptr_w .asg xar3,xptr_w .asg xar6,txptr_w .asg T0,nbiq .asg T1,nx .asg 0001100000000000b,my_ST0_55 .asg 0110100100000000b,my_ST1_55 .asg 1001000000000000b,my_ST2_55 .asg 0001000000000010b,my_ST3_55 .sect ".text" ;place into the code section .align 4 ;force 32-bit boundary .global _myDF2IIR ;make entry visible to linker _myDF2IIR: psh mmap(st0_55) ; save machine state psh mmap(st1_55) ; by saving all four psh mmap(st2_55) ; status registers psh mmap(st3_55) ; on the system stack psh T3 ; probably don't need this pshboth txptr_h ; save the xars use to hold reset pshboth txptr_w ; address of coeffs and delays mov #my_ST0_55,mmap(st0_55) ; now configure the machine mov #my_ST1_55,mmap(st1_55) ; a generic set of values that mov #my_ST2_55,mmap(st2_55) ; still need a bit of tweeking mov #my_ST3_55,mmap(st3_55) ; close to reset state bset sxmd ; enable sign extend bset frct ; shift left 1 on multiply bset m40 ; use 40 bit accumulator bset rdm ; round to nearest bclr c54cm ; not C54x compatible bclr satd ; disable saturation in D-unit bclr sata ; disable saturation in A-unit sub #1,nx ; hardware needs nx-1 for loop count sub #1,nbiq ; hardware needs nbiq-1 for loop count mov nx,mmap(brc0) ; set up outer loop count..T1 is free now mov nbiq,mmap(brc1) ; set up inner loop count..T0 is free now mov xptr_w,txptr_w ; save ptr_w initial value mov xptr_h,txptr_h ; save ptr_h initial value rptblocal L_outer-1 mov *ptr_x+<<#16,ac0 ; get sample value into ac rptblocal L_inner-1 ; loop through sections masm T3=*ptr_w+,*ptr_h+,ac0 ; ac0 = x-a2*w2, T3=w2 mas *ptr_w,*ptr_h,ac0 ; ac0 = x-a2*w2-w1*a1/2 ||mov T3,T0 ; move w2 into T0 masm T3=*ptr_w-,*ptr_h+,ac0 ; ac0 = x-a2*w2-a1*w1, T3=w1 mov rnd(hi(saturate(ac0))),mmap(T1) ;v1 mpym *ptr_h+,T3,ac0 ; ac0 = w1*b1/2 ||mov T3,*ptr_w+ ; move w1 into w2 sfts ac0,#1 ; assuming b1/2 was supplied macm *ptr_h+,T0,ac0 ; ac0 = b1*w1+b2*w2 ||mov T1,*ptr_w+ ; move v1 into w1 macm *ptr_h+,T1,ac0 ; ac0 = b1*w1+b2*w2+b0*v1 ; ac0 contains input to next section L_inner: mov rnd(hi(saturate(ac0))),*ptr_y+ ; filter cascade output value mov txptr_w,xptr_w ; reset xptr_w mov txptr_h,xptr_h ; reset xptr_h L_outer: popboth txptr_w ; restore xar used to hold reset address popboth txptr_h ; restore xar used to hold reset address pop T3 ; restore contents of T3 pop mmap(st3_55) ; restore the four status registers pop mmap(st2_55) pop mmap(st1_55) pop mmap(st0_55) ret