xref: /netbsd-src/common/lib/libc/arch/i386/string/small/strcpy.S (revision 2c56941e163201dcb781df7fdeec6bd093647c91)
1*2c56941eSjakllsch/*	$NetBSD: strcpy.S,v 1.2 2014/03/22 19:38:46 jakllsch Exp $	*/
2bdaa91a3Sjoerg/*-
3bdaa91a3Sjoerg * Copyright (c) 2011 The NetBSD Foundation, Inc.
4bdaa91a3Sjoerg * All rights reserved.
5bdaa91a3Sjoerg *
6bdaa91a3Sjoerg * This code is derived from software contributed to The NetBSD Foundation
7bdaa91a3Sjoerg * by Joerg Sonnenberger.
8bdaa91a3Sjoerg *
9bdaa91a3Sjoerg * Redistribution and use in source and binary forms, with or without
10bdaa91a3Sjoerg * modification, are permitted provided that the following conditions
11bdaa91a3Sjoerg * are met:
12bdaa91a3Sjoerg * 1. Redistributions of source code must retain the above copyright
13bdaa91a3Sjoerg *    notice, this list of conditions and the following disclaimer.
14bdaa91a3Sjoerg * 2. Redistributions in binary form must reproduce the above copyright
15bdaa91a3Sjoerg *    notice, this list of conditions and the following disclaimer in the
16bdaa91a3Sjoerg *    documentation and/or other materials provided with the distribution.
17bdaa91a3Sjoerg *
18bdaa91a3Sjoerg * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
19bdaa91a3Sjoerg * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
20bdaa91a3Sjoerg * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
21bdaa91a3Sjoerg * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
22bdaa91a3Sjoerg * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
23bdaa91a3Sjoerg * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
24bdaa91a3Sjoerg * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
25bdaa91a3Sjoerg * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
26bdaa91a3Sjoerg * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
27bdaa91a3Sjoerg * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
28bdaa91a3Sjoerg * POSSIBILITY OF SUCH DAMAGE.
29bdaa91a3Sjoerg */
30bdaa91a3Sjoerg
31bdaa91a3Sjoerg#include <machine/asm.h>
32*2c56941eSjakllsch	RCSID("$NetBSD: strcpy.S,v 1.2 2014/03/22 19:38:46 jakllsch Exp $")
33bdaa91a3Sjoerg
34bdaa91a3SjoergENTRY(strcpy)
35bdaa91a3Sjoerg	pushl	%esi
36bdaa91a3Sjoerg	pushl	%edi
37bdaa91a3Sjoerg	movl	12(%esp), %edi
38bdaa91a3Sjoerg	movl	16(%esp), %esi
39bdaa91a3Sjoerg	pushl	%edi
40bdaa91a3Sjoerg1:
41bdaa91a3Sjoerg	lodsb
42bdaa91a3Sjoerg	stosb
43bdaa91a3Sjoerg	testb	%al, %al
44bdaa91a3Sjoerg	jne 1b
45bdaa91a3Sjoerg	popl	%eax
46bdaa91a3Sjoerg	popl	%edi
47bdaa91a3Sjoerg	popl	%esi
48bdaa91a3Sjoerg	ret
49*2c56941eSjakllschEND(strcpy)
50