xref: /original-bsd/lib/libc/hp300/string/rindex.s (revision c3e32dec)
1/*-
2 * Copyright (c) 1990, 1993
3 *	The Regents of the University of California.  All rights reserved.
4 *
5 * This code is derived from software contributed to Berkeley by
6 * the Systems Programming Group of the University of Utah Computer
7 * Science Department.
8 *
9 * %sccs.include.redist.c%
10 */
11
12#if defined(LIBC_SCCS) && !defined(lint)
13	.asciz "@(#)rindex.s	8.1 (Berkeley) 06/04/93"
14#endif /* LIBC_SCCS and not lint */
15
16#include "DEFS.h"
17
18ENTRY(rindex)
19	movl	sp@(4),a0	/* string */
20	movb	sp@(11),d0	/* char to look for */
21	subl	a1,a1		/* clear rindex pointer */
22rixloop:
23	cmpb	a0@,d0		/* found our char? */
24	jne	rixnope		/* no, check for null */
25	movl	a0,a1		/* yes, remember location */
26rixnope:
27	tstb	a0@+		/* null? */
28	jne	rixloop		/* no, keep going */
29	movl	a1,d0		/* return value */
30	rts
31