### Progman

That is a linear congruential generator LCG with period of 2^16 per birthday theorem. The multiplication addition though is fast and simple. Generally modern contexts should have 2^64 period minimum.

Better is the famous Mersenne Twister algorithm. I've not seen it in hand written assembler but it would be too difficult. 2^19337-1 proven periodicity though is impressive.

Not for security still. Windows API is easiest if a secure one is needed.

If you need a value between 0 and x. Determine log2 by finding the bit size. If number from RNG truncated to bit size is still bigger than x, get another random number otherwise use it. Now you dont cause statistical bias due to modulo. On average 1-2 calls to get a random number depending on how far x is from Rounding up to nearest power of 2.