:word fastcall STRLEN(BX)
{
	AX = 0;
	#ifdef MarkerFunction
//	WHILE((DSBYTE[BX] != 0) && (DSBYTE[BX] != 1))
	WHILE($test DSBYTE[BX],0FEh) {
//	WHILE(DSBYTE[BX] != 0) && (DSBYTE[BX] != 1)
	#else
	WHILE(DSBYTE[BX] != 0) {
	#endif
		BX++;
		AX++;
	}
}

:void fastcall COPY(DI,SI,CX)
{
	$repe $movsb
}

:void fastcall COPYBACKWARD(DI,SI,CX)
{
	DI += CX;
	SI += CX;
	DI--;
	SI--;
	$std          
	$repe $movsb
	$cld          
}

//void memcpy(char* to, char* from, int length)
:void fastcall memcpy(DI,SI,CX)
{
	$push es,si,di
	ES = DS;
	IF(SI > DI) COPY(DI,SI,CX);
	IF(DI > SI) COPYBACKWARD(DI,SI,CX);
	$pop di,si,es
}

//void MEMSET(char* ,byte c,int n)
:void fastcall MEMSET(DI,AL,CX)
{
	$push es
	ES = DS;
	$rep $stosb
	$pop es
}

:void fastcall memset(DI,AL,CX)
{
	$push di
	@MEMSET(DI,AL,CX);
	$pop di
}

:void fastcall MEMSETZ(DI,CX)
{
	MEMSET(DI,0,CX);
}

:void fastcall memsetz(DI,CX)
{
	memset(DI,0,CX);
}

#define UPCASE	0
#define LOWCASE 1

:void fastcall MEMCASE(SI,CX,DL)
{
	LOOPNZ(CX)
	{
		$lodsb
		IF(DL == UPCASE)
		{
			IF(AL >= 'a') && (AL <= 'z' ) DSBYTE[SI - 1] = AL & 5Fh; //-='a'-'A';
		}
		ELSE
		{
			IF(AL >= 'A') && (AL <= 'Z') DSBYTE[SI - 1] = AL | 0x20;
		}
	}
}

:void fastcall MEMUP(SI,CX)
{
	LOOPNZ(CX)
	{
		$lodsb
		IF(AL >= 'a') && (AL <= 'z' ) DSBYTE[SI - 1] = AL & 5Fh; //-='a'-'A';
	}
}

:void fastcall MEMLOW(SI,CX)
{
	LOOPNZ(CX)
	{
		$lodsb
		IF(AL >= 'A') && (AL <= 'Z') DSBYTE[SI - 1] = AL | 0x20;
	}
}
