summaryrefslogtreecommitdiff
path: root/src/string/i386
diff options
context:
space:
mode:
authorRich Felker <dalias@aerifal.cx>2012-09-10 19:04:24 -0400
committerRich Felker <dalias@aerifal.cx>2012-09-10 19:04:24 -0400
commit2bf469310de6793228c103691859ed4d3158b117 (patch)
treeb292372faf231031dbe9404efb081fdf341ff719 /src/string/i386
parenta9555a995cea8aa67da571c95af61109140f2c8d (diff)
downloadmusl-2bf469310de6793228c103691859ed4d3158b117.tar.gz
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.
Diffstat (limited to 'src/string/i386')
-rw-r--r--src/string/i386/memmove.s21
1 files changed, 21 insertions, 0 deletions
diff --git a/src/string/i386/memmove.s b/src/string/i386/memmove.s
new file mode 100644
index 00000000..6e6cc8e3
--- /dev/null
+++ b/src/string/i386/memmove.s
@@ -0,0 +1,21 @@
+.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