File:  [MW Coherent from dump] / coherent / b / lib / libc / string / i8086 / strncpy.m
Revision 1.1.1.1 (vendor branch): download - view: text, annotated - select for diffs
Wed May 29 04:56:35 2019 UTC (7 years ago) by root
Branches: MarkWilliams, MAIN
CVS tags: relic, HEAD
coherent

//////////
/ i8086 C string library.
/ strncpy()
/ ANSI 4.11.2.4.
//////////

//////////
/ char *
/ strncpy(To, From, Count)
/ char *To, *From;
/ int Count;
/
/ Copy up to Count bytes from From to To,
/ then NUL-pad if Count not reached.
//////////

#include <larges.h>

To	=	LEFTARG
From	=	To+DPL
Count	=	From+DPL

	Enter(strncpy_)
	Les	di, To(bp)	/ To address to ES:DI
	mov	cx, Count(bp)	/ Count to CX
	or	cx, cx
	je	2f		/ Copy nothing
	Lds	si, From(bp)	/ From address to DS:SI
	cld

1:	lodsb			/ Fetch From character
	stosb			/ and store through To
	orb	al, al
	loopne	1b		/ Continue if AL!=0 && CX!=0
	rep			/ Finish clearing line
	stosb			/ (does nothing if CX==0)

2:	mov	ax, To(bp)	/ Return the destination
#if	LARGEDATA
	mov	dx, es
#endif
	Leave

unix.superglobalmegacorp.com

This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.