1: /* 2: * Copyright (c) 1987 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: #ifdef LIBC_SCCS 8: <@(#)strcmp.s 1.1 (Berkeley) 1/21/87\0> 9: .even 10: #endif LIBC_SCCS 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: 24: ENTRY(strcmp) 25: mov 2(sp),r0 / r0 = s1 26: mov 4(sp),r1 / r1 = s2 27: 1: 28: cmpb (r0)+,(r1) / compare the two strings 29: bne 2f / stop on first mismatch 30: tstb (r1)+ / but don't pass end of either string 31: bne 1b 32: clr r0 / fell off end of strings with '\0' == '\0` 33: rts pc / - success! return zero 34: 2: 35: movb -(r0),r0 / mismatch, return *s1 - *s2 ... 36: movb (r1),r1 / (no subb instruction ...) 37: sub r1,r0 38: rts pc