Inline assembler can't return 64-bit values in registers

Michael Meissner meissner@cygnus.com
Wed Dec 6 18:01:00 GMT 2000


On Wed, Dec 06, 2000 at 06:41:21PM -0600, Timur Tabi wrote:
> ** Reply to message from Richard Henderson <rth@redhat.com> on Wed, 6 Dec 2000
> 16:33:35 -0800
> 
> 
> > This doesn't do what you think it does.  One, you clearly didn't
> > want 64-bit temporaries, since you try to do shifty things with
> > them after the asm.
> 
> Actually, I did want 64-bit temps, since otherwise the expression "(temp2 <<
> 32)" would be equal to zero.  By declaring the temps as 64-bit, I avoid having
> to cast them.
> 
> Of course, I forgot to initialize them to zero first, but that wouldn't have
> affected the generated code.
> 
> > 	  : "=A" (temp)
> 
> According to my docs, this means either eax or edx.  Are you saying that it
> means edx AND eax (i.e. edx:eax) when dealing with a 64-bit variable?

Yes, because internally GCC represents EDX as the register after EAX.  Thus
when you say "=A" for a 64 bit result, it uses EAX and EDX to hold the
temporaries.  Because the x86 is a little endian machine (ie, BYTES_BIG_ENDIAN
== 0), and it represents words in little endian format (WORDS_BIG_ENDIAN == 0),
the least significant bits are in EAX and the most significant bits are in EDX,
which it just so happens is what the function return for 64 bit functions
expects (and also the 32x32->64 bit multiply as well).

-- 
Michael Meissner, Red Hat, Inc.
PMB 198, 174 Littleton Road #3, Westford, Massachusetts 01886, USA
Work:	  meissner@redhat.com		phone: +1 978-486-9304
Non-work: meissner@spectacle-pond.org	fax:   +1 978-692-4482


More information about the Gcc-bugs mailing list