Re: A86: Random Number stuff


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

Re: A86: Random Number stuff




In a message dated 1/9/2000 4:19:10 PM Eastern Standard Time, 
asmti86@hotmail.com writes:

> I'm sure this has been asked before, but I'l ask anyway =) Is there a way 
to 
>  call the rand function from assembly? If so how? All I could find in the 
ASM 
> 
>  Studio 3.1 help file was _random, or is that what I should use? If those 
>  don't work, is there an algorithim that can do this? I just need something 
>  basic, like a random number 1-9. I could probably (try) to modify it later 
>  if needed. Any help would be appreciated.

I got this off guide.iwarp.com
create a random number from 0 to 15
  ld a,r            
  and %00001111 ;a is now <16

you could modify it so that it is within any range you want and its a lot 
simpler than the one used it tetris however the r register is the memory 
refresh register and is incremented after every each instruction executed by 
the processor so if it used frequently it may not be random. Also bit 7 is 
never set so it can never be greater than 127
------
MikeT843@aol.com


Follow-Ups: