/******************************************************************************

	ZCpyBl()

	This function copies a block of memory from one place to another.
It is passed the size of the memory area (in bytes) and the addresses
of the source and destination areas.  Characters are copied in such a
manner that the transfer is correct even if the source and destination
buffers overlap.

	The performance of TECO-C depends on the execution speed of this
function.  It is called to move text in the following ways:

	1. from the text buffer into q-registers and vice versa (X, G)
	2. from the command string into the edit buffer (I, <TAB>)
	3. from the command string into q-registers (^U)
	4. to move the edit buffer gap (C, R, L, S, N, etc)

	The real reason this exists is to provide access to a fast block
move capability.  On a VAX,  the OTS$MOVE3 routine provides access to a very
fast block move instruction.

*****************************************************************************/

#include "ZPort.h"		/* define portability identifiers */
#include "DefTeco.h"		/* define general identifiers */




#ifdef vax11c
VOID	ots$move3();		/* copy memory using MOVC3 instruction */

VOID ZCpyBl(Length, Source, Destin)
LONG Length;
char *Source;
char *Destin;
{
	ots$move3(Length, Source, Destin);
}


#else


VOID ZCpyBl(Length, Source, Destin)
LONG Length;
char *Source;
char *Destin;
{
	int i;

	if (Source < Destin)
		{
		Source += Length;
		Source--;
		Destin += Length;
		Destin--;
		for (i=0; i<Length; i++)
			*Destin-- = *Source--;
		}
	else
		for (i=0; i<Length; i++)
			*Destin++ = *Source++;
}
#endif
