=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=- Date: Sat, 22 Apr 2000 07:09:46 From: Scott Dattalo <scott-at-DATTALO.COM> To: PICLIST-at-MITVMA.MIT.EDU Subject: Re: Frequency Conversion -------------------------------------------------------------------------------- On Sat, 22 Apr 2000, Nikolai Golovchenko wrote: > Grant, > To divide efficiently by 13.18 use a constant division/multiplication > code generator at > www.piclist.com/codegen/constdivmul > > This is as easy as copy and paste :) > > ; ACC = ACC * 0.075900 > ; > ; ALGORITHM: > ; Clear accumulator > ; Add input / 16 to accumulator > ; Add input / 64 to accumulator > ; Substract input / 512 from accumulator > ; Move accumulator to result > ; > ; Error in constant approximation : 0.358202, % > > > ; Input: ACC0 .. ACC1 (11 bits) > ; Output: ACC0 (8 bits) > <snip> I love it! That damn code generator beat me by about 5 cycles! (Unless you cut the approximation to where the comment 'we're probably close enough ...', Butt steal). No more Beer and Pic programming on Friday nights for now on. Guess I'll switch to the hard stuff: Beer and 8051 programming. Scott