This 24-bit version has a sequence length of 16777215: 21 bytes, 173-181 cycles.
Y as a parameter specifies number of random bits to generate (1 to 8)Īlternatively this loop could be unrolled with 8 entry points, saving the need to use Y or load it as a parameter.īy adding an extra byte or two to the seed variable, and choosing an appropriate polynomial to XOR with, we can extend the sequence length significantly with only one additonal ROL per byte (+40 cycles). use AND to mask the result), or if you are satisfied with less randomness, you can reduce Y, or even parameterize it:
If you intend to use fewer bits of the result (e.g. Each iteration effectively generators one more bit of entropy, so 8 iterations are needed for an 8-bit random number. The iteration count stored in Y can be reduced to speed up the generator, at the expense of quality of randomness. Eor #$39 apply XOR feedback whenever a 1 bit is shifted out