1/* 2 * Copyright (c) 1983 Regents of the University of California. 3 * All rights reserved. 4 * 5 * %sccs.include.redist.c% 6 */ 7 8#if defined(LIBC_SCCS) && !defined(lint) 9 .asciz "@(#)strcmp.s 5.6 (Berkeley) 06/01/90" 10#endif /* LIBC_SCCS and not lint */ 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 */ 22#include "DEFS.h" 23 24ENTRY(strcmp, 0) 25 movl 4(ap),r1 # r1 = s1 26 movl 8(ap),r3 # r3 = s2 27 subb3 (r3),(r1),r0 # quick check for first char different 28 beql 1f # have to keep checking 29 cvtbl r0,r0 30 ret 311: 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 46 mnegb (r3),r0 # r0 = '\0' - *s2 47 cvtbl r0,r0 48 ret 493: 50 subl2 r0,r5 # check for null in matching string 51 subl2 r5,r1 52 locc $0,r5,(r1) 53 bneq 4f 54 subb3 (r3),(r1),r0 # r0 = *s1 - *s2 55 cvtbl r0,r0 56 ret 574: 58 clrl r0 # both the same to null 59 ret 60