Mail Archives: djgpp/1997/06/05/18:09:36
The following macros are about as fast as you're going to get. They accept
words rather than bytes, as they copy 4 bytes at a time.
1 WORD = 4 BYTES, so when you tell it how many words to copy, make sure
it's the (# OF BYTES/4)
The following are stolen from Brennan's AT&T Assembly FAQ, I think.
#define quad_memcpy(src, dest, numwords) \
__asm__ __volatile__ ( \
"cld\n\t" \
"rep\n\t" \
"movsl" \
: : "S" (src), "D" (dest), "c" (numwords) \
: "%ecx", "%esi", "%edi" )
#define quad_memset(value, dest, numwords) \
__asm__ __volatile__ ( \
"cld\n\t" \
"rep\n\t" \
"stosl" \
: : "a" (value), "D" (dest), "c" (numwords) \
: "%ecx", "%edi" )
- Raw text -