68k, 32 bit, pseudo random number generator. By Lee Davison.
Back
* 32 bit 68k version of PRNG. Prng32 must be in RAM and must be * initialised to a non zero value. Taking the 5th next number is * slower but helps hide the shift nature of this generator. NextPRNG MOVEQ #4,d2 * do this 5 times MOVE.l Prng32,d0 * get current Ninc0 MOVEQ #0,d1 * clear bit count ROR.l #2,d0 * bit 31 -> carry BCC Ninc1 * skip increment if =0 ADDQ.b #1,d1 * else increment bit count Ninc1 ROR.l #3,d0 * bit 28 -> carry BCC Ninc2 * skip increment if =0 ADDQ.b #1,d1 * else increment bit count Ninc2 ROL.l #5,d0 * restore PRNG longword ROXR.b #1,d1 * EOR bit into Xb ROXR.l #1,d0 * shift bit to most significant DBF d2,Ninc0 * loop 5 times MOVE.l d0,Prng32 * save back to seed word RTS Prng32 ds.l 1 * random number storeThe 6502 8 bit version can be found here and the Z80 8 bit version can be found here.