> -----Original Message----- > From: Bob Axtell [SMTP:cr_axtell@YAHOO.COM] > Sent: Monday, June 23, 2003 2:19 AM > To: PICLIST@MITVMA.MIT.EDU > Subject: Re: [PIC]: Byte to Digits > > Repeatedly dividing by 10, extracting each place as it spits out, is a > good > way to do this but consumes incredible # of machine cycles. If you have to > generate lots of these, you can easily overrun your time budget. > > I use a compromise routine that (for an 8-bit value) subtracts off the100s > place character, then uses a lookup table to extract a packed BCD char, to > compose the last two characters. This is extremely fast- about 30 > instruction cycles to extract and compose all three ASCII characters. > > --Bob > Scott Dattalo's 3 digit BCD code on http://www.piclist.com runs in about 28 cycles. You would then have to add the ASCII '0' offset to each value, but the final result would still be very fast and without using any lookup tables. Mike ======================================================================= This e-mail is intended for the person it is addressed to only. The information contained in it may be confidential and/or protected by law. If you are not the intended recipient of this message, you must not make any use of this information, or copy or show it to any person. Please contact us immediately to tell us that you have received this e-mail, and return the original to us. Any use, forwarding, printing or copying of this message is strictly prohibited. No part of this message can be considered a request for goods or services. ======================================================================= Any questions about Bookham's E-Mail service should be directed to postmaster@bookham.com. -- http://www.piclist.com hint: The PICList is archived three different ways. See http://www.piclist.com/#archives for details.