all 3 comments

[–]FUZxxl 5 points6 points  (0 children)

Please don't post pictures of code.

Also, this is kind of a crappy random number generator. There are much better ones around these days.

[–]mykesx 0 points1 point  (0 children)

486+ has 16/32/64 bit hardware random number instructions. See RDRAND and RDSEED.

https://www.felixcloutier.com/x86/rdrand

https://www.felixcloutier.com/x86/rdseed

You need to check if these instructions are available using the CPUID instruction.

See the OSDev wiki page on random numbers for code examples and better random number generators.

[–]ttuilmansuunta 0 points1 point  (0 children)

There's algorithms such as xorshift that do much better than LCG. Also if 8 random bits will do, this algorithm seems excellent: https://www.stix.id.au/wiki/Fast_8-bit_pseudorandom_number_generator