142077Sbostic/*- 2*61222Sbostic * Copyright (c) 1990, 1993 3*61222Sbostic * The Regents of the University of California. All rights reserved. 442077Sbostic * 542077Sbostic * %sccs.include.redist.c% 642077Sbostic */ 742077Sbostic 842077Sbostic#if defined(LIBC_SCCS) && !defined(lint) 9*61222Sbostic .asciz "@(#)memcmp.s 8.1 (Berkeley) 06/04/93" 1042077Sbostic#endif /* LIBC_SCCS and not lint */ 1142077Sbostic 1242077Sbostic/* int memcmp(s1, s2, n) */ 1342077Sbostic 1442077Sbostic#include "DEFS.h" 1542077Sbostic 1642077SbosticENTRY(memcmp, 0) 1742077Sbostic movl 4(ap),r1 /* r1 = s1 */ 1842077Sbostic movq 8(ap),r3 /* r3 = s2; r4 = n */ 1942077Sbostic movzwl $65535,r5 2042077Sbostic0: 2142077Sbostic cmpl r4,r5 2242077Sbostic jgtru 3f /* handle stupid cmpc3 limitation */ 2342077Sbostic cmpc3 r4,(r1),(r3) /* compare */ 2442077Sbostic beql 2f /* done if same (r0 = 0) */ 2542077Sbostic1: 2642077Sbostic movzbl (r1),r0 2742077Sbostic movzbl (r3),r2 2842077Sbostic subl2 r2,r0 /* return *s1 - *s2; s1,s2 unsigned chars */ 2942077Sbostic2: 3042077Sbostic ret 3142077Sbostic3: 3242077Sbostic subl2 r5,r4 /* do 64K; adjust count */ 3342077Sbostic cmpc3 r5,(r1),(r3) 3442077Sbostic jeql 0b /* loop if same */ 3542077Sbostic jbr 1b 36