This is the mail archive of the
gcc@gcc.gnu.org
mailing list for the GCC project.
Re: inline-asm/9910: gcc dies on inline assembly
- From: Zack Weinberg <zack at codesourcery dot com>
- To: jay at remotepoint dot com
- Cc: gcc-gnats at gcc dot gnu dot org, gcc at sources dot redhat dot com, dies at sources dot redhat dot com
- Date: Sun, 02 Mar 2003 17:19:31 -0800
- Subject: Re: inline-asm/9910: gcc dies on inline assembly
- References: <20030303005309.20077.qmail@sources.redhat.com>
jay at remotepoint dot com writes:
> will not compile very simple piece of inline assembly code. gcc-3.2
> gives an internal compiler error where gcc-2.95 gave invalid asm
> statement (fixed or forbidden register 0 (ax) was spilled for class
> AREG). From what I can find, the code should actually be legal.
...
> int main() {
> int foo=10, bar=15;
>
> __asm__ __volatile__ ("addl %%ebx,%%eax"
> : "=eax"(foo)
> : "eax"(foo),"ebx"(bar)
> : "eax"
> );
gcc should not ICE, but this is emphatically not correct code. A
correct asm statement would read
__asm__ ("addl %1, %0"
: "+a" (foo)
: "b" (bar));
or better (since there is no requirement for eax and ebx to be the
registers used):
__asm__ ("addl %1, %0"
: "+r" (foo)
: "r" (bar));
The difference between constraint strings and clobber lists is
unfortunate and confusing, but no one has had a better idea.
zw