/* This C language subroutine searches for a character within a string. 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 5/94 by AS Updated on 3/95 by AS - seperated polymorphic functions #include
char *strchr(const char *s1, int c); */ #include "lib_glob.h" #include "str_glob.h" .SEGMENT/CODE Code_Space_Name; .FILE RTL_FILENAME; .GLOBAL _strchr; .GLOBAL ___strchrD; _strchr: ___strchrD: chr_core: R0=PASS R4, FETCH_RETURN R4=PASS R8, dm_ptr=R0; /*Point to start*/ dm_chr: R8=DM(dm_ptr,1); /*Read first sample*/ DO find_dm_chr UNTIL FOREVER; COMP(R4,R8); IF EQ JUMP (PC, restore_state) (LA); R8=PASS R8; IF EQ JUMP (PC, end_of_array) (LA); find_dm_chr: R0=R0+1, R8=DM(dm_ptr,1); COMP(R4,R8); IF NE R0=R0-R0; restore_state: RETURN (DB); RESTORE_STACK RESTORE_FRAME end_of_array: JUMP (PC, restore_state) (DB); /*End of array reached*/ R0=0; nop; .ENDSEG;