1/* 2 * Copyright (c) 1983 Regents of the University of California. 3 * All rights reserved. The Berkeley software License Agreement 4 * specifies the terms and conditions for redistribution. 5 */ 6 7#ifndef lint 8static char sccsid[] = "@(#)strcmp.s 5.1 (Berkeley) 05/30/85"; 9#endif not lint 10 11/* 12 * Compare string s1 lexicographically to string s2. 13 * Return: 14 * 0 s1 == s2 15 * > 0 s1 > s2 16 * < 0 s2 < s2 17 * 18 * strcmp(s1, s2) 19 * char *s1, *s2; 20 */ 21#include "DEFS.h" 22 23ENTRY(strcmp, 0) 24 movl 4(ap),r1 # r1 = s1 25 movl 8(ap),r3 # r3 = s2 26 subb3 (r3),(r1),r0 # quick check for first char different 27 beql 1f # have to keep checking 28 cvtbl r0,r0 29 ret 301: 31 clrl r5 # calculate min bytes to next page boundry 32 subb3 r1,$255,r5 # r5 = (bytes - 1) to end of page for s1 33 subb3 r3,$255,r0 # r0 = (bytes - 1) to end of page for s2 34 cmpb r0,r5 # r5 = min(r0, r5); 35 bgtru 2f 36 movb r0,r5 372: 38 incl r5 # r5 = min bytes to next page boundry 39 cmpc3 r5,(r1),(r3) # compare strings 40 bneq 3f 41 subl2 r5,r1 # check if found null yet 42 locc $0,r5,(r1) 43 beql 1b # not yet done, continue checking 44 subl2 r0,r3 45 mnegb (r3),r0 # r0 = '\0' - *s2 46 cvtbl r0,r0 47 ret 483: 49 subl2 r0,r5 # check for null in matching string 50 subl2 r5,r1 51 locc $0,r5,(r1) 52 bneq 4f 53 subb3 (r3),(r1),r0 # r0 = *s1 - *s2 54 cvtbl r0,r0 55 ret 564: 57 clrl r0 # both the same to null 58 ret 59