Created
January 1, 2011 13:48
-
-
Save kvannotten/761759 to your computer and use it in GitHub Desktop.
Copying a string using asm
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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