Category : Pascal Source Code
Archive   : PASS_ALL.ZIP
Filename : TI204.ASC

 
Output of file : TI204.ASC contained in archive : PASS_ALL.ZIP








PRODUCT : TURBO PASCAL NUMBER : 204
VERSION : 2.0xx
OS : PC-DOS, MS-DOS
DATE : April 1, 1986 PAGE : 1/2
TITLE : RANDOM NUMBER SEED LOCATIONS




Turbo Pascal maintains a four byte random number seed. There is
a Randomize procedure to give that seed a random value which the
function, Random, then uses to generate random values within a
specified range.

Random : r := seed;

The function Random(value) calls the following routine:

function Random(N_Max): real;
var c1, c2, r : real;
begin
c1 := exp(32 * ln(2));
c2 := exp(16 * ln(2));
r := (r * 129 * $361962E9) mod c1;
Random := r div c2 mod N_Max;
end;

The following table gives the random number seed address for most
Turbo Pascal implementations:

Random Number Seed Locations

IBM TURBO.COM 0129
IBM TURBO-87.COM 0116
Generic TURBO.COM 0129
Generic TURBO-87.COM 0116

The seed may be declared as:

Var RandomSeed: Array [0..3] Of Byte Absolute DSeg:$0129;

or:

Var RandomSeed: Array [0..1] Of Integer Absolute DSeg:$0129;

By replacing the value in the address, you can seed the random number
generator in any way you like: read it from a file; read a number
from the user; ask for the user to hit a key, and count until he
does; get the system time; or, assign a constant value. Using
constant values is useful in making statistical simulations uniform.










  3 Responses to “Category : Pascal Source Code
Archive   : PASS_ALL.ZIP
Filename : TI204.ASC

  1. Very nice! Thank you for this wonderful archive. I wonder why I found it only now. Long live the BBS file archives!

  2. This is so awesome! 😀 I’d be cool if you could download an entire archive of this at once, though.

  3. But one thing that puzzles me is the “mtswslnkmcjklsdlsbdmMICROSOFT” string. There is an article about it here. It is definitely worth a read: http://www.os2museum.com/wp/mtswslnk/