Created
February 5, 2017 17:57
-
-
Save bhickey/0de228c02cc60b5965582d2d946d8c38 to your computer and use it in GitHub Desktop.
6502 xorshift, 8-bit full period
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| ; r ^= (r << 1) | |
| ; r ^= (r >> 1) | |
| ; r ^= (r << 2) | |
| xorshift: | |
| lda <RAND_SEED | |
| asl a | |
| eor <RAND_SEED | |
| tax | |
| asr a | |
| eor x | |
| tax | |
| asr a | |
| asr a | |
| eor x | |
| rts |
16 bit version:
(It may be incorrect...)
Random:
lda random + 1
pha
lda random
asl a
rol random + 1
asl a
rol random + 1
asl a
rol random + 1
asl a
rol random + 1
asl a
rol random + 1
asl a
rol random + 1
asl a
rol random + 1
eor random
sta random
pla
eor random + 1
sta random + 1
lsr a
eor random
sta random
eor random + 1
sta random + 1
rts
http://www.retroprogramming.com/2017/07/xorshift-pseudorandom-numbers-in-z80.html
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Version without X register: