BITS 64
mov n, %rcx
mov s, %rsi
mov d, %rdi
rep movs[bwlq]
?
Kind of like __movs[bwdq](d, s, n) intrinsic in MSVC.
But gcc's __builtin_movsd is _mm_movsd, which is not what I wanted at
all.
Pardon my ASM, I'm used to Intel syntax.
Your best chance is __builtin_memcpy(), but it may not generate a rep movs[x].
It's pros:
- (mostly) always inlined memcpy
- compiler can use knowledge of copy (alignment, size) to strenght reduce stuff
Cons:
- Compiler is still free to not use rep movs[x]
- Compiler may still get it wrong (can not deduce size at compile time, etc.)
Otherwise you have to use inline asm. This way you can "build" your own
compatible substitute for __movs[bwdq].
like in a header compat_helper.h:
#ifdef __GNUC__
static inline void *__movsb(void *d, const void *s, size_t n)
{
asm("rep movsb"
: "=D" (d),
"=S" (s),
"=c" (n)
: "0" (d),
"1" (s),
"2" (n)
: "memory");
return d;
}
static inline void *__movsw(void *d, const void *s, size_t n)
{
asm("rep movsw"
: "=D" (d),
"=S" (s),
"=c" (n)
: "0" (d),
"1" (s),
"2" (n/2)
: "memory");
return d;
}
...
#elif defined(__MSVC__)
/* nothing */
#else
# error "no compat helper for your compiler"
#endif
Greetings
Jan
--
/home
sweet
/home