Well, you could probably do it in assembly quite easily. I forget the exact
registers that it uses, but when you MUL two 32bit numbers, you get the upper 32
bits of the result in one register (I THINK edx, but I'm not sure, it's been too
long), and the lower in another register.
Hope that helps a bit.
David
Jay Link wrote:
> This is somewhat off-topic, but I figure if anyone can answer it, you guys
> can. Thanks.
>
> ==========
>
> Ok, you smart guys, how do I get the upper 32 bits of a number when using
> a 32-bit compiler? I.e., >> 32 would work on a 64-bit system, but you
> can't do that on an x86, right?
>
> Here's an example using a "Watcom" compiler:
>
> /*------------------------------------------------------------------------*
> BIGMUL -> 32bit * 32bit = 64bit. We need the upper 32 bit.
> On a 64-bit compiler, it would be (num1 * num2) >> 32;
> *------------------------------------------------------------------------*/
> int BIGMUL(int a, int b);
> #pragma aux BIGMUL = \
> "imul edx" \
> parm [eax] [edx] \
> value [edx];
>
> How I rewrite this for gcc?
>
> Thanks!
>
> -Jay