int DivDoubleLong (int wh, int wl, int divisor)
{
union {
unsigned __int64 l;
struct {
#if BIG_ENDIAN
int wh;
int wl;
#else
int wl;
int wh;
#endif
} w;
} a, b;
a.w.wl = wl;
a.w.wh = wh;
b.w.wl = divisor;
b.w.wh = 0;
return (int)(a.l / b.l);
}
Thank you.
Naidu
Dmitry Pogrebinsky, Software engineer, Broadband Voice BU
Terayon Communications Systems, http://www.terayon.com
<http://www.terayon.com/>
Tel: +972-3-5384613, Email: dmi...@terayon.com
<mailto:dmi...@terayon.com>
Fax: +972-3-5335877, Haplada St. 7, 60218 Or-Yehuda, Israel
ICQ: 69304286. HomePage: http://www.cs.biu.ac.il/~dpogrebi
<http://www.cs.biu.ac.il/~dpogrebi>
For instance (untested):
unsigned int
div_ulong( uint wh, uint wl, uint d )
{
uint result = 0;
uint bit;
uint t;
if (!wh)
return wl / d;
if (wh >= d)
/* overflow */
return ~0;
for (bit = 1 << 31; bit; bit >>= 1) {
wh <<= 1;
t = wl << 1;
if (t < wl)
wh |= 1;
wl = t;
if (wh < d)
continue;
result |= bit;
wh -= d;
}
return result;
}
The signed division is a little harder.
There are also MUCH faster algorithms - you can do two (or more) bits at a time.
Using the systems divide instruction (if it has one) will also help.
Of course the PPC probably has a 64 by 64 divide as an instruction!
Find it, and add an assembler call in (say) the wxWorks sysALib.s.
David
----------------------------------------------------------------
David Laight email: d...@tadpole.co.uk
Tadpole Technology plc phone: +44 1223 428 232
Cambridge, UK fax: +44 1223 428 201
I agree that if this doesn't work for you then just write your own divide routine.
No biggie.
Erick
WRS knows this problem as TSR 124264.
The solution is to inlude an extra library (which is, stange enough, located
in the 'host' tree) in your build. To do this, change the LIB macro in the
build settings and add the extra LIB_INT64 macro:
LIB_INT64=C:/TORNADO2/host/x86-win32/lib/gcc-lib/i960-wrs-vxworks5.3/cygnus-
2.7.2-960126/libgcc.a
LIBS=...original setting... $(LIB_INT64)
You may need to change some directory names depending on your installation.
Also note that the extra library is included AFTER the normal libraries.
Hope this helps,
Gerard Kerkhofs
Nicolet Technologies B.V.
Erick Gonzalez <erick.g...@remove.nospam.marconi.com> wrote in message
news:393FA320...@remove.nospam.marconi.com...