Re: A question about register constraint of inline assembly

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Thanks for Ian's relpy. It's very helpful for me.

On 02 Jun 2005 09:37:29 -0400, Ian Lance Taylor wrote
> "Lin Chun-Zhi" <lcz90@xxxxxxxxxxxxx> writes:
> 
> Please reply to the list, not just to me.
> 
> > But there is another wield thing. I can't pass the compiling stage use 
the 
> > code below.
> > 
> > int main(void)
> > {
> >         int __value, __port;
> > 
> >         asm volatile ( "movl %1,%0" : "=a" (__value), "=d" (__port)
> >                                    : ""   (__value), "1"  (__port)
> >                      );
> > 
> >         return 0;
> > }
> > 
> > The error message is
> > [root@littleroach tmp]# gcc a.c
> > a.c: In function `main':
> > a.c:10: warning: asm operand 2 probably doesn't match constraints
> > a.c:10: error: impossible constraint in `asm'
> > 
> > But the same code in the kernel works very well.
> > Do I miss something?
> 
> It would probably work when optimizing.  Otherwise gcc is complaining
> because it has a memory address and it doesn't know what type of
> register to put it into.
> 
> You should specify a constraint, though.  It's not a good idea to not
> specify one.  If you want to specify that the value is changed by the
> asm (which is not the case in your example) use '+' instead of '='.
> 
> Ian


--
Open WebMail Project (http://openwebmail.org)


[Index of Archives]     [Linux C Programming]     [Linux Kernel]     [eCos]     [Fedora Development]     [Fedora Announce]     [Autoconf]     [The DWARVES Debugging Tools]     [Yosemite Campsites]     [Yosemite News]     [Linux GCC]

  Powered by Linux