--- Scott Dattalo wrote: > Clay, > > I looked at your MatLab code and I assume this is > similar to what you > wish to implement in PIC assembly. If so, then it > appears that all > divisions can be replaced with multiplications. For > example, you write: > dr = 2^20/seed > Fref_act = FGHz/dr > Which can obviously be written as: > Fref_act = (FGHz * seed) / 2^20 > And division by 2^20 is the same thing as shifting > right 20 bit positions. > In another place you show a division by a constant. > This one can be > replaced with a multiplication of 1/constant. Yes, there is some mathematical simplification that has been done already in C. I posted the original equations to more clearly represent the goal. > Having said this, I don't have any routines to > perform 64bit > multiplication. However, if I were to write one I'd > either start from > first principles and implement a shift/add routine, > or I'd use > pre-existing 32-bit routines. E.g. you may've > already noticed that if N > and M are 64-bit numbers, they can be written as: > > N = a*2^32 + b > M = c*2^32 + d > > and N*M can be written as > > N*M = ac*2^64 + (ad+bc)*2^32 + bd > > A 64-bit multiplication has been replaced with 4 > 32-bit multiplications. > This can actually be replaced with 3 32-bit > multiplications: > > N*M = ac*2^64 + (ac + bd - (a - b)(c - d)) *2^32 + > bd > > However, the middle term is now signed. > > Scott Thanks for the tips on the fundamentals of binary math. I'll try and implement them. Clay __________________________________ Yahoo! FareChase: Search multiple travel sites in one click. http://farechase.yahoo.com -- http://www.piclist.com PIC/SX FAQ & list archive View/change your membership options at http://mailman.mit.edu/mailman/listinfo/piclist