xref: /original-bsd/lib/libc/hp300/string/strncpy.s (revision c3e32dec)
1/*-
2 * Copyright (c) 1990, 1993
3 *	The Regents of the University of California.  All rights reserved.
4 *
5 * This code is derived from software contributed to Berkeley by
6 * the Systems Programming Group of the University of Utah Computer
7 * Science Department.
8 *
9 * %sccs.include.redist.c%
10 */
11
12#if defined(LIBC_SCCS) && !defined(lint)
13	.asciz "@(#)strncpy.s	8.1 (Berkeley) 06/04/93"
14#endif /* LIBC_SCCS and not lint */
15
16#include "DEFS.h"
17
18ENTRY(strncpy)
19	movl	sp@(4),d0	/* return value is toaddr */
20	movl	sp@(12),d1	/* count */
21	jeq	scdone		/* nothing to do */
22	movl	sp@(8),a0	/* a0 = fromaddr */
23	movl	d0,a1		/* a1 = toaddr */
24scloop:
25	movb	a0@+,a1@+	/* copy a byte */
26	jeq	scploop		/* copied null, go pad if necessary */
27	subql	#1,d1		/* adjust count */
28	jne	scloop		/* more room, keep going */
29scdone:
30	rts
31scploop:
32	subql	#1,d1		/* adjust count */
33	jeq	scdone		/* no more room, all done */
34	clrb	a1@+		/* clear a byte */
35	jra	scploop		/* keep going */
36