/*		Q/C V3.2 Utility Library		*/
/*     Copyright (c) 1984 Quality Computer Systems	*/
/*			11/25/84			*/

#include "stdio.h"

#ifdef PORTABLE
/* copy second string into first string */
char *strcpy(s1, s2)
char *s1, *s2;
	{
	register char *p;

	p = s1;
	while (*p++ = *s2++)	/* copy 2nd string into 1st */
		;
	return s1;
	}
#else
char *strcpy() {
#asm 8080
	LXI	H,2	;get s2
	DAD	SP
	MOV	E,M
	INX	H
	MOV	D,M
	INX	H
	MOV	A,M	;get s1
	INX	H
	MOV	H,M
	MOV	L,A
	PUSH	H	;save s1 for return
?scpy1: LDAX	D	;*s2
	MOV	M,A	;copy to *s1
	ORA	A	;check for end-of-string '\0'
	JZ	?scpy2
	INX	D	;move to next char
	INX	H
	JMP	?scpy1
?scpy2: POP	HL	;return s1
	MOV	A,H
	ORA	L	;set Z flag
#endasm
	}
#endif

