install approved copyright notice
[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 *
5 * Redistribution and use in source and binary forms are permitted
f4f66d2c
KB
6 * provided that the above copyright notice and this paragraph are
7 * duplicated in all such forms and that any documentation,
8 * advertising materials, and other materials related to such
9 * distribution and use acknowledge that the software was developed
10 * by the University of California, Berkeley. The name of the
11 * University may not be used to endorse or promote products derived
12 * from this software without specific prior written permission.
13 * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR
14 * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
15 * WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
586c39b1
DF
16 */
17
f4f66d2c
KB
18#if defined(LIBC_SCCS) && !defined(lint)
19 .asciz "@(#)strcmp.s 5.5 (Berkeley) %G%"
20#endif /* LIBC_SCCS and not lint */
1e9489b5
SL
21
22/*
23 * Compare string s1 lexicographically to string s2.
24 * Return:
25 * 0 s1 == s2
26 * > 0 s1 > s2
27 * < 0 s2 < s2
28 *
29 * strcmp(s1, s2)
30 * char *s1, *s2;
31 */
dadab5a2 32#include "DEFS.h"
1e9489b5 33
dadab5a2 34ENTRY(strcmp, 0)
3d8a65a3
KM
35 movl 4(ap),r1 # r1 = s1
36 movl 8(ap),r3 # r3 = s2
9cb3659c
KM
37 subb3 (r3),(r1),r0 # quick check for first char different
38 beql 1f # have to keep checking
39 cvtbl r0,r0
40 ret
1e9489b5 411:
009a82a7
KM
42 clrl r5 # calculate min bytes to next page boundry
43 subb3 r1,$255,r5 # r5 = (bytes - 1) to end of page for s1
44 subb3 r3,$255,r0 # r0 = (bytes - 1) to end of page for s2
45 cmpb r0,r5 # r5 = min(r0, r5);
46 bgtru 2f
47 movb r0,r5
482:
49 incl r5 # r5 = min bytes to next page boundry
50 cmpc3 r5,(r1),(r3) # compare strings
51 bneq 3f
52 subl2 r5,r1 # check if found null yet
53 locc $0,r5,(r1)
54 beql 1b # not yet done, continue checking
55 subl2 r0,r3
5a6eac85 56 mnegb (r3),r0 # r0 = '\0' - *s2
3d8a65a3
KM
57 cvtbl r0,r0
58 ret
009a82a7
KM
593:
60 subl2 r0,r5 # check for null in matching string
61 subl2 r5,r1
62 locc $0,r5,(r1)
63 bneq 4f
5a6eac85 64 subb3 (r3),(r1),r0 # r0 = *s1 - *s2
1e9489b5
SL
65 cvtbl r0,r0
66 ret
009a82a7 674:
3d8a65a3
KM
68 clrl r0 # both the same to null
69 ret