This is the mail archive of the gcc@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: inline-asm/9910: gcc dies on inline assembly


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


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]