xref: /freebsd/lib/libc/i386/string/wcschr.S (revision 0b3105a37d7adcadcb720112fed4dc4e8040be99)
1/*-
2 * Copyright (c) 2003 Tim J. Robbins.
3 * All rights reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
7 * are met:
8 * 1. Redistributions of source code must retain the above copyright
9 *    notice, this list of conditions and the following disclaimer.
10 * 2. Redistributions in binary form must reproduce the above copyright
11 *    notice, this list of conditions and the following disclaimer in the
12 *    documentation and/or other materials provided with the distribution.
13 *
14 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
15 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
16 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
17 * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
18 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
19 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
20 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
21 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
22 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
23 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
24 * SUCH DAMAGE.
25 */
26
27#include <machine/asm.h>
28__FBSDID("$FreeBSD$");
29
30/*
31 * wchar_t *
32 * wcschr(const wchar_t *s, wchar_t c) --
33 *	Return pointer to first occurrence of the character `c' in the wide
34 *	character string `s', or NULL if not found.
35 */
36ENTRY(wcschr)
37	movl	4(%esp),%ecx		/* String */
38	movl	8(%esp),%eax		/* Character */
39	pushl	%ebx
40.p2align 4,0x90
41L1:	movl	(%ecx),%ebx
42	cmpl	%eax,%ebx
43	je	found0
44	testl	%ebx,%ebx
45	jz	no
46	movl	4(%ecx),%ebx
47	cmpl	%eax,%ebx
48	je	found1
49	testl	%ebx,%ebx
50	jz	no
51	movl	8(%ecx),%ebx
52	cmpl	%eax,%ebx
53	je	found2
54	testl	%ebx,%ebx
55	jz	no
56	movl	12(%ecx),%ebx
57	cmpl	%eax,%ebx
58	je	found3
59	testl	%ebx,%ebx
60	jz	no
61	leal	16(%ecx),%ecx
62	jmp	L1
63.p2align 2,0x90
64found3:	leal	4(%ecx),%ecx
65.p2align 2,0x90
66found2:	leal	4(%ecx),%ecx
67.p2align 2,0x90
68found1:	leal	4(%ecx),%ecx
69.p2align 2,0x90
70found0: popl	%ebx
71	movl	%ecx,%eax
72	ret
73.p2align 2,0x90
74no:	popl	%ebx
75	xorl	%eax,%eax
76	ret
77END(wcschr)
78
79	.section .note.GNU-stack,"",%progbits
80