please dont rip this site
Home About Projects PIC code SX code

Most of this code has originated from requests and challenges on the PICList mailing list.

I tried to debug the routines as much as possible (for a hobby), but no guarantees. In case you find a bug, please let me know.

Please send any questions or comments to, or the PICList, as many nice folks hang around there and most probably will be glad to help you.

Routine Name Size, instructions Max timing, cycles Temporary registers Notes
24 by 24 bits 29 513 1
8 by 8 bits to 24 bit floating point 41 413 1
16 by 8 bits with Q16.16 fixed point result 39 460 1
24 by 16 bits (and 24 by 15) 27/28 584/581 3
32 by 16 bits using 16 by 16 bits with a 16 bit result 36 345 2/4
48 by 24 bits (and 48 by 23) 58/51 1458/1266 5/4 my versions at the bottom
Scaled 8 bit: x 256*x/y 28 281 3
Approximate 8 bit reciprocal: 32768/x 19 47 0
Divide 14 bit integer using a fixed point divisor and result (7Q8 format) 27 264 0
10 bits 68 70 0 this is a debugged John Payson's version
Routine Name Size, instructions Max timing, cycles Temporary registers Notes
Square Root
24 bit floating point 85 406 6 IEEE<>Microchip format conversion
12 bit integer 32 118 3
8 bit 20 66 2
8 bit fast 53 19 0
8 bit small 9 87 0 Idea from Scott Dattalo, tweak by Dmitry Kiryashov
Powers and logarithms
Fixed point Q0.16 log2x 105 323 3 also notes on xy
Fixed point Q6.10 2x 121 291 4
Vector magnitude, 16 bits 147 ~1600/800 4
Routine Name Size, instructions Max timing, cycles Temporary registers Notes
Radix Conversion
16 bit binary to 5 digit decimal 68 226 0 strips a digit at a time
16 bit binary to 3 digit decimal 34 108 0 based on John Payson's 5 digit version
16 bit binary to 3 digit decimal 56 57 0 based on Scott Dattalo's 8 bit BIN2BCD
5 digit decimal to 16 bit binary 35 36 0
5 digit decimal (BCD) to 16 bit binary 23 341 1
8 bit random number generator 10 10 0 my version at the bottom
Delay exactly N cycles - - 0 scalable for any N size
Routine Name Size, instructions Max timing, cycles Temporary registers Notes


Says: +


See also:

file: /Techref/member/NG--944/pic_collection.htm, 20KB, , updated: 2007/3/29 06:46, local time: 2015/4/18 10:08, owner: NG--944,

 ©2015 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=""> PIC Code Collection</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 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?

  PICList 2015 contributors:
o List host: MIT, Site host, Top posters @20150418 IVP, RussellMc, Bob Blick, alan.b.pearce, James Cameron, Josh Koffman, Dwayne Reid, Isaac Marino Bavaresco, Robert Dvoracek, Jesse Lackey,
* Page Editors: James Newton, David Cary, and YOU!
* Roman Black of Black Robotics donates from sales of Linistep stepper controller kits.
* Ashley Roll of Digital Nemesis donates from sales of RCL-1 RS232 to TTL converters.
* Monthly Subscribers: Gregg Rew. on-going support is MOST appreciated!
* Contributors: Richard Seriani, Sr.

Welcome to!