/* This C language subroutine computes the length of the maximum initial segment of the string pointed to by s1 which consists entirely of characters not from the string pointed to be 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 strcspn(const char *s1, const char *s2); For a detailed description, see strcspn.asm */ #include "lib_glob.h" #include "str_glob.h" .SEGMENT/CODE Code_Space_Name; .FILE RTL_FILENAME; .GLOBAL ___strcspnPD; ___strcspnPD: strcspn_core: R0=PASS R4; /* Check for NULL for s1 */ IF NE R0=PASS R8; /* Check for NULL for s2 */ pm_vs_dm: IF EQ JUMP (PC, restore_state) (DB); /* Cond code set by caller */ R0=R0-R0, pm_ptr=R4; /* Point to s1 */ dm_bse=R8; /* Point to s2 with base pointer*/ R4=PM(pm_ptr, pm_1); /* Read s1 */ R4=PASS R4, R8=DM(dm_ptr, dm_1);/* Test for NULL s1, read s2 */ IF EQ JUMP (PC, restore_state); /* Return a zero for NULL s1 */ DO scan_pmdms1 UNTIL EQ; /* Scan through s1 */ DO scan_pmdms2 UNTIL EQ; /* Scan through s2 */ IF NE R2=PASS R8; /* Check for EOS(s2) */ scan_pmdms2: IF NE COMP(R2,R4), R8=DM(dm_ptr, dm_1);/* Does s1==s2 */ COMP(R2,R4), R4=PM(pm_ptr, pm_1);/* Read next char of s1 */ IF NE R4=PASS R4, dm_ptr=dm_bse;/* If EOS(s1), exit loop */ R2=PASS R2; /* Test for EOS(s2) */ NOP; /* BUG FIX */ scan_pmdms1: IF EQ R0=R0+1, R8=DM(dm_ptr, dm_1);/* Increment Count */ restore_state: FETCH_RETURN RETURN (DB); RESTORE_STACK RESTORE_FRAME .ENDSEG;