11849Swollman/*- 21849Swollman * Copyright (c) 1990 The Regents of the University of California. 31849Swollman * All rights reserved. 41849Swollman * 525043Sbde * This code is derived from locore.s. 61849Swollman * 71849Swollman * Redistribution and use in source and binary forms, with or without 81849Swollman * modification, are permitted provided that the following conditions 91849Swollman * are met: 101849Swollman * 1. Redistributions of source code must retain the above copyright 111849Swollman * notice, this list of conditions and the following disclaimer. 121849Swollman * 2. Redistributions in binary form must reproduce the above copyright 131849Swollman * notice, this list of conditions and the following disclaimer in the 141849Swollman * documentation and/or other materials provided with the distribution. 151849Swollman * 4. Neither the name of the University nor the names of its contributors 161849Swollman * may be used to endorse or promote products derived from this software 171849Swollman * without specific prior written permission. 181849Swollman * 191849Swollman * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND 201849Swollman * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 211849Swollman * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 221849Swollman * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE 231849Swollman * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 241849Swollman * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 251849Swollman * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 261849Swollman * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 271849Swollman * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 281849Swollman * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 291849Swollman * SUCH DAMAGE. 301849Swollman */ 311849Swollman 3225043Sbde#include <machine/asm.h> 3393000Sobrien__FBSDID("$FreeBSD$"); 341849Swollman 3593000Sobrien#if 0 3625043Sbde RCSID("$NetBSD: bcopy.S,v 1.6 1996/11/12 00:50:06 jtc Exp $") 3793000Sobrien#endif 381849Swollman 391849Swollman /* 401849Swollman * (ov)bcopy (src,dst,cnt) 411849Swollman * ws@tools.de (Wolfgang Solfrank, TooLs GmbH) +49-228-985800 421849Swollman */ 431849Swollman 4425043Sbde#ifdef MEMCOPY 4525043SbdeENTRY(memcpy) 4625043Sbde#else 4725043Sbde#ifdef MEMMOVE 4825043SbdeENTRY(memmove) 4925043Sbde#else 501849SwollmanENTRY(bcopy) 5125043Sbde#endif 5225043Sbde#endif 531849Swollman pushl %esi 541849Swollman pushl %edi 5525043Sbde#if defined(MEMCOPY) || defined(MEMMOVE) 5625043Sbde movl 12(%esp),%edi 5725043Sbde movl 16(%esp),%esi 58105149Ssobomax movl %edi,%eax 5925043Sbde#else 601849Swollman movl 12(%esp),%esi 611849Swollman movl 16(%esp),%edi 6225043Sbde#endif 631849Swollman movl 20(%esp),%ecx 64105149Ssobomax movl %edi,%edx 65105149Ssobomax subl %esi,%edx 66105149Ssobomax cmpl %ecx,%edx /* overlapping? */ 6713064Sdg jb 1f 681849Swollman cld /* nope, copy forwards. */ 69105149Ssobomax movl %ecx,%edx 701849Swollman shrl $2,%ecx /* copy by words */ 711849Swollman rep 721849Swollman movsl 73105149Ssobomax movl %edx,%ecx 741849Swollman andl $3,%ecx /* any bytes left? */ 751849Swollman rep 761849Swollman movsb 771849Swollman popl %edi 781849Swollman popl %esi 791849Swollman ret 801849Swollman1: 811849Swollman addl %ecx,%edi /* copy backwards. */ 821849Swollman addl %ecx,%esi 8325043Sbde std 84105149Ssobomax movl %ecx,%edx 8525043Sbde andl $3,%ecx /* any fractional bytes? */ 861849Swollman decl %edi 871849Swollman decl %esi 881849Swollman rep 891849Swollman movsb 90105149Ssobomax movl %edx,%ecx /* copy remainder by words */ 911849Swollman shrl $2,%ecx 921849Swollman subl $3,%esi 931849Swollman subl $3,%edi 941849Swollman rep 951849Swollman movsl 961849Swollman popl %edi 971849Swollman popl %esi 981849Swollman cld 991849Swollman ret 100184548Speter#ifdef MEMCOPY 101184548SpeterEND(memcpy) 102184548Speter#else 103184548Speter#ifdef MEMMOVE 104184548SpeterEND(memmove) 105184548Speter#else 106184548SpeterEND(bcopy) 107184548Speter#endif 108184548Speter#endif 109217106Skib 110217106Skib .section .note.GNU-stack,"",%progbits 111