please dont rip this site

PIC Microcontoller Radix Math Method

10bit to BCD unpacked 4 digit in 38 inst ~88 cycles by E. A. Grens

10 bit Binary to BCD Conversion

Posted on the Chat Zone by Ed Grens on September 22, 2004 at 03 08 38

On 18 September Peter Hemsley posted a 12b binary to BCD conversion subroutine in a response to a post by me. His algorithm is excellent for 12b conversion, but not efficient for the 10b often encountered with A/D inputs. Over the 10b data range, 0x000 to 0x3FF, this routine requires on the average of 131 processor cycles. Actually this is more than it requires on the average over the entire 12b range (118 cycles).

A simple divide by power of ten algorithm, listed below, requires on the average 88 cycles over the 10b range. This is possible because, for 10b, one can use single byte subtractions for divides. At 12b (probably) and certainly at 16b this approach cannot compete with the procedure Peter has presented. But, if 10b is what you need, it can be advantageous.

Ed +


See also:


Michael Lee Van Dyke Says:

On the 10 bit code, the 9th instruction after the Bin2decg label is is "goto B2d2". There is no B2d2 label in the code, it will not work as it is written here.


file: /Techref/microchip/math/radix/b2bu-10b4d-eag.htm, 8KB, , updated: 2020/4/3 12:02, local time: 2024/7/13 18:28, owner: JMN-EFP-786,

 ©2024 These pages are served without commercial sponsorship. (No popup ads, etc...).Bandwidth abuse increases hosting cost forcing sponsorship or shutdown. This server aggressively defends against automated copying for any reason including offline viewing, duplication, etc... Please respect this requirement and DO NOT RIP THIS SITE. Questions?
Please DO link to this page! Digg it! / MAKE!

<A HREF=""> 10bit to BCD unpacked 4 digit in 38 inst ~88 cycles by E. A. Grens</A>

After you find an appropriate page, you are invited to your to this massmind site! (posts will be visible only to you before review) Just type a nice message (short messages are blocked as spam) in the box and press the Post button. (HTML welcomed, but not the <A tag: Instead, use the link box to link to another page. A tutorial is available Members can login to post directly, become page editors, and be credited for their posts.

Link? Put it here: 
if you want a response, please enter your email address: 
Attn spammers: All posts are reviewed before being made visible to anyone other than the poster.
Did you find what you needed?


Welcome to!


Welcome to!