changeset 93:a675cec34076

target-utils/libc: assembly implementation of bcmp/memcmp
author Mychaela Falconia <falcon@freecalypso.org>
date Sat, 29 Oct 2016 00:15:12 +0000
parents bfed7a5c21a6
children cbc6bc05d494
files target-utils/libc/Makefile target-utils/libc/memcmp.S
diffstat 2 files changed, 23 insertions(+), 3 deletions(-) [+]
line wrap: on
line diff
--- a/target-utils/libc/Makefile	Fri Oct 28 23:45:49 2016 +0000
+++ b/target-utils/libc/Makefile	Sat Oct 29 00:15:12 2016 +0000
@@ -4,9 +4,9 @@
 AR=	arm-elf-ar
 RANLIB=	arm-elf-ranlib
 
-OBJS=	atoi.o bzero.o ctype_.o index.o memcpy.o memcpy16.o memcpy32.o memset.o\
-	rindex.o strcasecmp.o strcat.o strcmp.o strcpy.o strncat.o strncmp.o \
-	strncpy.o
+OBJS=	atoi.o bzero.o ctype_.o index.o memcmp.o memcpy.o memcpy16.o memcpy32.o\
+	memset.o rindex.o strcasecmp.o strcat.o strcmp.o strcpy.o strncat.o \
+	strncmp.o strncpy.o
 
 all:	libc.a
 
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/target-utils/libc/memcmp.S	Sat Oct 29 00:15:12 2016 +0000
@@ -0,0 +1,20 @@
+	.text
+	.code	32
+	.globl	bcmp
+	.globl	memcmp
+bcmp:
+memcmp:
+	cmp	r2, #0
+	beq	zero_len_out
+	mov	r3, r0
+1:	ldrb	r0, [r3], #1
+	ldrb	r12, [r1], #1
+	subs	r0, r0, r12
+	bxne	lr
+	subs	r2, r2, #1
+	bne	1b
+	bx	lr
+
+zero_len_out:
+	mov	r0, #0
+	bx	lr