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

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

randomgenerator:

retn 0

;) Take a look at at http://www.asmcommunity.net/board/index.php?topic=27928.0

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 :)

where I took Park Miller and Mersenne Twister B and made them feed into each other :)

Also you can use MS CryptoAPI:

PROV_RSA_FULL EQU 1

Gen_Random PROC

LOCAL hProv:DWORD

LOCAL rNumber:BYTE

invoke CryptAcquireContext,ADDR hProv,NULL,NULL,PROV_RSA_FULL,NULL

invoke CryptGenRandom,hProv,1,ADDR rNumber

invoke CryptReleaseContext,hProv,NULL

movzx eax,rNumber

ret

Gen_Random ENDP

PROV_RSA_FULL EQU 1

Gen_Random PROC

LOCAL hProv:DWORD

LOCAL rNumber:BYTE

invoke CryptAcquireContext,ADDR hProv,NULL,NULL,PROV_RSA_FULL,NULL

invoke CryptGenRandom,hProv,1,ADDR rNumber

invoke CryptReleaseContext,hProv,NULL

movzx eax,rNumber

ret

Gen_Random ENDP