1/* 2 * Copyright 2005-2009 Analog Devices Inc. 3 * 4 * Licensed under the Clear BSD license or the GPL-2 (or later) 5 */ 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 47ENDPROC(_memchr) 48