>I was wondering whether there is any efficient way of implementing an >8-bit by 8-bit divide. My dividend is smaller than the divisor (always). >Both are positive numbers. The dividend is in the range 0-128 and the >divisor is in the range 0-256. The only way I know of is to implement it >as a 16-bit by 8-bit divide. But that takes 192 instructions which is a >lot for my application. > >Does anyone have any better idea how to do it? > Since no-one has had a go at this, I REALLY don't have time but how about this approach... Since you wish to calculate (a*256)/b where a < 128 A fast 8x8 multiply can be done in 40 or so cycles. a * (256/b) All you need now is a fast reciprocal routine to calculate 256/b This is probably more amenable to an optimization than the more general case you asked for. Anything better than 140-150 cycles will be faster than what you already have. To kick start that thread, here is something that I filed from an earlier thread on Dividing INTO a Constant. Courtesy of Scott Dattalo.. There's another division trick I forgot to mention in my previous post. Consider this power series expansion of division: N N / / e \ / e \2 / e \3 \ ------- = --- * | 1 - |---| + |---| - |---| + ... | v + e v \ \ v / \ v / \ v / / In your case, N, the dividend, is a constant. The divisor has been written as a sum of two variables. Now the trick is to find a 'v' for which division is easy and at the same time much larger than 'e'. One way is to search for the MSB in your variable. For example if you were dividing by 257 then a good 'v' and 'e' would be v=256 and e=1. But this same trick for 511 would yield v=256 and e=255, which would lead to a relatively slow convergence. Another better approach would be to let v be the 4 most significant bits. Thus the 511 case (=0x1ff) would yield a v=0x1e0 and an e=1f. The series converges much more rapidly and the division is reduced to a 4-bit divisor. Ray Gardiner (DSP Systems) ray@dsp-systems.com http://www.dsp-systems.com private email to:- ray@netspace.net.au