summaryrefslogtreecommitdiffstats
path: root/newlib/libc/machine/i386/memchr.S
diff options
context:
space:
mode:
Diffstat (limited to 'newlib/libc/machine/i386/memchr.S')
-rw-r--r--newlib/libc/machine/i386/memchr.S23
1 files changed, 22 insertions, 1 deletions
diff --git a/newlib/libc/machine/i386/memchr.S b/newlib/libc/machine/i386/memchr.S
index 7639685be..d9b0bf2b7 100644
--- a/newlib/libc/machine/i386/memchr.S
+++ b/newlib/libc/machine/i386/memchr.S
@@ -14,13 +14,33 @@
SOTYPE_FUNCTION(memchr)
SYM (memchr):
+#ifdef __iamcu__
+ pushl edi
+ movl eax,edi
+ movl edx,eax
+ xorl edx,edx
+ testl ecx,ecx
+ jz L20
+
+ repnz
+ scasb
+
+ setnz dl
+ decl edi
+
+ decl edx
+ andl edi,edx
+L20:
+ movl edx,eax
+
+ popl edi
+#else
pushl ebp
movl esp,ebp
pushl edi
movzbl 12(ebp),eax
movl 16(ebp),ecx
movl 8(ebp),edi
-
xorl edx,edx
testl ecx,ecx
jz L20
@@ -111,4 +131,5 @@ L20:
leal -4(ebp),esp
popl edi
leave
+#endif
ret