The 'r' register is a random number generator. It contains a value that is a power of 2. So to use it to produce simple random numbers (as seen in Avalanche) do this: ld a,r ;get rand # srl a ;shift right logically - to just 'change' the number a bit and 63 ;mask off bits so the # is between 1-63 - (e.g. and 127,3,15) Hope this helps!