From f486d77a925d187878dc2edd704955178052cd1e Mon Sep 17 00:00:00 2001 From: jtc Date: Sun, 18 May 1997 21:24:46 +0000 Subject: [PATCH] I removed the extra instructions which compute the return value in Hiroshi Horitomo's implementation a bit too hastily. They are required to handle the unsigned comparison required by the standard. --- lib/libc/arch/m68k/string/strcmp.S | 30 ++++++++++-------- lib/libc/arch/m68k/string/strncmp.S | 47 +++++++++++++++-------------- 2 files changed, 42 insertions(+), 35 deletions(-) diff --git a/lib/libc/arch/m68k/string/strcmp.S b/lib/libc/arch/m68k/string/strcmp.S index 7b27384efe25..e17a2da339e0 100644 --- a/lib/libc/arch/m68k/string/strcmp.S +++ b/lib/libc/arch/m68k/string/strcmp.S @@ -1,10 +1,11 @@ -/* $NetBSD: strcmp.S,v 1.9 1997/05/18 20:32:20 jtc Exp $ */ +/* $NetBSD: strcmp.S,v 1.10 1997/05/18 21:24:46 jtc Exp $ */ /*- * Copyright (c) 1997 The NetBSD Foundation, Inc. * All rights reserved. * * This code is derived from software contributed to The NetBSD Foundation + * by Hiroshi Horitomo and * by J.T. Conklin . * * Redistribution and use in source and binary forms, with or without @@ -39,35 +40,40 @@ #include #if defined(LIBC_SCCS) && !defined(lint) - RCSID("$NetBSD: strcmp.S,v 1.9 1997/05/18 20:32:20 jtc Exp $") + RCSID("$NetBSD: strcmp.S,v 1.10 1997/05/18 21:24:46 jtc Exp $") #endif /* LIBC_SCCS and not lint */ ENTRY(strcmp) movl sp@(4),a0 movl sp@(8),a1 L1: /* unrolled by 4 for 680[23]0's */ - movb a0@+,d0 + movb a0@+,d1 jeq L2 - subb a1@+,d0 + subb a1@+,d1 jne L3 - movb a0@+,d0 + movb a0@+,d1 jeq L2 - subb a1@+,d0 + subb a1@+,d1 jne L3 - movb a0@+,d0 + movb a0@+,d1 jeq L2 - subb a1@+,d0 + subb a1@+,d1 jne L3 - movb a0@+,d0 + movb a0@+,d1 jeq L2 - subb a1@+,d0 + subb a1@+,d1 jeq L1 + + scs d0 extbl d0 + movb d1,d0 rts -L2: subb a1@,d0 -L3: extbl d0 +L2: subb a1@,d1 +L3: scs d0 + extbl d0 + movb d1,d0 rts diff --git a/lib/libc/arch/m68k/string/strncmp.S b/lib/libc/arch/m68k/string/strncmp.S index 5bc5bad543c9..a3cb1379a00f 100644 --- a/lib/libc/arch/m68k/string/strncmp.S +++ b/lib/libc/arch/m68k/string/strncmp.S @@ -1,10 +1,11 @@ -/* $NetBSD: strncmp.S,v 1.8 1997/05/18 20:32:21 jtc Exp $ */ +/* $NetBSD: strncmp.S,v 1.9 1997/05/18 21:24:48 jtc Exp $ */ /*- * Copyright (c) 1997 The NetBSD Foundation, Inc. * All rights reserved. * * This code is derived from software contributed to The NetBSD Foundation + * by Hiroshi Horitomo and * by J.T. Conklin . * * Redistribution and use in source and binary forms, with or without @@ -39,46 +40,46 @@ #include #if defined(LIBC_SCCS) && !defined(lint) - RCSID("$NetBSD: strncmp.S,v 1.8 1997/05/18 20:32:21 jtc Exp $") + RCSID("$NetBSD: strncmp.S,v 1.9 1997/05/18 21:24:48 jtc Exp $") #endif /* LIBC_SCCS and not lint */ ENTRY(strncmp) - movl sp@(12),d1 + movl sp@(12),d0 jeq L4 movl sp@(4),a0 movl sp@(8),a1 L1: /* unroll by 4 for m680[23]0's */ - movb a0@+,d0 + movb a0@+,d1 jeq L2 - subb a1@+,d0 + subb a1@+,d1 jne L3 - subql #1,d1 - jne L4 + subql #1,d0 + jeq L4 - movb a0@+,d0 + movb a0@+,d1 jeq L2 - subb a1@+,d0 + subb a1@+,d1 jne L3 - subql #1,d1 - jne L4 + subql #1,d0 + jeq L4 - movb a0@+,d0 + movb a0@+,d1 jeq L2 - subb a1@+,d0 + subb a1@+,d1 jne L3 - subql #1,d1 - jne L4 + subql #1,d0 + jeq L4 - movb a0@+,d0 + movb a0@+,d1 jeq L2 - subb a1@+,d0 + subb a1@+,d1 jne L3 - subql #1,d1 + subql #1,d0 jne L1 +L4: rts -L4: moveq #0,d0 - rts - -L2: subb a1@,d0 -L3: extbl d0 +L2: subb a1@,d1 +L3: scs d0 + extbl d0 + movb d1,d0 rts