This is the mail archive of the
gcc-help@gcc.gnu.org
mailing list for the GCC project.
Re: A question about register constraint of inline assembly
- From: "Lin Chun-Zhi" <lcz90 at cs dot ccu dot edu dot tw>
- To: gcc-help at gcc dot gnu dot org
- Date: Fri, 3 Jun 2005 10:34:55 +0800
- Subject: Re: A question about register constraint of inline assembly
- References: <20050602031521.M89555@cs.ccu.edu.tw> <m38y1tzbjx.fsf@gossamer.airs.com> <20050602051408.M11066@cs.ccu.edu.tw> <m3r7fkyj52.fsf@gossamer.airs.com>
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@cs.ccu.edu.tw> 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)