Re: A86: Random Number stuff


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

Re: A86: Random Number stuff




Cool, thanx a lot =)


>From: JayEll64@aol.com
>Reply-To: assembly-86@lists.ticalc.org
>To: assembly-86@lists.ticalc.org
>Subject: Re: A86: Random Number stuff
>Date: Sun, 9 Jan 2000 16:44:20 EST
>
>
>In a message dated 1/9/00 2:19:10 PM Mountain 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.
>
>Something like the following is all you should really need:
>
>;Randomization routine by Jimmy Mardell (used in ZTetris v3.0)
>PRandom:               ; Creates a pseudorandom number 0 <= x < A
>  ld b,a
>  ld a,r
>  add a,a
>  ld hl,0
>  ld d,0
>  ld e,a
>RMul:
>  add hl,de
>  djnz RMul
>  ld a,h
>  ret
>
>This could obviously be optimized if you have a constant range (ie, 0 <= x 
><
>9, and then increase the result to get a range of 1 to 9).
>
>JayEll
>

______________________________________________________
Get Your Private, Free Email at http://www.hotmail.com