dword Rand;

void InitRand32()
{
	$rdtsc
	Rand=EAX>>2+1;
}

dword stdcall Rand32(dword base)
{
	$push EDX
	EAX=Rand/127773;
	EAX><EDX;
	$push EDX
	EAX=EAX*16807;
	$pop EDX
	EAX><EDX;
	$push EDX
	EAX=EAX*2836;
	$pop EDX
	EDX-=EAX;
	Rand=EAX=EDX;
	EAX=EAX%base;
	$pop EDX
}

            
