4 * The contents of this file are subject to the terms of the
5 * Common Development and Distribution License (the "License").
6 * You may not use this file except in compliance with the License.
8 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
9 * or http://www.opensolaris.org/os/licensing.
10 * See the License for the specific language governing permissions
11 * and limitations under the License.
13 * When distributing Covered Code, include this CDDL HEADER in each
14 * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
15 * If applicable, add the following below this CDDL HEADER, with the
16 * fields enclosed by brackets "[]" replaced with your own identifying
17 * information: Portions Copyright [yyyy] [name of copyright owner]
22 * Copyright 2004 Sun Microsystems, Inc. All rights reserved.
23 * Use is subject to license terms.
28 #include <sys/asm_linkage.h>
30 ANSI_PRAGMA_WEAK
(memccpy
,function
)
35 pushl
%esi
/ save register variable
36 movl
8(%esp
),%eax
/ %eax
= address of dest string
37 movl
12(%esp
),%esi
/ %esi
= address of source string
38 movb
16(%esp
),%dh
/ %dh
= character to search for
39 movl
20(%esp
),%ecx
/ %ecx
= length to go still
41 decl
%ecx
/ decrement bytes to go
44 movb
%dl
,(%eax
) / move byte
45 cmpb
%dh
,%dl
/ is it the byte sought?
48 decl
%ecx
/ decrement bytes to go
51 movb
%dl
,1(%eax
) / move byte
52 cmpb
%dh
,%dl
/ is it the byte sought?
55 decl
%ecx
/ decrement bytes to go
58 movb
%dl
,2(%eax
) / move byte
59 cmpb
%dh
,%dl
/ is it the byte sought?
62 decl
%ecx
/ decrement bytes to go
65 movb
%dl
,3(%eax
) / move byte
68 cmpb
%dh
,%dl
/ is it the byte sought?
73 popl
%esi
/ restore register variable
74 incl
%eax
/ return pointer to next byte in dest
81 popl
%esi
/ restore register variable
82 addl $
2,%eax
/ return pointer to next byte in dest
87 popl
%esi
/ restore register variable
88 xorl
%eax
,%eax
/ search fails