From: Schmitt Michael <mschmitt@ba...>  20020320 14:50:01

okay my fault ... my brain still things sdcc is a 8051 (only compiler, = still where sdcc startet as sdc a couple of years ago ....) i mean 8051 ... the problem is ... every machine cycle counts so it has = to be a realy very fast 18/15 bit div function. so the fastest function i = have takes about 70usec (assuming 24mhz or 0,5usec per machine cycle =3D 140 machine cycles) .. anybody out there that can beat that ? isn't that a lot of fun ? spending hours and hours just to get rid of = just 1 machine cycle to get into the needed specs ? Dipl.Ing. (FH) Michael Schmitt Baumer Ident GmbH Entwicklung / Development Department Hertzstr. 10 D69469 Weinheim Deutschland / Germany Tel. +49 (0) 6201 9957  30 Fax. +49 (0) 6201 9957  99 EMail : mschmitt@... Web: http://www.baumerident.com > Urspr=FCngliche Nachricht > Von: Scott Dattalo [mailto:scott@...] > Gesendet: Mittwoch, 20. M=E4rz 2002 15:20 > Cc: SDCCUSER (EMail) > Betreff: Re: [Sdccuser] need a very fast 18bit / 15bit div >=20 >=20 > On Wed, 20 Mar 2002, Bernhard Held wrote: >=20 > > > Does anybody know where to find source of a very fast=20 > division of 18bit / > > > 15bit ? > > What processor? For the 8051you'll find assembler functions=20 > for 16/16 and > > 32/32 bit divisions in the library. It should be easy to=20 > adjust the source > > for 18/15 bit. Additionally you can eliminate the loop.=20 > AFAIK there is no > > faster algorithm for the 8051, if there's no further=20 > infomation about the > > distribution of the values. >=20 > Yeah, which processor? >=20 > There are always tricks one can play. A generic solution to=20 > this problem > would be to unroll the division loop. This saves decrementing a loop > counter and a branch. >=20 > If you know something about the form of the numbers, there=20 > are additional > tricks. For example, if your divisor is actually a constant, then = it's > often faster to multiply by it's reciprocal. Or if you know that the > upper bits are constant, then you can try this formula: >=20 > x/y =3D x / (y_up + y_lo) >=20 > =3D x / y_up * (1/(1 + y_lo/y_up)) >=20 > A series expansion of >=20 > 1 >  =3D 1  A + A^2  A^3 > 1 + A >=20 > May be then invoked. This is especially useful for the case=20 > when y_up is > way greater than y_lo because then only a few terms of the=20 > expansion are > needed. Intelligent partitioning can turn some of the=20 > division operations > into shift operations. >=20 > There are many, many tricks. But each trick depends on the specific > problem to be solved. >=20 > Scott >=20 >=20 > _______________________________________________ > Sdccuser mailing list > Sdccuser@... > https://lists.sourceforge.net/lists/listinfo/sdccuser >=20 