fix compile issue when DOASSERTS=y
[uclibc-ng.git] / libc / string / bfin / memchr.S
blob26d419f7c6d1acd15cc5078136764f8f05346fca
1 /* memchr.S
2  * Copyright (C) 2003-2007 Analog Devices Inc., All Rights Reserved.
3  *
4  * This file is subject to the terms and conditions of the GNU Library General
5  * Public License. See the file "COPYING.LIB" in the main directory of this
6  * archive for more details.
7  *
8  * Non-LGPL License also available as part of VisualDSP++
9  * http://www.analog.com/processors/resources/crosscore/visualDspDevSoftware.html
10  */
12 #include <sysdep.h>
14 /* void *memchr(const void *s, int c, size_t n);
15  * R0 = address (s)
16  * R1 = sought byte (c)
17  * R2 = count (n)
18  *
19  * Returns pointer to located character.
20  */
22 .text
24 .align 2
26 .weak _memchr
27 ENTRY(_memchr)
28         P0 = R0;             /* P0 = address */
29         P2 = R2;             /* P2 = count */
30         R1 = R1.B(Z);
31         CC = R2 == 0;
32         IF CC JUMP .Lfailed;
34 .Lbytes:
35         LSETUP (.Lbyte_loop_s, .Lbyte_loop_e) LC0=P2;
37 .Lbyte_loop_s:
38         R3 = B[P0++](Z);
39         CC = R3 == R1;
40         IF CC JUMP .Lfound;
41 .Lbyte_loop_e:
42         NOP;
44 .Lfailed:
45         R0=0;
46         RTS;
48 .Lfound:
49         R0 = P0;
50         R0 += -1;
51         RTS;
53 .size _memchr,.-_memchr
55 libc_hidden_def (memchr)