/* This C language subroutine returns a pointer to the first occurance of a character from s2 found in s1. The Run Time Library for the C Language. Gordon A. Sterling (617) 461 - 3076 DSP Development Tools Engineering Created on 1/19/91 Updated on 5/94 by AS Updated on 3/95 by AS - separated polymorphic functions #include
size_t strpbrk(const char *s1, const char *s2); */ #include "lib_glob.h" #include "str_glob.h" .SEGMENT/CODE Code_Space_Name; .FILE RTL_FILENAME; .GLOBAL ___strpbrkDP; ___strpbrkDP: strpbrk_core: R0=PASS R4; /* Check for NULL for s1 */ IF NE R0=PASS R8; /* Check for NULL for s2 */ dm_vs_pm: IF EQ JUMP (PC, restore_state) (DB); /* Cond code set by caller */ R0=PASS R4, dm_ptr=R4; /* Point to s1 */ pm_bse=R8; /* Point to s2 with base pointer*/ R4=DM(dm_ptr, dm_1); /* Read s1 */ R4=PASS R4, R8=PM(pm_ptr, pm_1);/* Test for NULL s1, read s2 */ IF EQ JUMP (PC, restore_state); /* Return a zero for NULL s1 */ DO scan_dmpms1 UNTIL EQ; /* Scan through s1 */ DO scan_dmpms2 UNTIL EQ; /* Scan through s2 */ IF NE R2=PASS R8; /* Check for EOS(s2) */ scan_dmpms2: IF NE COMP(R2,R4), R8=PM(pm_ptr, pm_1);/* Does s1==s2 */ COMP(R2,R4), R8=DM(dm_ptr, dm_1);/* Read next character of s1*/ IF NE R4=PASS R8, pm_ptr=pm_bse;/* If EOS(s1), exit loop */ R2=PASS R2; /* Test for EOS(s2) */ scan_dmpms1: IF EQ R0=R0+1, R8=PM(pm_ptr, pm_1);/* Increment Count */ R4=PASS R4; /* Test for EOS(s1) */ IF EQ R0=R0-R0; /* If so, return NULL */ restore_state: FETCH_RETURN RETURN (DB); RESTORE_STACK RESTORE_FRAME .ENDSEG;