Re: A83: Re: Random number


[Prev][Next][Index][Thread]

Re: A83: Re: Random number




In a message dated 29/02/00 17:33:04 GMT Standard Time, 
gte172i@prism.gatech.edu writes:

<< ld a,r    ; 0-255
 and %1    ; 0 or 1
           ;the value isnt very random but it is better than nothing. >>

I do not believe this is reliable. R is incremented on every instruction
byte fetch but certainly for some Z80 processors only bits 0..6 are
incremented, bit 7 says the same and can be altered by LD R,A.

Also, because this is tied into a cycle count if you are running code
which has a fixed number of T-States each time.

e.g.

repeat
    pos = Random(16)
until not Used[pos]

because for each iteration of the loop the number of t-states does not
vary then it is not impossible that pos could generate either a repeating
value or a repeating sequence of values which would cause the loop
to lock up.

Paul Robson.

... and when you write a spectrum emulator these idiocies do actually
matter :)