**RANDOM**

**Random generator**

The basis of the random generator in Litos8 system is generation of pseudo-random sequence of numbers using calculation new_seed = old_seed*17405 + 10395331. Unlike conventional algorithms, the calculation carried out 64-bit with exchanging double word operands, thus ensuring sufficient diversity of random numbers, with huge repeat interval. Moreover, number generator can be wobbled with unforeseeable events, such as pressing a key.

**RandInit** - initialize
random generator

INPUT:

DX:AX = new random generator seed

BL = flag, 0 = use pseudorandom sequence, 1 = enable events

**RandShift** - shift random
generator with an event

INPUT:

AX,BX,CX = shift random value

**RandByte** - get random byte

OUTPUT:

AL = random byte (0 to 0ffh)

**RandWord** - get random word

OUTPUT:

AX = random word (0 to 0ffffh)

**RandDWord** - get random
dword

OUTPUT:

DX:AX = random double word (0 to 0ffffffffh)

**RandByteMax** - get random
byte with max value

INPUT:

AL = maximal unsigned value (0 to 0ffh)

OUTPUT:

AL = random byte (0 to maximal value)

**RandWordMax** - get random
word with max value

INPUT:

AX = maximal unsigned value (0 to 0ffffh)

OUTPUT:

AX = random word (0 to maximal value)

**RandDWordMax** - get random
dword with max value

INPUT:

DX:AX = maximal unsigned value (0 to 0ffffffffh)

OUTPUT:

DX:AX = random double word (0 to maximal value)

**RandSByteMax** - get random
signed byte with max value

INPUT:

AL = maximal signed value (-128 to +127)

OUTPUT:

AL = random byte (0 to maximal value)

**RandSWordMax** - get random
signed word with max value

INPUT:

AX = maximal signed value (-32768 to +32767)

OUTPUT:

AX = random word (0 to maximal value)

**RandSDWordMax** - get random
signed dword with max value

INPUT:

DX:AX = maximal signed value (-80000000h to +7fffffffh)

OUTPUT:

DX:AX = random double word (0 to maximal value)

**RandByteInt** - get random
byte in interval

INPUT:

AL = maximal value (unsigned)

AH = minimal value (unsigned)

OUTPUT:

AL = random byte (min to max)

**RandWordInt** - get random
word in interval

INPUT:

AX = maximal value (unsigned)

DX = minimal value (unsigned)

OUTPUT:

AX = random word (min to max)

**RandDWordInt** - get random
dword in interval

INPUT:

DX:AX = maximal value (unsigned)

BX:CX = minimal value (unsigned)

OUTPUT:

DX:AX = random double word (min to max)

**RandSByteInt** - get random
signed byte in interval

INPUT:

AL = maximal value (signed)

AH = minimal value (signed)

OUTPUT:

AL = random byte (min to max)

**RandSWordInt** - get random
signed word in interval

INPUT:

AX = maximal value (signed)

DX = minimal value (signed)

OUTPUT:

AX = random word (min to max)

**RandSDWordInt** - get random
signed dword in interval

INPUT:

DX:AX = maximal value (signed)

BX:CX = minimal value (signed)

OUTPUT:

DX:AX = random double word (min to max)