问问题
1787 次
2 回答
2
You have an empty entry in your clobber section. You don't need that.
Try this:
asm("mov %0, %1"
: "=m" (dst)
: "m" (dst),
"m" (src)
/* no clobbers */
);
That code is precisely equivalent to this:
*dst = *src
so I presume this is just small example?
The code compiles, but gives:
t.c: Assembler messages:
t.c:2: Error: too many memory references for `mov'
So I think your assembler instruction needs work, but the compiler syntax is OK.
于 2013-10-30T12:12:23.120 回答
0
You can use:
void copy(int *dst, int *src)
{
__asm__ __volatile__(
"movl (%0), %%eax\n"
"movl %%eax, (%1)\n"
:
: "r"(src), "r"(dst)
: "%eax"
);
}
which is equivalent to:
mov (%edx), %eax ; eax = *src
mov %eax, (%ecx) ; *dst = eax
于 2013-10-30T16:34:52.403 回答