141818Sbostic/*- 2*61123Sbostic * Copyright (c) 1990, 1993 3*61123Sbostic * The Regents of the University of California. All rights reserved. 441818Sbostic * 541818Sbostic * This code is derived from software contributed to Berkeley by 641818Sbostic * the Systems Programming Group of the University of Utah Computer 741818Sbostic * Science Department. 841818Sbostic * 941818Sbostic * %sccs.include.redist.c% 1041818Sbostic */ 1141818Sbostic 1241818Sbostic#if defined(LIBC_SCCS) && !defined(lint) 13*61123Sbostic .asciz "@(#)strncpy.s 8.1 (Berkeley) 06/04/93" 1441818Sbostic#endif /* LIBC_SCCS and not lint */ 1541818Sbostic 1641818Sbostic#include "DEFS.h" 1741818Sbostic 1841818SbosticENTRY(strncpy) 1941818Sbostic movl sp@(4),d0 /* return value is toaddr */ 2041818Sbostic movl sp@(12),d1 /* count */ 2141818Sbostic jeq scdone /* nothing to do */ 2241818Sbostic movl sp@(8),a0 /* a0 = fromaddr */ 2341818Sbostic movl d0,a1 /* a1 = toaddr */ 2441818Sbosticscloop: 2541818Sbostic movb a0@+,a1@+ /* copy a byte */ 2641818Sbostic jeq scploop /* copied null, go pad if necessary */ 2741818Sbostic subql #1,d1 /* adjust count */ 2841818Sbostic jne scloop /* more room, keep going */ 2941818Sbosticscdone: 3041818Sbostic rts 3141818Sbosticscploop: 3241818Sbostic subql #1,d1 /* adjust count */ 3341818Sbostic jeq scdone /* no more room, all done */ 3441818Sbostic clrb a1@+ /* clear a byte */ 3541818Sbostic jra scploop /* keep going */ 36