提交 2bf46931 编写于 作者: R Rich Felker

asm for memmove on i386 and x86_64

for the sake of simplicity, I've only used rep movsb rather than
breaking up the copy for using rep movsd/q. on all modern cpus, this
seems to be fine, but if there are performance problems, there might
be a need to go back and add support for rep movsd/q.
上级 a9555a99
.global memmove
.type memmove,@function
memmove:
mov 4(%esp),%eax
sub 8(%esp),%eax
cmp 12(%esp),%eax
jae memcpy
push %esi
push %edi
mov 12(%esp),%edi
mov 16(%esp),%esi
mov 20(%esp),%ecx
lea -1(%edi,%ecx),%edi
lea -1(%esi,%ecx),%esi
std
rep movsb
cld
lea 1(%edi),%eax
pop %edi
pop %esi
ret
.global memmove
.type memmove,@function
memmove:
mov %rdi,%rax
sub %rsi,%rax
cmp %rdx,%rax
jae memcpy
mov %rdx,%rcx
lea -1(%rdi,%rdx),%rdi
lea -1(%rsi,%rdx),%rsi
std
rep movsb
cld
lea 1(%rdi),%rax
ret
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册