News:

MASM32 SDK Description, downloads and other helpful links
MASM32.com New Forum Link
masmforum WebSite

random number generator

Started by fusspot, August 31, 2007, 02:44:35 PM

Previous topic - Next topic

fusspot

Is it possible to implement random number generation in assembler language?
If yes, how do i do that?

ragdog

hi

here is a algo from firewoks project

random PROC base:DWORD        ; Park Miller random number algorithm
   mov eax, seed            ; from M32lib/nrand.asm
   xor edx, edx
   mov ecx, 127773
   div ecx
   mov ecx, eax
   mov eax, 16807
   mul edx
   mov edx, ecx
   mov ecx, eax
   mov eax, 2836
   mul edx
   sub ecx, eax
   xor edx, edx
   mov eax, ecx
   mov seed, ecx
   div base
   mov eax, edx
   ret
random ENDP

greets

sonic

masmlib already contains a random number generator (nrandom)

0x58

and in case of generating 0.F --> 0123456789ABCDEF  ::)

brethren

 i wrote an asm version of the well512 random number generator(just google it).
http://www.masm32.com/board/index.php?topic=11679.msg122005#msg122005
http://www.masm32.com/board/index.php?topic=11679.msg121891#msg121891

theres a seperate asm file (well512.asm) that you can assemble and add to your own library if you want and a small example of its usage

dedndave

last week - everyone was writing one    :P
look in the laboratory and workshop

jj2007

Quote from: dedndave on November 20, 2010, 08:45:10 PM
last week - everyone was writing one    :P
look in the laboratory and workshop

No, Dave is not kidding. Go here.