/* This C language subroutine concatenates one string to another, copying at most N characters. 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 - separated polymorphic functions #include
char *strncat(char *s1, const char *s2 size_t size); */ #include "lib_glob.h" #include "str_glob.h" .SEGMENT/CODE Code_Space_Name; .FILE RTL_FILENAME; .GLOBAL ___strncatPP; ___strncatPP: ncat_core: R12=PASS R12, pm_ptr=R4;/*Test for 0 input, point to input array*/ IF LE JUMP (PC, restore_state) (DB); /* Quit if n <= 0 */ R0=0; nop; pm_to_pm_ncat: DO find_pm_pm_end UNTIL EQ; /* Loop until NULL character */ IF NE R2=PM(pm_ptr,pm_1); /* If not NULL, read next char */ find_pm_pm_end: IF NE R2=PASS R2; /* Check for NULL character */ MODIFY(pm_ptr,pm_M1); /* Backup to NULL character */ R2=pm_ptr; /* Get address of output array */ R2=R8-R2; /* Get difference between in/out*/ pm_mdf=R2; /* Used for pre-modify reading */ LCNTR=R12, DO pm_pm UNTIL LCE; /* Copy n-1 characters */ IF NE R2=PM(pm_mdf, pm_ptr); /* Point to input char */ pm_pm: IF NE R2=PASS R2,PM(pm_ptr,pm_1)=R2; /* Write character */ R0=PASS R4, PM(pm_ptr,pm_1)=R0; /* Write out NULL */ restore_state: FETCH_RETURN RETURN (DB); RESTORE_STACK RESTORE_FRAME .ENDSEG;