Hey guys!Hopefully this time in the right part of the messageboard X). Anyhoo, do you guys know how to generate random numbers, single digits, whose range is from 0-9.

I started using this equation :(Min+Max)/2. I tried it for a few times but it only gives the numbers 4-9 not the other three.

Oh, btw. I'm doing this in TASM.

If anyone knows how, please do share. A super simple but generates all the numbers from 0 to 9 would do.  :D
Posted on 2008-09-27 08:18:00 by razzler

    retn 0

;) Take a look at at http://www.asmcommunity.net/board/index.php?topic=27928.0
Posted on 2008-09-27 22:35:46 by roticv
Park-Miller is quick and easy but a graphical analysis of the emitted series of numbers shows that it doesn't have a very good spread - the emitted values tend to cluster rather than be evenly spread across the numeric domain - if you want a much better random generator see http://www.asmcommunity.net/board/index.php?topic=20571.0
where I took Park Miller and Mersenne Twister B and made them feed into each other :)
Posted on 2008-09-27 22:45:40 by Homer
Also you can use MS CryptoAPI:


Gen_Random PROC

  invoke CryptAcquireContext,ADDR hProv,NULL,NULL,PROV_RSA_FULL,NULL
  invoke CryptGenRandom,hProv,1,ADDR rNumber
  invoke CryptReleaseContext,hProv,NULL
  movzx eax,rNumber

Gen_Random ENDP

Posted on 2008-09-29 15:19:13 by hunter