flag fields are u_int's
[unix-history] / usr / src / lib / libc / vax / string / strcmp.s
CommitLineData
586c39b1
DF
1/*
2 * Copyright (c) 1983 Regents of the University of California.
493b70ca
KB
3 * All rights reserved.
4 *
019bea33 5 * %sccs.include.redist.c%
586c39b1
DF
6 */
7
f4f66d2c 8#if defined(LIBC_SCCS) && !defined(lint)
019bea33 9 .asciz "@(#)strcmp.s 5.6 (Berkeley) %G%"
f4f66d2c 10#endif /* LIBC_SCCS and not lint */
1e9489b5
SL
11
12/*
13 * Compare string s1 lexicographically to string s2.
14 * Return:
15 * 0 s1 == s2
16 * > 0 s1 > s2
17 * < 0 s2 < s2
18 *
19 * strcmp(s1, s2)
20 * char *s1, *s2;
21 */
dadab5a2 22#include "DEFS.h"
1e9489b5 23
dadab5a2 24ENTRY(strcmp, 0)
3d8a65a3
KM
25 movl 4(ap),r1 # r1 = s1
26 movl 8(ap),r3 # r3 = s2
9cb3659c
KM
27 subb3 (r3),(r1),r0 # quick check for first char different
28 beql 1f # have to keep checking
29 cvtbl r0,r0
30 ret
1e9489b5 311:
009a82a7
KM
32 clrl r5 # calculate min bytes to next page boundry
33 subb3 r1,$255,r5 # r5 = (bytes - 1) to end of page for s1
34 subb3 r3,$255,r0 # r0 = (bytes - 1) to end of page for s2
35 cmpb r0,r5 # r5 = min(r0, r5);
36 bgtru 2f
37 movb r0,r5
382:
39 incl r5 # r5 = min bytes to next page boundry
40 cmpc3 r5,(r1),(r3) # compare strings
41 bneq 3f
42 subl2 r5,r1 # check if found null yet
43 locc $0,r5,(r1)
44 beql 1b # not yet done, continue checking
45 subl2 r0,r3
5a6eac85 46 mnegb (r3),r0 # r0 = '\0' - *s2
3d8a65a3
KM
47 cvtbl r0,r0
48 ret
009a82a7
KM
493:
50 subl2 r0,r5 # check for null in matching string
51 subl2 r5,r1
52 locc $0,r5,(r1)
53 bneq 4f
5a6eac85 54 subb3 (r3),(r1),r0 # r0 = *s1 - *s2
1e9489b5
SL
55 cvtbl r0,r0
56 ret
009a82a7 574:
3d8a65a3
KM
58 clrl r0 # both the same to null
59 ret