


int BLG_memcpy8(void *dst, void *src, int len)
{
	_asm
	{
		//Saving registries
		push eax
		push ebx
		push ecx
		push edx
		//Storing data
		mov eax, dst
		mov ebx, src
		mov ecx, len
		//Checking empty string
		cmp ecx, 0
		//$BLG - v5.22: Modif
		//je  LOOPEND
		jle LOOPEND
		//Copying data
		//Tried to optimize next lines, with blocks of 4,2 & 1 byte(s) depending on ecx value : no noticeable performance improvement		
		LOOPSTART:
		mov dl, [ebx]
		mov [eax], dl
		inc eax
		inc ebx
		dec ecx
		cmp ecx, 0
		jne LOOPSTART
		LOOPEND:
		//Restoring registries
		pop edx
		pop ecx
		pop ebx
		pop eax
	}
	return 0;
}


// Original code from baselib.cpp/MBstrlowercase()
// for(k=0;k<l;k++) if ((p[k]>='A')&&(p[k]<='Z')) p[k]+='a'-'A';

int BLG_lowercase(void *src, int len)
{
	_asm
	{
		//Saving registries
		push eax
		push ebx
		push ecx
		//Storing data
		mov eax, src
		mov ecx, len
		//Checking empty string
		cmp ecx, 0
		//$BLG - v5.22: Modif
		//je  LOOPEND
		jle LOOPEND
		//Checking and modifying case
		LOOPSTART:
		mov bl, [eax]
		cmp bl, 65
		jl LOOPAGAIN			// ignore char if < 'A'
		cmp bl, 90
		jg LOOPAGAIN			// ignore char if > 'Z'
		add bl, 32
		mov [eax], bl		// add 'a'-'A' if uppercase to get lowercase
		LOOPAGAIN:
		inc eax
		dec ecx
		cmp ecx, 0
		jne LOOPSTART
		LOOPEND:
		//Restoring registries
		pop ecx
		pop ebx
		pop eax
	}
	return 0;
}


// Original code from baselib.cpp/MBstruppercase()
// for(k=0;k<l;k++) if ((p[k]>='a')&&(p[k]<='z')) p[k]+='A'-'a';

int BLG_uppercase(void *src, int len)
{
	_asm
	{
		//Saving registries
		push eax
		push ebx
		push ecx
		//Storing data
		mov eax, src
		mov ecx, len
		//Checking empty string
		cmp ecx, 0
		//$BLG - v5.22: Modif
		//je  LOOPEND
		jle  LOOPEND
		//Checking and modifying case
		LOOPSTART:
		mov bl, [eax]
		cmp bl, 97
		jl LOOPAGAIN			// ignore char if < 'a'
		cmp bl, 122
		jg LOOPAGAIN			// ignore char if > 'z'
		sub bl, 32
		mov [eax], bl		// sub 'a'-'A' if lowercase to get uppercase
		LOOPAGAIN:
		inc eax
		dec ecx
		cmp ecx, 0
		jne LOOPSTART
		LOOPEND:
		//Restoring registries
		pop ecx
		pop ebx
		pop eax
	}
	return 0;
}