diff options
author | PikalaxALT <pikalaxalt@gmail.com> | 2017-12-15 09:38:53 -0500 |
---|---|---|
committer | PikalaxALT <pikalaxalt@gmail.com> | 2017-12-15 09:39:34 -0500 |
commit | f95a4a932476be2ba99e2fd081e8d2bc6ea12813 (patch) | |
tree | 75f67192cb2d7b7b575c94edda318e475239b63c /newlib/libc/machine/hppa/memchr.S | |
parent | f60aca96985e68c7d8a52eb7bc955fb80e132f73 (diff) |
Import newlib and create makefile
Diffstat (limited to 'newlib/libc/machine/hppa/memchr.S')
-rw-r--r-- | newlib/libc/machine/hppa/memchr.S | 48 |
1 files changed, 48 insertions, 0 deletions
diff --git a/newlib/libc/machine/hppa/memchr.S b/newlib/libc/machine/hppa/memchr.S new file mode 100644 index 0000000..1cca3e5 --- /dev/null +++ b/newlib/libc/machine/hppa/memchr.S @@ -0,0 +1,48 @@ +/* + * (c) Copyright 1986 HEWLETT-PACKARD COMPANY + * + * To anyone who acknowledges that this file is provided "AS IS" + * without any express or implied warranty: + * permission to use, copy, modify, and distribute this file + * for any purpose is hereby granted without fee, provided that + * the above copyright notice and this notice appears in all + * copies, and that the name of Hewlett-Packard Company not be + * used in advertising or publicity pertaining to distribution + * of the software without specific, written prior permission. + * Hewlett-Packard Company makes no representations about the + * suitability of this software for any purpose. + */ + +/* SPECTRUM_ID: @(#)memchr.s 37.4 86/04/23 */ +/* + * memchr(s, c, n) + * + * returns pointer to first occurrence of char c + * in first n characters of memory area s, + * or null if c does not occur. + */ + +#include "DEFS.h" + +#define FROM arg0 +#define CHAR arg1 +#define COUNT arg2 +#define TEMP1 r19 + +ENTRY(memchr) + comb,<= COUNT,r0,memchrexit /* return if count is zero */ + copy r0,ret0 /* null if c not found in n chars */ + depi 0,23,24,CHAR /* make char unsigned */ + + ldbs,ma 1(FROM),TEMP1 +memchrloop: + comb,=,n TEMP1,CHAR,memchrequal + addib,<> -1,COUNT,memchrloop + ldbs,ma 1(FROM),TEMP1 + b,n memchrexit + +memchrequal: + ldo -1(FROM),ret0 + +memchrexit: +EXIT(memchr) |