This is the mail archive of the
gcc@gcc.gnu.org
mailing list for the GCC project.
Re: Fwd: extended asm
- From: Zack Weinberg <zack at codesourcery dot com>
- To: Ankit Jain <ankitjain1580 at yahoo dot com>
- Cc: gcc at gcc dot gnu dot org
- Date: Sun, 25 Jul 2004 07:30:28 -0700
- Subject: Re: Fwd: extended asm
- References: <20040725050238.33815.qmail@web52907.mail.yahoo.com>
Ankit Jain <ankitjain1580@yahoo.com> writes:
> asm("movb %3,%0":"=r"(x),"=r"(y):"r"(a),"r"(b));
> now what should technically happen is the value in b
> should move to x but the fun part is y is also
> initialised by same value. why is it so and from where
> this value comes from
The compiler does not interpret the "movb %3,%0" part of this asm
statement, except to substitute %-escapes when writing out the .s
file. It only looks at the constraints. You wrote constraints that
say the asm reads values from the variables (a) and (b), which must be
in registers; and then writes values to the variables (x) and (y),
which must also be in registers. The compiler believes you. It is
your responsibility to write the actual assembly instructions to be
consistent with the constraints; in this case it appears that you
didn't, which is a bug in your code.
There is no implication that the values written to (a) and (b) be the
same. I don't know where you got that idea.
zw