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: Fwd: extended asm


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


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