/* 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 ___memchrP; ___memchrP: chr_core: R2=PASS R12; /*Test for zero*/ IF EQ JUMP (PC, abort) (DB); R0=PASS R4; R4=PASS R8, pm_ptr=R0; /*Point to start*/ pm_chr: R2=R2-1, R8=PM(pm_ptr,1); /*Read first sample*/ IF EQ JUMP (PC, pm_finish); /*Only one point*/ LCNTR=R2, DO find_pm_chr UNTIL LCE; COMP(R4,R8), R8=PM(pm_ptr,1); IF EQ JUMP (PC, abort) (LA); find_pm_chr: R0=R0+1; pm_finish: COMP(R4,R8), FETCH_RETURN IF NE R0=R0-R0; restore_state: RETURN (DB); RESTORE_STACK RESTORE_FRAME abort: JUMP (PC, restore_state) (DB); FETCH_RETURN nop; .ENDSEG;