labels in extended asm

Adam Reid areid@lumerical.com
Wed Jan 25 01:12:00 GMT 2006


Hi,

I am wondering if someone can show me an example of how to use local labels in
extended asm? I would like to be able to put a line of extended asm into an
inline function without having the labels duplicated each time the function is
inlined by the compiler. I have heard that this is possible using the "%ldigit"
feature of the output templates, but I can't figure out how to use this feature.
The following is an example of the type of function I'd like to write:

inline void memcopy(int *A, int *B, int len){

    asm volatile("shl $2, %%ecx;\n\t"
                 "xorl %%edx, %%edx;\n"
                 "myloop:\n\t"
                 "movl (%%eax, %%edx), %%esi;\n\t"
                 "movl %%esi, (%%ebx, %%edx);\n\t"
                 "addl $4, %%edx;\n\t"
                 "cmpl %%ecx, %%edx;\n\t"
                 "jl myloop;"
                :
                :"c" (len), "a" (A), "b" (B)
                :"edx", "esi", "memory"
                );

   return();
}

Thanks for your help,

Adam



More information about the Gcc-help mailing list