Re: Upper 32 bits (off topic)

Search this archive.

From: David Goodlad (dgoodlad@junction.net)
Date: Fri 10 Mar 2000 - 17:59:30 IST


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


This archive was generated by hypermail 2.1.4 : Wed 21 Jan 2004 - 22:10:23 IST