xref: /csrg-svn/lib/libc/vax/string/strcmp.s (revision 61222)
121433Sdist/*
2*61222Sbostic * Copyright (c) 1983, 1993
3*61222Sbostic *	The Regents of the University of California.  All rights reserved.
434480Sbostic *
542639Sbostic * %sccs.include.redist.c%
621433Sdist */
717320Ssam
834819Sbostic#if defined(LIBC_SCCS) && !defined(lint)
9*61222Sbostic	.asciz "@(#)strcmp.s	8.1 (Berkeley) 06/04/93"
1034819Sbostic#endif /* LIBC_SCCS and not lint */
1121433Sdist
1217320Ssam/*
1317320Ssam * Compare string s1 lexicographically to string s2.
1417320Ssam * Return:
1517320Ssam *	0	s1 == s2
1617320Ssam *	> 0	s1 > s2
1717320Ssam *	< 0	s2 < s2
1817320Ssam *
1917320Ssam * strcmp(s1, s2)
2017320Ssam *	char *s1, *s2;
2117320Ssam */
2217329Ssam#include "DEFS.h"
2317320Ssam
2417329SsamENTRY(strcmp, 0)
2517364Smckusick	movl	4(ap),r1	# r1 = s1
2617364Smckusick	movl	8(ap),r3	# r3 = s2
2718716Smckusick	subb3	(r3),(r1),r0	# quick check for first char different
2818716Smckusick	beql	1f		# have to keep checking
2918716Smckusick	cvtbl	r0,r0
3018716Smckusick	ret
3117320Ssam1:
3217483Smckusick	clrl	r5		# calculate min bytes to next page boundry
3317483Smckusick	subb3	r1,$255,r5	# r5 = (bytes - 1) to end of page for s1
3417483Smckusick	subb3	r3,$255,r0	# r0 = (bytes - 1) to end of page for s2
3517483Smckusick	cmpb	r0,r5		# r5 = min(r0, r5);
3617483Smckusick	bgtru	2f
3717483Smckusick	movb	r0,r5
3817483Smckusick2:
3917483Smckusick	incl	r5		# r5 = min bytes to next page boundry
4017483Smckusick	cmpc3	r5,(r1),(r3)	# compare strings
4117483Smckusick	bneq	3f
4217483Smckusick	subl2	r5,r1		# check if found null yet
4317483Smckusick	locc	$0,r5,(r1)
4417483Smckusick	beql	1b		# not yet done, continue checking
4517483Smckusick	subl2	r0,r3
4617447Smckusick	mnegb	(r3),r0		# r0 = '\0' - *s2
4717364Smckusick	cvtbl	r0,r0
4817364Smckusick	ret
4917483Smckusick3:
5017483Smckusick	subl2	r0,r5		# check for null in matching string
5117483Smckusick	subl2	r5,r1
5217483Smckusick	locc	$0,r5,(r1)
5317483Smckusick	bneq	4f
5417447Smckusick	subb3	(r3),(r1),r0	# r0 = *s1 - *s2
5517320Ssam	cvtbl	r0,r0
5617320Ssam	ret
5717483Smckusick4:
5817364Smckusick	clrl	r0		# both the same to null
5917364Smckusick	ret
60