Generic algorithm is something like this, port/scale as required: // Given A and B, find A = A/B, R = A%B for (R=n=0; n < 16; n++) // for each bit of A { R <<= 1; // right shift A into R... if (A & 0x8000) R |= 1; // ...with carry A <<= 1; // the wrong way to do it in asm!! if (R >= B) // if remainder larger than divisor { R -= B; // 'mod' it A |= 1; // here's the magic } } HTH == Rich On Mon, 27 Nov 2000, Dilan Amarasinghe wrote: > Date: Mon, 27 Nov 2000 11:56:16 +0530 > From: Dilan Amarasinghe > Reply-To: pic microcontroller discussion list > To: PICLIST@MITVMA.MIT.EDU > Subject: 16 / 8 -> 16 + 8 divider algorithm > > Does anybody have a divider algorithm. If so you send me in. > > Best Regards > > -- > http://www.piclist.com hint: To leave the PICList > mailto:piclist-unsubscribe-request@mitvma.mit.edu > > -- http://www.piclist.com hint: To leave the PICList mailto:piclist-unsubscribe-request@mitvma.mit.edu