1/*- 2 * Copyright (c) 1990 The Regents of the University of California. 3 * All rights reserved. 4 * 5 * This code is derived from locore.s. 6 * 7 * Redistribution and use in source and binary forms, with or without 8 * modification, are permitted provided that the following conditions 9 * are met: 10 * 1. Redistributions of source code must retain the above copyright 11 * notice, this list of conditions and the following disclaimer. 12 * 2. Redistributions in binary form must reproduce the above copyright 13 * notice, this list of conditions and the following disclaimer in the 14 * documentation and/or other materials provided with the distribution. 15 * 3. Neither the name of the University nor the names of its contributors 16 * may be used to endorse or promote products derived from this software 17 * without specific prior written permission. 18 * 19 * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND 20 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 21 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 22 * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE 23 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 24 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 25 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 26 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 27 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 28 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 29 * SUCH DAMAGE. 30 */ 31 32#include <machine/asm.h> 33#if 0 34 RCSID("$NetBSD: bcopy.S,v 1.6 1996/11/12 00:50:06 jtc Exp $") 35#endif 36 37 /* 38 * (ov)bcopy (src,dst,cnt) 39 * ws@tools.de (Wolfgang Solfrank, TooLs GmbH) +49-228-985800 40 */ 41 42#ifdef MEMCOPY 43ENTRY(memcpy) 44#else 45#ifdef MEMMOVE 46ENTRY(memmove) 47#else 48ENTRY(bcopy) 49#endif 50#endif 51 pushl %esi 52 pushl %edi 53#if defined(MEMCOPY) || defined(MEMMOVE) 54 movl 12(%esp),%edi 55 movl 16(%esp),%esi 56 movl %edi,%eax 57#else 58 movl 12(%esp),%esi 59 movl 16(%esp),%edi 60#endif 61 movl 20(%esp),%ecx 62 movl %edi,%edx 63 subl %esi,%edx 64 cmpl %ecx,%edx /* overlapping? */ 65 jb 2f 66 cld /* nope, copy forwards. */ 67 movl %ecx,%edx 68 shrl $2,%ecx /* copy by words */ 69 rep 70 movsl 71 movl %edx,%ecx 72 andl $3,%ecx /* any bytes left? */ 73 jne 1f 74 popl %edi 75 popl %esi 76 ret 771: 78 rep 79 movsb 80 popl %edi 81 popl %esi 82 ret 832: 84 addl %ecx,%edi /* copy backwards. */ 85 addl %ecx,%esi 86 std 87 movl %ecx,%edx 88 decl %edi 89 decl %esi 90 andl $3,%ecx /* any fractional bytes? */ 91 je 3f 92 rep 93 movsb 943: 95 movl %edx,%ecx /* copy remainder by words */ 96 shrl $2,%ecx 97 subl $3,%esi 98 subl $3,%edi 99 rep 100 movsl 101 popl %edi 102 popl %esi 103 cld 104 ret 105#ifdef MEMCOPY 106END(memcpy) 107#else 108#ifdef MEMMOVE 109END(memmove) 110#else 111END(bcopy) 112#endif 113#endif 114 115 .section .note.GNU-stack,"",%progbits 116