1/* $NetBSD: strncmp.S,v 1.6 2013/07/19 16:42:12 matt Exp $ */ 2 3/*- 4 * Copyright (c) 1997 The NetBSD Foundation, Inc. 5 * All rights reserved. 6 * 7 * This code is derived from software contributed to The NetBSD Foundation 8 * by Hiroshi Horimoto <horimoto@cs-aoi.cs.sist.ac.jp> and 9 * by J.T. Conklin <jtc@NetBSD.org>. 10 * 11 * Redistribution and use in source and binary forms, with or without 12 * modification, are permitted provided that the following conditions 13 * are met: 14 * 1. Redistributions of source code must retain the above copyright 15 * notice, this list of conditions and the following disclaimer. 16 * 2. Redistributions in binary form must reproduce the above copyright 17 * notice, this list of conditions and the following disclaimer in the 18 * documentation and/or other materials provided with the distribution. 19 * 20 * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS 21 * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED 22 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 23 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS 24 * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 25 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 26 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 27 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 28 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 29 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 30 * POSSIBILITY OF SUCH DAMAGE. 31 */ 32 33#include <machine/asm.h> 34 35#if defined(LIBC_SCCS) && !defined(lint) 36 RCSID("$NetBSD: strncmp.S,v 1.6 2013/07/19 16:42:12 matt Exp $") 37#endif /* LIBC_SCCS and not lint */ 38 39 40#ifdef __mcoldfire__ 41#define GETC(a,b) mvsb a,b 42#define SUBC(a,b) mvsb a,%d2; subl %d2,b 43#else 44#define GETC(a,b) movb a,b 45#define SUBC(a,b) subb a,b 46#endif 47 48ENTRY(strncmp) 49 movl 12(%sp),%d0 50 jeq .L4 51 movl 4(%sp),%a0 52 movl 8(%sp),%a1 53#ifdef __coldfire__ 54 movl %d2,-(%sp) | save temp 55#endif 56.L1: /* unroll by 4 for m680[23]0's */ 57 GETC((%a0)+,%d1) 58 jeq .L2 59 SUBC((%a1)+,%d1) 60 jne .L3 61 subql #1,%d0 62 jeq .L4 63 64 GETC((%a0)+,%d1) 65 jeq .L2 66 SUBC((%a1)+,%d1) 67 jne .L3 68 subql #1,%d0 69 jeq .L4 70 71 GETC((%a0)+,%d1) 72 jeq .L2 73 SUBC((%a1)+,%d1) 74 jne .L3 75 subql #1,%d0 76 jeq .L4 77 78 GETC((%a0)+,%d1) 79 jeq .L2 80 SUBC((%a1)+,%d1) 81 jne .L3 82 subql #1,%d0 83 jne .L1 84#ifdef __mcoldfire__ 85 movl (%sp)+,%d2 | restore temp 86#endif 87.L4: rts 88 89.L2: SUBC((%a1),%d1) 90.L3: 91#ifdef __mcoldfire__ 92 movl (%sp)+,%d2 | restore temp 93 movl %d1,%d0 94#else 95 scs %d0 96 EXTBL(%d0) 97 moveb %d1,%d0 98#endif 99 rts 100END(strncmp) 101