blob: 542e40f8775f73d48dda644175776a80084f0fc2 [file] [log] [blame]
Bryan Wu1394f032007-05-06 14:50:22 -07001/*
Robin Getz96f10502009-09-24 14:11:24 +00002 * Copyright 2005-2009 Analog Devices Inc.
Bryan Wu1394f032007-05-06 14:50:22 -07003 *
Robin Getz96f10502009-09-24 14:11:24 +00004 * Licensed under the ADI BSD license or the GPL-2 (or later)
Bryan Wu1394f032007-05-06 14:50:22 -07005 */
6
7#include <linux/linkage.h>
8
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 */
16
17.text
18
19.align 2
20
21ENTRY(_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;
27
28.Lbytes:
29 LSETUP (.Lbyte_loop_s, .Lbyte_loop_e) LC0=P2;
30
31.Lbyte_loop_s:
32 R3 = B[P0++](Z);
33 CC = R3 == R1;
34 IF CC JUMP .Lfound;
35.Lbyte_loop_e:
36 NOP;
37
38.Lfailed:
39 R0=0;
40 RTS;
41
42.Lfound:
43 R0 = P0;
44 R0 += -1;
45 RTS;
46
Mike Frysinger51be24c2007-06-11 15:31:30 +080047ENDPROC(_memchr)