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.
This commit is contained in:
parent
a9555a995c
commit
2bf469310d
2 changed files with 36 additions and 0 deletions
15
src/string/x86_64/memmove.s
Normal file
15
src/string/x86_64/memmove.s
Normal file
|
|
@ -0,0 +1,15 @@
|
|||
.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
|
||||
Loading…
Add table
Add a link
Reference in a new issue