1/*******************************************************************************
2 *
3 * Copyright (c) 1993 Intel Corporation
4 *
5 * Intel hereby grants you permission to copy, modify, and distribute this
6 * software and its documentation.  Intel grants this permission provided
7 * that the above copyright notice appears in all copies and that both the
8 * copyright notice and this permission notice appear in supporting
9 * documentation.  In addition, Intel grants this permission provided that
10 * you prominently mark as "not part of the original" any modifications
11 * made to this software or documentation, and that the name of Intel
12 * Corporation not be used in advertising or publicity pertaining to
13 * distribution of the software or the documentation without specific,
14 * written prior permission.
15 *
16 * Intel Corporation provides this AS IS, WITHOUT ANY WARRANTY, EXPRESS OR
17 * IMPLIED, INCLUDING, WITHOUT LIMITATION, ANY WARRANTY OF MERCHANTABILITY
18 * OR FITNESS FOR A PARTICULAR PURPOSE.  Intel makes no guarantee or
19 * representations regarding the use of, or the results of the use of,
20 * the software and documentation in terms of correctness, accuracy,
21 * reliability, currentness, or otherwise; and you rely on the software,
22 * documentation and results solely at your own risk.
23 *
24 * IN NO EVENT SHALL INTEL BE LIABLE FOR ANY LOSS OF USE, LOSS OF BUSINESS,
25 * LOSS OF PROFITS, INDIRECT, INCIDENTAL, SPECIAL OR CONSEQUENTIAL DAMAGES
26 * OF ANY KIND.  IN NO EVENT SHALL INTEL'S TOTAL LIABILITY EXCEED THE SUM
27 * PAID TO INTEL FOR THE PRODUCT LICENSED HEREUNDER.
28 *
29 ******************************************************************************/
30
31/*
32 * (c) copyright 1989,1993 Intel Corp., all rights reserved
33 */
34
35/*
36	procedure strpbrk  (optimized assembler version: 80960K series, 80960CA)
37
38	char_addr = strpbrk (string, brkset_string)
39
40	Return the address of the first character in string that is NOT
41	in the brkset_string.  Return NULL if none exists.
42
43	At the time of this writing, only g0 thru g7 and g13 are available
44	for use in this leafproc;  other registers would have to be saved and
45	restored.  These nine registers, plus tricky use of g14 are sufficient
46	to implement the routine.
47
48	This routine stays out of g3 and g4 altogether.  They may be used by
49	the strtok routine, which calls this routine in an incestuous way.
50*/
51#ifdef  __PIC
52        .pic
53#endif
54#ifdef  __PID
55        .pid
56#endif
57
58	.file "strprk.s"
59	.globl	_strpbrk
60	.globl	__strpbrk
61	.leafproc	_strpbrk, __strpbrk
62	.align	2
63
64_strpbrk:
65#ifdef __PIC
66	lda	Lrett-(.+8)(ip),g14
67	b	__strpbrk
68#else
69	lda	Lrett,g14
70	b	__strpbrk
71#endif
72
73Lrett:	ret
74
75__strpbrk:
76
77Lnext_char_strpbrk:
78	addo	1,g1,g2		# g2 will be the brkset ptr
79	ldob	(g0),g7		# fetch next character of string
80	ldob	(g1),g6		# fetch first character of brkset
81	cmpobe.f 0,g7,Lexit_char_not_found	# quit if at end of string
82Lscan_set_strpbrk:
83	cmpo	g6,g7		# is brkset char equal to string char?
84	ldob	(g2),g5		# fetch next brkset char
85	addo	1,g2,g2		# bump brkset ptr
86	be.f	Lexit_char_found
87	cmpo	g6,0		# is brkset_string exhausted?
88	lda	(g5),g6
89	bne.t	Lscan_set_strpbrk # check next character of brkset
90	addo	1,g0,g0		# check next character of string
91	b	Lnext_char_strpbrk
92
93Lexit_char_not_found:
94	mov	0,g0		# return null if brkset char not found in string
95Lexit_char_found:
96	mov	g14,g13		# save return address
97	lda	0,g14		# conform to register conventions
98	bx	(g13)
99
100/* end of strpbrk */
101