1: /*
   2:  * Copyright (c) 1987 Regents of the University of California.
   3:  * All rights reserved.  The Berkeley software License Agreement
   4:  * specifies the terms and conditions for redistribution.
   5:  */
   6: 
   7: #ifdef LIBC_SCCS
   8:         <@(#)strncat.s	1.1 (Berkeley) 1/20/87\0>
   9:         .even
  10: #endif LIBC_SCCS
  11: 
  12: /*
  13:  * Concatenate string s2 on the end of s1
  14:  * and return the base of s1.  The parameter
  15:  * n is the maximum length of string s2 to
  16:  * concatenate.
  17:  *
  18:  * char *
  19:  * strncat(s1, s2, n)
  20:  *	char *s1, *s2;
  21:  *	int n;
  22:  */
  23: #include "DEFS.h"
  24: 
  25: ENTRY(strncat)
  26:         mov     6(sp),r0        / r0 = n
  27:         beq     4f              / (all done if n == 0)
  28:         mov     2(sp),r1        / r1 = s1
  29: 1:
  30:         tstb    (r1)+           / find end of s1
  31:         bne     1b
  32:         dec     r1              / back up to '\0'
  33:         mov     r2,-(sp)        / need an extra register for s2 ...
  34:         mov     6(sp),r2        / r2 = s2
  35: 2:
  36:         movb    (r2)+,(r1)+     / copy s2 to the end of s1 stopping at the
  37:         beq     3f              /   end of s2 or when n runs out ...
  38:         sob     r0,2b
  39:         clrb    (r1)
  40: 3:
  41:         mov     (sp)+,r2        / restore r2
  42: 4:
  43:         mov     2(sp),r0        / and return s1
  44:         rts     pc
Last modified: 1988-01-11
Generated: 2016-12-26
Generated by src2html V0.67
page hit count: 3022
Valid CSS Valid XHTML 1.0 Strict