xref: /csrg-svn/lib/libc/vax/string/strcmp.s (revision 18716)
1/*	strcmp.s	4.6	85/04/24	*/
2
3/*
4 * Compare string s1 lexicographically to string s2.
5 * Return:
6 *	0	s1 == s2
7 *	> 0	s1 > s2
8 *	< 0	s2 < s2
9 *
10 * strcmp(s1, s2)
11 *	char *s1, *s2;
12 */
13#include "DEFS.h"
14
15ENTRY(strcmp, 0)
16	movl	4(ap),r1	# r1 = s1
17	movl	8(ap),r3	# r3 = s2
18	subb3	(r3),(r1),r0	# quick check for first char different
19	beql	1f		# have to keep checking
20	cvtbl	r0,r0
21	ret
221:
23	clrl	r5		# calculate min bytes to next page boundry
24	subb3	r1,$255,r5	# r5 = (bytes - 1) to end of page for s1
25	subb3	r3,$255,r0	# r0 = (bytes - 1) to end of page for s2
26	cmpb	r0,r5		# r5 = min(r0, r5);
27	bgtru	2f
28	movb	r0,r5
292:
30	incl	r5		# r5 = min bytes to next page boundry
31	cmpc3	r5,(r1),(r3)	# compare strings
32	bneq	3f
33	subl2	r5,r1		# check if found null yet
34	locc	$0,r5,(r1)
35	beql	1b		# not yet done, continue checking
36	subl2	r0,r3
37	mnegb	(r3),r0		# r0 = '\0' - *s2
38	cvtbl	r0,r0
39	ret
403:
41	subl2	r0,r5		# check for null in matching string
42	subl2	r5,r1
43	locc	$0,r5,(r1)
44	bneq	4f
45	subb3	(r3),(r1),r0	# r0 = *s1 - *s2
46	cvtbl	r0,r0
47	ret
484:
49	clrl	r0		# both the same to null
50	ret
51