It seems like the problem is in the ASM part, but I don't remember enough of my ASM classes to help you with that.
Also it seems like only src2 is causing issue, because the following code is working for me, may be it can help you finding the problem in your ASM code :
Code:
#include<stdio.h>
#include<string.h>
static inline char * asm_str_concat(char *d, char *s1, char *s2)
{
int rsrc1, rdest,rsrc2;
__asm__ __volatile__(
"1:lodsb\n\t;"
"stosb\n\t;"
"testb %%al,%%al\n\t;"
"jne 1b;"
"dec %%di;"
"movl %%ecx,%0;"
"2:lodsb\n\t;"
"stosb\n\t;"
"testb %%al,%%al\n\t;"
"jne 2b;"
: "=&S" (rsrc2), "=&D" (rdest),"=a"(s2)
: "0" (s2),"1" (d),"c" (s1)
);
return d;
}
int main(int argc,char *argv[])
{
char dest2[512];
char *src1;
char *src2;
char *d2;
src1=argv[1];
src2="test";//argv[2];
printf("%s\n",src1);
printf("%s\n",src2);
d2 = asm_str_concat(dest2, src2,src1 );
printf("%s\n",dest2);
return 0;
}