I think the fastest way would be to subtract 100 (0 1 or 2 times) to get the most significant digit, leaving a number from 0-99, then look up the other two digits in a table. Sum total should be around two dozen cycles, and a 100-entry table for around 120-130 memory location. Something like this... (Scratched out fast, assumes the PCLATH already where it needs to be... no guarantees, not debugged or anything but should be about close...) clrf most_significant-digit movfw number_to_convert sublw d'100' skpnc ;did I get the right carry state? goto otherdigits incf most_significant_digit,f sublw d'100' skpnc goto otherdigits incf most_significant_digit,f goto lookupothers otherdigits: addlw d'100' call lookuplowdigits movwf least_significant_2_digits ... all done lookuplowdigits: addwf PCL,f dt 0x00, 0x01, 0x02 ... 0x99 -----Original Message----- From: Edson Brusque [mailto:brusque@FLYNET.COM.BR] Sent: Wednesday, December 22, 1999 2:50 PM To: PICLIST@MITVMA.MIT.EDU Subject: Fast byte to BCD routine! Hello PICsters! I'm needing a fast routine to break-down a byte to three digits: before: input = 137; after: output2 = 7; output1 = 3; output0 = 1; It doesn't have to be small, but it have to be FAST. I'm thinking about doing it with a BIG lookup-table. Anyone have a better idea? Maybe a hybrid routine (table+calculations). Best regards and thanks for all your help, Brusque ___________________________________________________________________________ | | || |\| | || || |\|\ Edson :-^= Brusque | | || ||| | || || |||| brusque@flynet.com.br | |_||_||| |_||_||_|||| Musician, Programmer, Developer, Electronics | \_\\_\|| \_\\_\\_\||| Blumenau / SC / Brazil / South America | | | | | | | || Earth / Solar System / Milk Way |__|__|__|__|__|__|__|| Giro In'Italia homepage: www.flynet.com.br/giro \__\__\__\__\__\__\__\| C.I.Tronics Lighting Designers: www.citronics.com.br ---------------------------------------- ICQ# 15937748 --------------------- Founder of the CUMP mailing list subscribe-cump@egroups.com Founder of the SoundFont mailing list soundfont-subscribe@onelist.com ----------------------------------------------------------------------------