1/* 2 * (c) Copyright 1986 HEWLETT-PACKARD COMPANY 3 * 4 * To anyone who acknowledges that this file is provided "AS IS" 5 * without any express or implied warranty: 6 * permission to use, copy, modify, and distribute this file 7 * for any purpose is hereby granted without fee, provided that 8 * the above copyright notice and this notice appears in all 9 * copies, and that the name of Hewlett-Packard Company not be 10 * used in advertising or publicity pertaining to distribution 11 * of the software without specific, written prior permission. 12 * Hewlett-Packard Company makes no representations about the 13 * suitability of this software for any purpose. 14 */ 15 16/* SPECTRUM_ID: @(#)memchr.s 37.4 86/04/23 */ 17/* 18 * memchr(s, c, n) 19 * 20 * returns pointer to first occurrence of char c 21 * in first n characters of memory area s, 22 * or null if c does not occur. 23 */ 24 25#include <picolibc.h> 26 27#include "DEFS.h" 28 29#define FROM arg0 30#define CHAR arg1 31#define COUNT arg2 32#define TEMP1 r19 33 34ENTRY(memchr) 35 comb,<= COUNT,r0,memchrexit /* return if count is zero */ 36 copy r0,ret0 /* null if c not found in n chars */ 37 depi 0,23,24,CHAR /* make char unsigned */ 38 39 ldbs,ma 1(FROM),TEMP1 40memchrloop: 41 comb,=,n TEMP1,CHAR,memchrequal 42 addib,<> -1,COUNT,memchrloop 43 ldbs,ma 1(FROM),TEMP1 44 b,n memchrexit 45 46memchrequal: 47 ldo -1(FROM),ret0 48 49memchrexit: 50EXIT(memchr) 51