1: /*
2: * Copyright (c) 1987 Regents of the University of California.
3: * All rights reserved. The Berkeley software License Agreement
4: * specifies the terms and conditions for redistribution.
5: */
6:
7: #ifdef LIBC_SCCS
8: <@(#)bunequal.s 1.2 (Berkeley) 1/8/87\0>
9: .even
10: #endif LIBC_SCCS
11:
12: #define ENTRY(x) .globl _/**/x; \
13: _/**/x:
14:
15: /*
16: * This is taken from bcmp.s from 2.10.
17: * The output of bunequal is the offset of the byte which didn't match;
18: * if all the bytes match, then we return n.
19: *
20: * bunequal(b1, b2, length)
21: */
22:
23: ENTRY(bunequal)
24: mov 6(sp),r0 / if ((r0 = length) == 0)
25: beq 3f / return(length:r0)
26: mov r2,-(sp) / reserve a register for our use
27: mov 6(sp),r2 / r2 = b2
28: mov 4(sp),r1 / r1 = b1
29: 1:
30: cmpb (r1)+,(r2)+ / do if (*b1++ != *b2++)
31: bne 2f / return(length:r0) {length != 0}
32: sob r0,1b / while (--length)
33: 2:
34: mov (sp)+,r2 / restore r2
35: neg r0 / return(length:r0)
36: add 6(sp),r0
37: 3:
38: rts pc
39:
40: /* brand new code, using the above as base... */
41: /*
42: * bskip(s1, n, b) : finds the first occurrence of any byte != 'b' in the 'n'
43: * bytes beginning at 's1'.
44: */
45:
46: ENTRY(bskip)
47: mov 2(sp),r1 / r1 = s1
48: mov 4(sp),r0 / if ((r0 = n) == 0)
49: beq 3f / return(n:r0)
50: tstb 6(sp) / in reality b is always zero, so optimize
51: bne 4f / slower test
52: 1:
53: tstb (r1)+ / do if (*s1++)
54: bne 2f / return(n:r0) {n != 0}
55: sob r0,1b / while (--n)
56: 2:
57: neg r0 / return(n:r0)
58: add 4(sp),r0
59: 3:
60: rts pc
61:
62: 4:
63: mov r2,-(sp) / reserve a register for our use
64: movb 10(sp),r2 / r2 = b
65: 1:
66: cmpb (r1)+,r2 / do if (*s1++ != b)
67: bne 2f / return(n:r0) {n != 0}
68: sob r0,1b / while (--n)
69: 2:
70: mov (sp)+,r2 / restore r2
71: neg r0 / return(n:r0)
72: add 4(sp),r0
73: rts pc
Defined functions
Defined macros
ENTRY
defined in line
12; used 2 times