This is the mail archive of the
gcc@gcc.gnu.org
mailing list for the GCC project.
Re: Fwd: extended asm
- From: Ankit Jain <ankitjain1580 at yahoo dot com>
- To: Zack Weinberg <zack at codesourcery dot com>, gcc <gcc at gcc dot gnu dot org>
- Date: Tue, 27 Jul 2004 17:56:50 +0100 (BST)
- Subject: Re: Fwd: extended asm
i am sorry but io could not get what you are saying.
if u can somewhat explain me again.
"The compiler does not interpret the "movb %3,%0" part
of this asm statement, except to substitute %-escapes
when writing out the .s file." what is this .s file?
what do u mean by that compiler dont interpret the
instruction?
well i will again try to explain my problem. i am not
moving with efficiency of the program. what i am
looking at is how all this works? look at the code
below:(it is a small code)
int a=10;b=20,c=0,d=0;
asm("movl %3,%0 \n",:"=r"(c),"=r"(d):"r"(a),"r"(b));
printf("%d%d",c,d);
now this code pronts the value of c and d as 20 and
10.
now my question was when i have moved only one value
i.e b->c then d is also initialised with some value.
may be you have got my question earlier but i havent
got your answer
thanks
ankit
--- Zack Weinberg <zack@codesourcery.com> wrote: >
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
>
________________________________________________________________________
Yahoo! Messenger - Communicate instantly..."Ping"
your friends today! Download Messenger Now
http://uk.messenger.yahoo.com/download/index.html