/* 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 _strncat; .GLOBAL ___strncatDD; _strncat: ___strncatDD: ncat_core: R12=PASS R12; /* Test for zero input */ IF LE JUMP (PC, restore_state) (DB); /* Quit if n <=0 */ R0=R0-R0, FETCH_RETURN R12=PASS R12, dm_ptr=R4; /* Set cond codes, Pt to input array*/ dm_to_dm_ncat: DO find_dm_dm_end UNTIL EQ; /* Loop until NULL character */ IF NE R2=DM(dm_ptr,dm_1); /* If not NULL, read next char */ find_dm_dm_end: IF NE R2=PASS R2; /* Check for NULL character */ MODIFY(dm_ptr,dm_M1); /* Backup to NULL character */ R2=dm_ptr; /* Get address of output array */ R2=R8-R2; /* Get difference between in/out*/ dm_mdf=R2; /* Used for pre-modify reading */ LCNTR=R12, DO dm_dm UNTIL LCE; /* Copy n-1 characters */ IF NE R2=DM(dm_mdf, dm_ptr); /* Point to input char */ dm_dm: IF NE R2=PASS R2,DM(dm_ptr,dm_1)=R2; /* Write character */ R0=PASS R4, DM(dm_ptr,dm_1)=R0; /* Write out NULL */ restore_state: RETURN (DB); RESTORE_STACK RESTORE_FRAME .ENDSEG;