1/* strcmp.s 4.4 84/12/02 */ 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 cmpc3 $32,(r1),(r3) # compare strings 20 bneq 2f 21 locc $0,$32,-32(r1) # check if contain null 22 beql 1b 23 subl2 r0,r3 # back up r3 to same point 24 mnegb (r3),r0 # r0 = '\0' - *s2 25 cvtbl r0,r0 26 ret 272: 28 subl3 r0,$32,r0 # check for null in matching string 29 subl2 r0,r1 30 locc $0,r0,(r1) 31 bneq 3f 32 subb3 (r3),(r1),r0 # r0 = *s1 - *s2 33 cvtbl r0,r0 34 ret 353: 36 clrl r0 # both the same to null 37 ret 38