Skip to content

Instantly share code, notes, and snippets.

@kvannotten
Created January 1, 2011 13:48
Show Gist options
  • Save kvannotten/761759 to your computer and use it in GitHub Desktop.
Save kvannotten/761759 to your computer and use it in GitHub Desktop.
Copying a string using asm
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;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment