xref: /csrg-svn/lib/libc/vax/string/strcmp.s (revision 17483)
1/*	strcmp.s	4.5	84/12/06	*/
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
181:
19	clrl	r5		# calculate min bytes to next page boundry
20	subb3	r1,$255,r5	# r5 = (bytes - 1) to end of page for s1
21	subb3	r3,$255,r0	# r0 = (bytes - 1) to end of page for s2
22	cmpb	r0,r5		# r5 = min(r0, r5);
23	bgtru	2f
24	movb	r0,r5
252:
26	incl	r5		# r5 = min bytes to next page boundry
27	cmpc3	r5,(r1),(r3)	# compare strings
28	bneq	3f
29	subl2	r5,r1		# check if found null yet
30	locc	$0,r5,(r1)
31	beql	1b		# not yet done, continue checking
32	subl2	r0,r3
33	mnegb	(r3),r0		# r0 = '\0' - *s2
34	cvtbl	r0,r0
35	ret
363:
37	subl2	r0,r5		# check for null in matching string
38	subl2	r5,r1
39	locc	$0,r5,(r1)
40	bneq	4f
41	subb3	(r3),(r1),r0	# r0 = *s1 - *s2
42	cvtbl	r0,r0
43	ret
444:
45	clrl	r0		# both the same to null
46	ret
47