/* 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 ___strncatDP; ___strncatDP: ncat_core: R12=PASS R12; /* Test for zero input */ IF LE JUMP (PC, restore_state) (DB); /* Quit if n<=0 */ R0=R0-R0; R12=PASS R12, pm_ptr=R4; /* Set cond codes, point to input array*/ dm_to_pm_ncat: DO find_dm_pm_end UNTIL EQ; /* Loop until NULL character */ IF NE R2=PM(pm_ptr,pm_1); /* If not NULL, read next char */ find_dm_pm_end: IF NE R2=PASS R2; /* Check for NULL character */ MODIFY(pm_ptr,pm_M1); /* Backup to NULL character */ R2=R2+1, dm_ptr=R8; /* Point to input array */ LCNTR=R12, DO dm_pm UNTIL LCE; /* Copy n-1 characters */ IF NE R2=DM(dm_ptr, dm_1); /* Point to input char */ dm_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;