Merge branch 'for-next'
[linux-2.6/linux-acpi-2.6/ibm-acpi-2.6.git] / arch / blackfin / lib / memchr.S
blob542e40f8775f73d48dda644175776a80084f0fc2
1 /*
2  * Copyright 2005-2009 Analog Devices Inc.
3  *
4  * Licensed under the ADI 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)