flat assembler
Message board for the users of flat assembler.

Index > OS Construction > Simple Pseudo Random Number Generator

Author
Thread Post new topic Reply to topic
Mike Gonta



Joined: 26 Dec 2010
Posts: 243
Mike Gonta 17 Feb 2017, 22:03
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 edx, 1
  rcr eax, 1
  jnc .1
  xor edx, 0xD0000000 ; 0xD000000000000000 is maximal tap for 64 bit
.1:    

simple_prng.asm

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

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



Joined: 28 May 2015
Posts: 83
Location: 0000:7C00
nkeck72 21 Feb 2017, 22:23
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


Copyright © 1999-2024, Tomasz Grysztar. Also on GitHub, YouTube.

Website powered by rwasa.