xref: /original-bsd/lib/libc/vax/string/strcspn.s (revision c3e32dec)
1/*-
2 * Copyright (c) 1990, 1993
3 *	The Regents of the University of California.  All rights reserved.
4 *
5 * %sccs.include.redist.c%
6 */
7
8#if defined(LIBC_SCCS) && !defined(lint)
9	.asciz "@(#)strcspn.s	8.1 (Berkeley) 06/04/93"
10#endif /* LIBC_SCCS and not lint */
11
12/*
13 * Span the complement of string s2 (skip characters that are not in s2).
14 * Return the number of characters in s1 that were skipped.
15 *
16 * size_t
17 * strcspn(s1, s2)
18 *	const char *s1, *s2;
19 */
20#include "DEFS.h"
21
22ENTRY(strcspn, 0)
23	subl2	$32,sp		/* make 256 bit table */
24	movc5	$0,(sp),$0,$32,(sp)
25	movq	4(ap),r1	/* r1 = s1, r2 = s2 */
26
27	/* turn on bit for each character in s2, including '\0' */
281:
29	movzbl	(r2)+,r0
30	bbss	r0,(sp),1b
31	bneq	1b
32	movl	r1,r0		/* r0 = s (current pos in s1) */
33
34	/* look for a character that is in s2 */
352:
36	movzbl	(r0)+,r2	/* c = *s++ */
37	bbc	r2,(sp),2b	/* loop until c is in table */
38	decl	r0		/* s-- */
39	subl2	r1,r0		/* r0 = s - s1 = count */
40	ret
41