1/*
2 *	@(#)vaxbsubs.s	3.1  10/29/86
3 */
4
5/*
6 *	Copyright (c) 1984, 1985, 1986 by the Regents of the
7 *	University of California and by Gregory Glenn Minshall.
8 *
9 *	Permission to use, copy, modify, and distribute these
10 *	programs and their documentation for any purpose and
11 *	without fee is hereby granted, provided that this
12 *	copyright and permission appear on all copies and
13 *	supporting documentation, the name of the Regents of
14 *	the University of California not be used in advertising
15 *	or publicity pertaining to distribution of the programs
16 *	without specific prior permission, and notice be given in
17 *	supporting documentation that copying and distribution is
18 *	by permission of the Regents of the University of California
19 *	and by Gregory Glenn Minshall.  Neither the Regents of the
20 *	University of California nor Gregory Glenn Minshall make
21 *	representations about the suitability of this software
22 *	for any purpose.  It is provided "as is" without
23 *	express or implied warranty.
24 */
25
26/* This is taken from bcmp.s from 4.2.
27 * The output of bunequal is the offset of the byte which didn't match;
28 * if all the bytes match, then we return n.
29 *
30 * BUGNOTE:  This has no chance of working for lengths greater than 64K.
31 *		(so, if you use this somewhere else, you may need to
32 *		fix it...)
33 */
34
35/* bunequal(s1, s2, n) */
36
37#include "defs.h"
38
39ENTRY(bunequal)
40	movl	4(ap),r1
41	movl	8(ap),r3
42	movl	12(ap),r4
431:
44	movzwl	$65535,r0
45	cmpl	r4,r0
46	jleq	2f
47	subl2	r0,r4
48	cmpc3	r0,(r1),(r3)
49	jeql	1b
50	addl2	r4,r0
51	/* changes... */
52	subl3	r0,12(ap),r0
53	/* end of changes for bunequal... */
54	ret
552:
56	cmpc3	r4,(r1),(r3)
57	/* changes... */
58	subl3	r0,12(ap),r0
59	/* end of changes for bunequal... */
60	ret
61
62
63
64
65/* brand new code, using the above as base... */
66/* bskip(s1, n, b) : finds the first occurrence of any byte != 'b' in the 'n'
67 * bytes beginning at 's1'.
68 *
69 * BUGNOTE:  This has no chance of working for lengths greater than 64K.
70 *		(so, if you use this somewhere else, you may need to
71 *		fix it...)
72 */
73
74ENTRY(bskip)
75	movl	4(ap),r1
76	movl	8(ap),r3
77	movl	12(ap),r4
781:
79	movzwl	$65535,r0
80	cmpl	r3,r0
81	jleq	2f
82	subl2	r0,r3
83	skpc	r4,r0,(r1)
84	jeql	1b
85	addl2	r3,r0
86	subl3	r0,8(ap),r0
87	ret
882:
89	skpc	r4,r3,(r1)
90	subl3	r0,8(ap),r0
91	ret
92