Re: memmove.S for i386
Johannes Vetter <[email protected]>
| Newsgroups | gmane.linux.lib.dietlibc |
|---|---|
| Message-ID | <[email protected]> |
Hi, your function should be ok. "ja" could be optimized to "jae" (same size and better speed in senseless case (dest==src)). >>> void *memmove(void *dest, const void *src, size_t n); movsb is only a good choice for small n. You should use movsd instead, if there is enough codespace. There are reference-implementations of memcpy and memmove at Intels- and AMDs-documentation. momsq and MMX-Code can be an alternative for newer instruction sets. Best regards, Johannes Nikola Vladov schrieb: > Can some assembler guru verify next function? For me it works fine. > I'm not shure on cmpl and ja bellow. > > ------------------------- > /* public domain. author: Nikola Vladov */ > ..text > ..align 0 > ..global memmove > ..type memmove,@function > memmove: > pushl %esi > pushl %edi > movl 12(%esp),%edi > movl 16(%esp),%esi > movl 20(%esp),%ecx > movl %edi, %eax > cld > > cmpl %edi, %esi > ja .L1 > > std > decl %edi > decl %esi > addl %ecx, %edi > addl %ecx, %esi > ..L1: > rep movsb > cld > > popl %edi > popl %esi > ret >