xref: /csrg-svn/lib/libc/vax/string/strspn.s (revision 61222)
142083Sbostic/*-
2*61222Sbostic * Copyright (c) 1990, 1993
3*61222Sbostic *	The Regents of the University of California.  All rights reserved.
442083Sbostic *
542083Sbostic * %sccs.include.redist.c%
642083Sbostic */
742083Sbostic
842083Sbostic#if defined(LIBC_SCCS) && !defined(lint)
9*61222Sbostic	.asciz "@(#)strspn.s	8.1 (Berkeley) 06/04/93"
1042083Sbostic#endif /* LIBC_SCCS and not lint */
1142083Sbostic
1242083Sbostic/*
1342083Sbostic * Span the string s2 (skip characters that are in s2).
1442083Sbostic * Return the number of characters in s1 that were skipped.
1542083Sbostic *
1642083Sbostic * size_t
1742083Sbostic * strspn(s1, s2)
1842083Sbostic *	const char *s1, *s2;
1942083Sbostic */
2042083Sbostic#include "DEFS.h"
2142083Sbostic
2242083SbosticENTRY(strspn, 0)
2342083Sbostic	subl2	$32,sp		/* make 256 bit table */
2442083Sbostic	movc5	$0,(sp),$0,$32,(sp)
2542083Sbostic	movq	4(ap),r1	/* r1 = s1, r2 = s2 */
2642083Sbostic
2742083Sbostic	/* turn on bit for each character in s2, including '\0' */
2842083Sbostic1:
2942083Sbostic	movzbl	(r2)+,r0
3042083Sbostic	bbss	r0,(sp),1b
3142083Sbostic	bneq	1b
3242083Sbostic
3342083Sbostic	/* now clear bit for '\0' */
3442083Sbostic	/* (this is easier than avoiding setting it in the first place) */
3542083Sbostic	bicb2	$1,(sp)		/* stop at '\0' */
3642083Sbostic	movl	r1,r0		/* r0 = s (current pos in s1) */
3742083Sbostic
3842083Sbostic	/* look for a character that is not in s2 */
3942083Sbostic2:
4042083Sbostic	movzbl	(r0)+,r2	/* c = *s++ */
4142083Sbostic	bbs	r2,(sp),2b	/* loop while c is in table */
4242083Sbostic	decl	r0		/* s-- */
4342083Sbostic	subl2	r1,r0		/* r0 = s - s1 = count */
4442083Sbostic	ret
45