On Thu, 27 May 2004, Dennis Crawley wrote: > Another idea: > > a = a + (b-a)/16 =15a/16 + b/16 I was going to suggest just that, until I saw Andy's post. But for grins, you may wish to look at the 8-bit generalized implementation of that equation: http://www.dattalo.com/technical/software/pic/twist.asm > > a= .9375a + .0625b > > a*.9375 23 instr. > b*.0625 9 instr. > addition 5 instr. > 37 instr. vs 61 instr. of my old code. I obviously don't have your code, but I think it should take around 32 to 34 instructions. The algorithm is something like this: t = b; t = t + a; t = t>>1; t = t + a; t = t>>1; t = t + a; t = t>>1; a = t + a; a = a>>1; The >>'s pick up the carry from the previous additions. Each addition takes 6 instructions and each shift takes 2. If you can trash b, then this takes 32 instructions. If not, then it'll take 34. From the twist algorithm (in url given above), you can experiment with other weights like 3/16 and 13/16 or whatever. BTW, this is actually an IIR filter and not an FIR one. Scott -- http://www.piclist.com hint: PICList Posts must start with ONE topic: [PIC]:,[SX]:,[AVR]: ->uP ONLY! [EE]:,[OT]: ->Other [BUY]:,[AD]: ->Ads