Commit | Line | Data |
---|---|---|
1394f032 BW |
1 | /* |
2 | * File: arch/blackfin/lib/memchr.S | |
3 | * Based on: | |
4 | * Author: | |
5 | * | |
6 | * Created: | |
7 | * Description: | |
8 | * | |
9 | * Modified: | |
10 | * Copyright 2004-2006 Analog Devices Inc. | |
11 | * | |
12 | * Bugs: Enter bugs at http://blackfin.uclinux.org/ | |
13 | * | |
14 | * This program is free software; you can redistribute it and/or modify | |
15 | * it under the terms of the GNU General Public License as published by | |
16 | * the Free Software Foundation; either version 2 of the License, or | |
17 | * (at your option) any later version. | |
18 | * | |
19 | * This program is distributed in the hope that it will be useful, | |
20 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | |
21 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
22 | * GNU General Public License for more details. | |
23 | * | |
24 | * You should have received a copy of the GNU General Public License | |
25 | * along with this program; if not, see the file COPYING, or write | |
26 | * to the Free Software Foundation, Inc., | |
27 | * 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA | |
28 | */ | |
29 | ||
30 | #include <linux/linkage.h> | |
31 | ||
32 | /* void *memchr(const void *s, int c, size_t n); | |
33 | * R0 = address (s) | |
34 | * R1 = sought byte (c) | |
35 | * R2 = count (n) | |
36 | * | |
37 | * Returns pointer to located character. | |
38 | */ | |
39 | ||
40 | .text | |
41 | ||
42 | .align 2 | |
43 | ||
44 | ENTRY(_memchr) | |
45 | P0 = R0; /* P0 = address */ | |
46 | P2 = R2; /* P2 = count */ | |
47 | R1 = R1.B(Z); | |
48 | CC = R2 == 0; | |
49 | IF CC JUMP .Lfailed; | |
50 | ||
51 | .Lbytes: | |
52 | LSETUP (.Lbyte_loop_s, .Lbyte_loop_e) LC0=P2; | |
53 | ||
54 | .Lbyte_loop_s: | |
55 | R3 = B[P0++](Z); | |
56 | CC = R3 == R1; | |
57 | IF CC JUMP .Lfound; | |
58 | .Lbyte_loop_e: | |
59 | NOP; | |
60 | ||
61 | .Lfailed: | |
62 | R0=0; | |
63 | RTS; | |
64 | ||
65 | .Lfound: | |
66 | R0 = P0; | |
67 | R0 += -1; | |
68 | RTS; | |
69 | ||
51be24c3 | 70 | ENDPROC(_memchr) |