The problem is, when the program steps to the line: stosb, it will display an error: "Program received signal SIGSEGV, Segmentation fault." I don't know why, any ideas?
Under ubuntu x86_64, using "gcc -o test test.c" to compile and link.
#include <stdio.h>
static inline char * strcpy(char * dest,const char *src)
{
int d0, d1, d2;
__asm__ __volatile__("1:\tlodsb\n\t"
"stosb\n\t"
"testb %%al,%%al\n\t"
"jne 1b"
: "=&S" (d0), "=&D" (d1), "=&a" (d2)
: "0" (src),"1" (dest)
: "memory");
return dest;
}
int main(void) {
char* src_main = "Hello_src";
char* dest_main = "Hello_des";
strcpy(dest_main, src_main);
puts(src_main);
puts(dest_main);
return 0;
}