1/* strcmp.s 4.3 84/11/14 */ 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 mnegb -32(r0)[r3],r0 # r0 = $0 - *s2 24 cvtbl r0,r0 25 ret 262: 27 subl3 r0,$32,r0 # check for null in matching string 28 subl2 r0,r1 29 locc $0,r0,(r1) 30 bneq 3f 31 subb3 (r3),-(r1),r0 # r0 = *s1 - *s2 32 cvtbl r0,r0 33 ret 343: 35 clrl r0 # both the same to null 36 ret 37