Merge tag 'for_linus' of git://git.kernel.org/pub/scm/linux/kernel/git/mst/vhost
[cris-mirror.git] / arch / blackfin / lib / memchr.S
blobbcfc8a14c3f2f1488df98e182b6fc4031795a16a
1 /*
2  * Copyright 2005-2009 Analog Devices Inc.
3  *
4  * Licensed under the Clear BSD license or the GPL-2 (or later)
5  */
7 #include <linux/linkage.h>
9 /* void *memchr(const void *s, int c, size_t n);
10  * R0 = address (s)
11  * R1 = sought byte (c)
12  * R2 = count (n)
13  *
14  * Returns pointer to located character.
15  */
17 .text
19 .align 2
21 ENTRY(_memchr)
22         P0 = R0;                /* P0 = address */
23         P2 = R2;                /* P2 = count */
24         R1 = R1.B(Z);
25         CC = R2 == 0;
26         IF CC JUMP .Lfailed;
28 .Lbytes:
29         LSETUP (.Lbyte_loop_s, .Lbyte_loop_e) LC0=P2;
31 .Lbyte_loop_s:
32         R3 = B[P0++](Z);
33         CC = R3 == R1;
34         IF CC JUMP .Lfound;
35 .Lbyte_loop_e:
36         NOP;
38 .Lfailed:
39         R0=0;
40         RTS;
42 .Lfound:
43         R0 = P0;
44         R0 += -1;
45         RTS;
47 ENDPROC(_memchr)