xref: /onnv-gate/usr/src/lib/libc/i386/gen/wschr.s (revision 7298:b69e27387f74)
10Sstevel@tonic-gate/*
20Sstevel@tonic-gate * CDDL HEADER START
30Sstevel@tonic-gate *
40Sstevel@tonic-gate * The contents of this file are subject to the terms of the
56812Sraf * Common Development and Distribution License (the "License").
66812Sraf * You may not use this file except in compliance with the License.
70Sstevel@tonic-gate *
80Sstevel@tonic-gate * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
90Sstevel@tonic-gate * or http://www.opensolaris.org/os/licensing.
100Sstevel@tonic-gate * See the License for the specific language governing permissions
110Sstevel@tonic-gate * and limitations under the License.
120Sstevel@tonic-gate *
130Sstevel@tonic-gate * When distributing Covered Code, include this CDDL HEADER in each
140Sstevel@tonic-gate * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
150Sstevel@tonic-gate * If applicable, add the following below this CDDL HEADER, with the
160Sstevel@tonic-gate * fields enclosed by brackets "[]" replaced with your own identifying
170Sstevel@tonic-gate * information: Portions Copyright [yyyy] [name of copyright owner]
180Sstevel@tonic-gate *
190Sstevel@tonic-gate * CDDL HEADER END
200Sstevel@tonic-gate */
216812Sraf
220Sstevel@tonic-gate/*
236812Sraf * Copyright 2008 Sun Microsystems, Inc.  All rights reserved.
240Sstevel@tonic-gate * Use is subject to license terms.
250Sstevel@tonic-gate */
260Sstevel@tonic-gate
27*7298SMark.J.Nelson@Sun.COM	.file	"wschr.s"
280Sstevel@tonic-gate
290Sstevel@tonic-gate/
300Sstevel@tonic-gate/ Wide character wcschr() implementation
310Sstevel@tonic-gate/
320Sstevel@tonic-gate/ Algorithm based on Solaris 2.6 gen/strchr.s implementation
330Sstevel@tonic-gate/
340Sstevel@tonic-gate
356812Sraf#include "SYS.h"
360Sstevel@tonic-gate
370Sstevel@tonic-gate	ANSI_PRAGMA_WEAK(wcschr,function)
380Sstevel@tonic-gate	ANSI_PRAGMA_WEAK(wschr,function)
390Sstevel@tonic-gate
400Sstevel@tonic-gate	.align	8		/ accounts for .loop alignment and prolog
410Sstevel@tonic-gate
426812Sraf	ENTRY(wcschr)
430Sstevel@tonic-gate	movl	4(%esp),%eax	/ %eax = string address
440Sstevel@tonic-gate	movl	8(%esp),%ecx	/ %ecx = wchar sought
450Sstevel@tonic-gate.loop:
460Sstevel@tonic-gate	movl	(%eax),%edx	/ %edx = wchar of string
470Sstevel@tonic-gate	cmpl	%ecx,%edx	/ find it?
480Sstevel@tonic-gate	je	.found		/ yes
490Sstevel@tonic-gate	testl	%edx,%edx	/ is it null?
500Sstevel@tonic-gate	je	.notfound
510Sstevel@tonic-gate
520Sstevel@tonic-gate	movl	4(%eax),%edx	/ %edx = wchar of string
530Sstevel@tonic-gate	cmpl	%ecx,%edx	/ find it?
540Sstevel@tonic-gate	je	.found1		/ yes
550Sstevel@tonic-gate	testl	%edx,%edx	/ is it null?
560Sstevel@tonic-gate	je	.notfound
570Sstevel@tonic-gate
580Sstevel@tonic-gate	movl	8(%eax),%edx	/ %edx = wchar of string
590Sstevel@tonic-gate	cmpl	%ecx,%edx	/ find it?
600Sstevel@tonic-gate	je	.found2		/ yes
610Sstevel@tonic-gate	testl	%edx,%edx	/ is it null?
620Sstevel@tonic-gate	je	.notfound
630Sstevel@tonic-gate
640Sstevel@tonic-gate	movl	12(%eax),%edx	/ %edx = wchar of string
650Sstevel@tonic-gate	cmpl	%ecx,%edx	/ find it?
660Sstevel@tonic-gate	je	.found3		/ yes
670Sstevel@tonic-gate	addl	$16,%eax
680Sstevel@tonic-gate	testl	%edx,%edx	/ is it null?
690Sstevel@tonic-gate	jne	.loop
700Sstevel@tonic-gate
710Sstevel@tonic-gate.notfound:
720Sstevel@tonic-gate	xorl	%eax,%eax	/ %eax = NULL
730Sstevel@tonic-gate	ret
740Sstevel@tonic-gate
750Sstevel@tonic-gate.found3:
760Sstevel@tonic-gate	addl	$12,%eax
770Sstevel@tonic-gate	ret
780Sstevel@tonic-gate.found2:
790Sstevel@tonic-gate	addl	$8,%eax
800Sstevel@tonic-gate	ret
810Sstevel@tonic-gate.found1:
820Sstevel@tonic-gate	addl	$4,%eax
830Sstevel@tonic-gate.found:
840Sstevel@tonic-gate	ret
856812Sraf	SET_SIZE(wcschr)
860Sstevel@tonic-gate
876812Sraf	ENTRY(wschr)
880Sstevel@tonic-gate	_prologue_
890Sstevel@tonic-gate	movl	_esp_(8),%eax
900Sstevel@tonic-gate	movl	_esp_(4),%edx
910Sstevel@tonic-gate	pushl	%eax
920Sstevel@tonic-gate	pushl	%edx
936812Sraf	call	_fref_(wcschr)
940Sstevel@tonic-gate	addl	$8,%esp
950Sstevel@tonic-gate	_epilogue_
960Sstevel@tonic-gate	ret
976812Sraf	SET_SIZE(wschr)
98