I'm new to AT&T assembly language. I read this from linux source code(kernel 2.4.0 include/asm_i386/string).
static inline void * __memcpy(void * to, const void * from, size_t n)
{
int d0, d1, d2;
__asm__ __volatile__(
"rep ; movsl\n\t"
"testb $2,%b4\n\t"
"je 1f\n\t"
"movsw\n"
"1:\ttestb $1,%b4\n\t"
"je 2f\n\t"
"movsb\n"
"2:"
: "=&c" (d0), "=&D" (d1), "=&S" (d2)
:"0" (n/4), "q" (n),"1" ((long) to),"2" ((long) from)
: "memory");
return (to);
}
I wonder whether the temporary variables d0,d1,d2 are necessary here.
Can it be this way?
static inline void * __memcpy(void * to, const void * from, size_t n)
{
__asm__ __volatile__(
"rep ; movsl\n\t"
"testb $2,%b4\n\t"
"je 1f\n\t"
"movsw\n"
"1:\ttestb $1,%b4\n\t"
"je 2f\n\t"
"movsb\n"
"2:"
:
:"c" (n/4), "&q" (n),"D" ((long) to),"S" ((long) from)
: "memory");
return (to);
If can, what the differences are?
Please help...thanks