memcpy.S revision 1.2
11.1Sjoerg/* $NetBSD: memcpy.S,v 1.2 2014/05/23 03:17:31 uebayasi Exp $ */ 21.1Sjoerg/*- 31.1Sjoerg * Copyright (c) 2011 The NetBSD Foundation, Inc. 41.1Sjoerg * All rights reserved. 51.1Sjoerg * 61.1Sjoerg * This code is derived from software contributed to The NetBSD Foundation 71.1Sjoerg * by Joerg Sonnenberger. 81.1Sjoerg * 91.1Sjoerg * Redistribution and use in source and binary forms, with or without 101.1Sjoerg * modification, are permitted provided that the following conditions 111.1Sjoerg * are met: 121.1Sjoerg * 1. Redistributions of source code must retain the above copyright 131.1Sjoerg * notice, this list of conditions and the following disclaimer. 141.1Sjoerg * 2. Redistributions in binary form must reproduce the above copyright 151.1Sjoerg * notice, this list of conditions and the following disclaimer in the 161.1Sjoerg * documentation and/or other materials provided with the distribution. 171.1Sjoerg * 181.1Sjoerg * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS 191.1Sjoerg * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED 201.1Sjoerg * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 211.1Sjoerg * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS 221.1Sjoerg * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 231.1Sjoerg * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 241.1Sjoerg * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 251.1Sjoerg * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 261.1Sjoerg * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 271.1Sjoerg * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 281.1Sjoerg * POSSIBILITY OF SUCH DAMAGE. 291.1Sjoerg */ 301.1Sjoerg 311.1Sjoerg#include <machine/asm.h> 321.2Suebayasi RCSID("$NetBSD: memcpy.S,v 1.2 2014/05/23 03:17:31 uebayasi Exp $") 331.1Sjoerg 341.1Sjoerg# ifdef BCOPY 351.1SjoergENTRY(bcopy) 361.1Sjoerg pushl %esi 371.1Sjoerg pushl %edi 381.1Sjoerg movl 12(%esp), %esi 391.1Sjoerg movl 16(%esp), %edi 401.1Sjoerg jmp __memmove_start 411.1Sjoerg# endif 421.1Sjoerg# if defined(MEMMOVE) 431.1SjoergENTRY(memcpy) 441.1SjoergENTRY(memmove) 451.1Sjoerg pushl %esi 461.1Sjoerg pushl %edi 471.1Sjoerg movl 12(%esp), %edi 481.1Sjoerg movl 16(%esp), %esi 491.1Sjoerg .globl __memmove_start 501.1Sjoerg__memmove_start: 511.1Sjoerg movl 20(%esp), %ecx 521.1Sjoerg pushl %edi 531.1Sjoerg testl %ecx, %ecx 541.1Sjoerg jz 2f 551.1Sjoerg cmpl %esi, %edi 561.1Sjoerg jb 1f 571.1Sjoerg addl %ecx, %esi 581.1Sjoerg decl %esi 591.1Sjoerg addl %ecx, %edi 601.1Sjoerg decl %edi 611.1Sjoerg std 621.1Sjoerg1: 631.1Sjoerg rep 641.1Sjoerg movsb 651.1Sjoerg2: 661.1Sjoerg cld 671.1Sjoerg popl %eax 681.1Sjoerg popl %edi 691.1Sjoerg popl %esi 701.1Sjoerg ret 711.2SuebayasiEND(memcpy) 721.2SuebayasiEND(memmove) 731.1Sjoerg# endif /* MEMMOVE */ 741.2Suebayasi# ifdef BCOPY 751.2SuebayasiEND(bcopy) 761.2Suebayasi# endif 77