memcpy asm for i386 and x86_64

This commit is contained in:
Rich Felker 2012-08-11 21:33:13 -04:00
parent 036eaa24cf
commit aaa9eb5101
2 changed files with 51 additions and 0 deletions

29
src/string/i386/memcpy.s Normal file
View File

@ -0,0 +1,29 @@
.global memcpy
.type memcpy,@function
memcpy:
push %esi
push %edi
mov 12(%esp),%edi
mov 16(%esp),%esi
mov 20(%esp),%ecx
mov %edi,%eax
cmp $4,%ecx
jc 1f
test $3,%edi
jz 1f
2: movsb
dec %ecx
test $3,%edi
jnz 2b
1: mov %ecx,%edx
shr $2,%ecx
rep
movsl
and $3,%edx
jz 1f
2: movsb
dec %edx
jnz 2b
1: pop %edi
pop %esi
ret

View File

@ -0,0 +1,22 @@
.global memcpy
.type memcpy,@function
memcpy:
mov %rdi,%rax
cmp $8,%rdx
jc 1f
test $7,%edi
jz 1f
2: movsb
dec %rdx
test $7,%edi
jnz 2b
1: mov %rdx,%rcx
shr $3,%rcx
rep
movsq
and $7,%edx
jz 1f
2: movsb
dec %edx
jnz 2b
1: ret