base:16bit_xorshift_random_generator
Differences
This shows you the differences between two versions of the page.
Both sides previous revisionPrevious revisionNext revision | Previous revisionLast revisionBoth sides next revision | ||
base:16bit_xorshift_random_generator [2019-05-10 02:37] – vsariola | base:16bit_xorshift_random_generator [2019-05-10 22:03] – vsariola | ||
---|---|---|---|
Line 4: | Line 4: | ||
* ported by: Veikko Sariola | * ported by: Veikko Sariola | ||
- | Xorshift is a fast pseudorandom generator algorithm originally developed by [[https:// | + | Xorshift is a fast pseudorandom generator algorithm originally developed by [[https:// |
<code c> | <code c> | ||
Line 31: | Line 31: | ||
STA rng_zp_high | STA rng_zp_high | ||
... | ... | ||
- | ; the RNG, you can get 8-bit random numbers in A, leaves | + | ; the RNG. You can get 8-bit random numbers in A or 16-bit numbers |
+ | ; from the zero page addresses. Leaves | ||
random | random | ||
LSR | LSR | ||
Line 40: | Line 41: | ||
ROR ; A has now x >> 9 and high bit comes from low byte | ROR ; A has now x >> 9 and high bit comes from low byte | ||
EOR rng_zp_low | EOR rng_zp_low | ||
- | STA rng_zp_low | + | STA rng_zp_low |
EOR rng_zp_high | EOR rng_zp_high | ||
STA rng_zp_high ; x ^= x << 8 done | STA rng_zp_high ; x ^= x << 8 done |
base/16bit_xorshift_random_generator.txt · Last modified: 2019-08-12 15:41 by ftc