flat assembler
Message board for the users of flat assembler.
 Home   FAQ   Search   Register 
 Profile   Log in to check your private messages   Log in 
flat assembler > OS Construction > Simple Pseudo Random Number Generator

Author
Thread Post new topic Reply to topic
Mike Gonta



Joined: 26 Dec 2010
Posts: 186
Simple Pseudo Random Number Generator
Here is a simple real mode (80386 code) PRNG with a period of (2^64)-1.
It's an optimized implementation (only 4 instructions) of the Galois LFSR PRNG.
There's an LCG in simple_prng_init to process the entropy.
I'm using it in Space Invaders

Code:

  shr edx1
  rcr eax1
  jnc .1
  xor edx0xD0000000 ; 0xD000000000000000 is maximal tap for 64 bit
.1:


simple_prng.asm

_________________
Mike Gonta
look and see - many look but few see

http://mikegonta.com
Post 17 Feb 2017, 22:03
View user's profile Send private message Reply with quote
nkeck72



Joined: 28 May 2015
Posts: 78
Location: 0000:7C00
Nice. I might use this in another project of mine if I get the chance.
Post 21 Feb 2017, 22:23
View user's profile Send private message Visit poster's website Reply with quote
Display posts from previous:
Post new topic Reply to topic

Jump to:  


< Last Thread | Next Thread >

Forum Rules:
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You can download files in this forum


Powered by phpBB © 2001-2005 phpBB Group.

Main index   Download   Documentation   Examples   Message board
Copyright © 2004-2016, Tomasz Grysztar.