/* This C language subroutine searches for a character within a range of memory. The Run Time Library for the C Language. Gordon A. Sterling (617) 461 - 3076 DSP Development Tools Engineering Created on 4/30/90 Updated on 6/94 by AS Updated on 2/95 by AS - separated polymorphic functions #include
void *memchr(const void *s1, int c, size_t n); */ #include "lib_glob.h" #include "str_glob.h" .SEGMENT/CODE Code_Space_Name; .FILE RTL_FILENAME; .GLOBAL _memchr; .GLOBAL ___memchrD; _memchr: ___memchrD: chr_core: R2=PASS R12, dm_lnt=dm_0; /*Test for zero*/ IF EQ JUMP (PC, restore_state) (DB); R0=PASS R4, FETCH_RETURN R4=PASS R8, dm_ptr=R0; /*Point to start*/ dm_chr: R2=R2-1, R8=DM(dm_ptr,1); /*Read first sample*/ IF EQ JUMP (PC, dm_finish); /*Only one point*/ LCNTR=R2, DO find_dm_chr UNTIL LCE; COMP(R4,R8), R8=DM(dm_ptr,1); IF EQ JUMP (PC, restore_state) (LA); find_dm_chr: R0=R0+1; dm_finish: COMP(R4,R8); IF NE R0=R0-R0; restore_state: RETURN (DB); RESTORE_STACK RESTORE_FRAME .ENDSEG;