base:16bit_xorshift_random_generator
Differences
This shows you the differences between two versions of the page.
Both sides previous revisionPrevious revision | Next revisionBoth sides next revision | ||
base:16bit_xorshift_random_generator [2019-05-10 02:09] – vsariola | base:16bit_xorshift_random_generator [2019-05-10 02:37] – vsariola | ||
---|---|---|---|
Line 20: | Line 20: | ||
</ | </ | ||
- | Here is an implementation for the C64. 25 cycles without the RTS. | + | Here is an implementation for the C64. 30 cycles without the RTS. |
<code asm> | <code asm> | ||
Line 32: | Line 32: | ||
... | ... | ||
; the RNG, you can get 8-bit random numbers in A, leaves X/Y unchanged | ; the RNG, you can get 8-bit random numbers in A, leaves X/Y unchanged | ||
- | random | + | random |
LSR | LSR | ||
+ | LDA rng_zp_low | ||
+ | ROR | ||
EOR rng_zp_high | EOR rng_zp_high | ||
STA rng_zp_high ; high part of x ^= x << 7 done | STA rng_zp_high ; high part of x ^= x << 7 done | ||
- | ROR ; A has now x >> 9 and the high bit of the 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 |
base/16bit_xorshift_random_generator.txt · Last modified: 2019-08-12 15:41 by ftc