Re: [stella] entropy & randomness

Subject: Re: [stella] entropy & randomness
From: "Eric Ball/Markham/IBM" <eball@xxxxxxxxxx>
Date: Tue, 9 Oct 2001 14:18:10 -0400
Typo, X(n+1) = X(n) * 2

Have to wade in with my own C$0.03:

I have created the following 8 bit PRNG based on
http://www-2.cs.cmu.edu/~koopman/lfsr/

     LDA  RAND
     BEQ  XSEED
     LSR
     BCC  SRAND
XSEED:    EOR  #$A9
SRAND:    STA  RAND

Note: The webpage gives the XOR terms for a left shift LFSR, but since the
6502 only has ASL, I've flipped the bits of the term around.  You should
also be careful if you use RAND rather than just the carry bit because
there are a couple of sequences where X(n+1) = X(n) * 2.  (New) This is
normally avoided by shifting in a bit based on the XOR of several bits, but
that requires more instructions.

For experimentation, here is the LFSR in Basic:
FOR x = 0 TO 255
  IF r <= 0 OR r > 255 THEN
    r = 169
  ELSEIF r >= 128 THEN
      r = (r * 2) XOR (256 + 169)
  ELSE
    r = r * 2
  END IF
  PRINT r,
NEXT x




-
Archives (includes files) at http://www.biglist.com/lists/stella/archives/
Unsub & more at http://www.biglist.com/lists/stella/





-
Archives (includes files) at http://www.biglist.com/lists/stella/archives/
Unsub & more at http://www.biglist.com/lists/stella/

Current Thread