xref: /csrg-svn/lib/libc/tahoe/string/memcmp.s (revision 61190)
142075Sbostic/*
2*61190Sbostic * Copyright (c) 1988, 1993
3*61190Sbostic *	The Regents of the University of California.  All rights reserved.
442075Sbostic *
542643Sbostic * %sccs.include.redist.c%
642075Sbostic *
742075Sbostic * This code is derived from software contributed to Berkeley by
842075Sbostic * Computer Consoles Inc.
942075Sbostic */
1042075Sbostic
1142075Sbostic#if defined(LIBC_SCCS) && !defined(lint)
12*61190Sbostic	.asciz "@(#)memcmp.s	8.1 (Berkeley) 06/04/93"
1342075Sbostic#endif /* LIBC_SCCS and not lint */
1442075Sbostic
1542075Sbostic/*
1642075Sbostic * int
1742075Sbostic * memcmp(s1, s2, n)
1842075Sbostic *	void const *s1, const *s2;
1942075Sbostic *	size_t n;
2042075Sbostic *
2142075Sbostic * Compare up to n bytes from s1/s2.
2242075Sbostic * Return
2342075Sbostic *	= 0 if s1 == s2
2442075Sbostic *	< 0 if s1 < s2		(unsigned character comparison)
2542075Sbostic *	> 0 if s1 > s2
2642075Sbostic */
2742075Sbostic#include "DEFS.h"
2842075Sbostic
2942075SbosticENTRY(memcmp, 0)
3042075Sbostic	movl	4(fp),r0
3142075Sbostic	movl	8(fp),r1
3242075Sbostic	mnegl	12(fp),r2
3342075Sbostic	jeql	2f
3442075Sbostic1:
3542075Sbostic	cmpb	(r0),(r1)
3642075Sbostic	jneq	3f
3742075Sbostic	incl	r0
3842075Sbostic	incl	r1
3942075Sbostic	aoblss	$0,r2,1b
4042075Sbostic2:
4142075Sbostic	clrl	r0
4242075Sbostic	ret
4342075Sbostic3:
4442075Sbostic	jlssu	4f
4542075Sbostic	movl	$1,r0
4642075Sbostic	ret
4742075Sbostic4:
4842075Sbostic	mnegl	$1,r0
4942075Sbostic	ret
50