ON 20030103@2:20:19 AM at page: http://www.piclist.com/techref/microchip/math/div/24by16ad.htm AD-ULU-7C8 Andy David added 'Says The above (anonymous) poster has not convinced me that the original code doesn't work -- my test cases for divisor < 0x100 are all correct. The original code is for the 17c series pics, hence the use of the subwfb instruction. The purpose of the first 5 lines of code at d2416s is to compare the current remainder with the (constant) divisor. Using a 16-bit subtract abd checking the status of carry is standard, I can't get this code to fail. The carry that is subsequently shifted into the quotient is correct as either remainder => divisor (when remainder - divisor is +ve (>= 0) carry = 1) or remainder < divisor (carry = 0). I've just tried several test cases with divisor < 0x100, I can't see any problem. As a benchmark I've used BaseCalc. The alternative code looks like it will work but I don't believe there's a reason for using it; you'd normally need a good reason to replace 5 (working) lines of code with 7. Note that if you want to use this code for 14-bit core you'll need to change more code than suggested. Now that I've finished saying that the code works, I refer the reader to the standard disclaimer in that I'm not responsible for your use of this code. Clever people use Dimitry's, Nikolai's or Scott's code, anyway. -- AD.' ON 20030103@11:46:09 PM at page: http://www.piclist.com/techref/microchip/math/div/24by16ad.htm JMN-EFP-786 James Newton edited the page. Difference: http://www.piclist.com/techref/diff.asp?url=H:\techref\microchip\math\div\24by16ad.htm&version=4