Em 15/2/2010 14:44, sergio masci escreveu: > > On Mon, 15 Feb 2010, Isaac Marino Bavaresco wrote: > > = >> There is an interesting implementation which is used by MPLAB-C18 >> library (file itobcd.asm). >> It is a very efficient serialized method, it uses only shifts and adds. >> It is worthy a try. >> = > Hi Isaac, > > Thanks for the pointer but in this case I was trying to explain the = > fundamentals and in particular why getting to grips with 16 bit arithmati= c = > on an 8 bit PIC is a GOOD thing. The whole thing would have been really = > trivial had the OP been comfortable with 16 bit arithmetic in the first = > place. > > Regards > Sergio Masci > = I understand, but this method doesn't use 16-bit math at all. All the math is done nibble-by-nibble, no carry is propagated during the additions. The only part that uses carry propagation is during the shifts, that shifts the whole 16-bit (or 9-bit in this case) value. It works for values with any number of digits. If you don't already know this method, I would suggest to study it, it is very enlightening. Shows a very different approach that exploits curious properties of binary and BCD numbers. It is being used for a while by the CPLD/FPGA guys, because it is easily implemented using just shift-registers and adders. Best regards, Isaac __________________________________________________ Fa=E7a liga=E7=F5es para outros computadores com o novo Yahoo! Messenger = http://br.beta.messenger.yahoo.com/ = -- = http://www.piclist.com PIC/SX FAQ & list archive View/change your membership options at http://mailman.mit.edu/mailman/listinfo/piclist