The MASM Forum

General => The Workshop => Topic started by: Oliver Scantleberry on May 07, 2016, 02:30:27 PM

Title: nrandom function
Post by: Oliver Scantleberry on May 07, 2016, 02:30:27 PM
Does anyone know how to initialize the "nrandom_seed" or use the "nseed function", whichever one I should use, to use the "nrandom" function without a repeating series of output numbers?

Never mind, I found my typo-- "invoke nseed, var". Thanks anyway.
Title: Re: nrandom function
Post by: Vortex on May 07, 2016, 07:39:45 PM
Hi Oliver,

Reading the manual \masm32\help\masmlib.chm :

Quotenrandom

nrandom proc base:DWORD

Description

A Park Miller random algorithm written by Jaymeson Trudgen (NaN) and optimised by Rickey Bowers Jr. (bitRAKE).

Parameter

1.base Zero based range for random output.

Return Value

Random number within range set in "base" in EAX.

Comments

The seed for the random algorithm is set as a variable of GLOBAL scope in a seperate procedure atached to the library module. The variable is nrandom_seed and this variable should be set with a DWORD size number prior to the use of this algorithm.
Title: Re: nrandom function
Post by: bluedevil on June 28, 2016, 08:53:39 AM
Quote from: Oliver Scantleberry on May 07, 2016, 02:30:27 PM
Does anyone know how to initialize the "nrandom_seed" or use the "nseed function", whichever one I should use, to use the "nrandom" function without a repeating series of output numbers?

Never mind, I found my typo-- "invoke nseed, var". Thanks anyway.

Hi, actually you have solved the problem, anyway i have made and published sources about random functions once upon a time. Maybe people need them again ;) Check the attachments.

Regards