home *** CD-ROM | disk | FTP | other *** search
- Nntp-Posting-Host: yrsa.ifi.uio.no
- Newsgroups: alt.sys.amiga.demos
- Path: sparky!uunet!mcsun!sunic!aun.uninett.no!nuug!ifi.uio.no!larshaug
- From: larshaug@ifi.uio.no (Lars Haugseth)
- Subject: Re: pseudo random numbers
- Message-ID: <1993Jan26.090949.4643@ifi.uio.no>
- Sender: larshaug@ifi.uio.no (Lars Haugseth)
- Organization: Dept. of Informatics, University of Oslo, Norway
- References: <1k19ioINN7l8@darkstar.UCSC.EDU>
- Date: Tue, 26 Jan 1993 09:09:49 GMT
- Lines: 46
- Originator: larshaug@yrsa.ifi.uio.no
-
-
- In article <1k19ioINN7l8@darkstar.UCSC.EDU>, moria@ucscb.UCSC.EDU (Moria Beledain) writes:
- >
- > pfibl.
- > i am looking for a Good pseudo random number generator.
- > the one i am using now was by Leo Schwabb many years ago, and
- > i have modified it to now and then EOR in some clock counter
- > etc.. But i am still not satisfied!
- >
- > so who knows some good ideas ?
- > .. Maybe a routine to use the HPos.. It has periods of
- > very fast fluctuation which if polled slow enough could seem
- > quite random..
- > .. hmm
- > rnd
- > move.w seed,d0
- > lsl.w #4,d0
- > eor.b HPOS,d0
- > move.w d0,seed
- > rts
- >
-
- Here's how I do it, and I get pretty good results :
-
- GETRND: moveq #0,d0
- moveq #0,d1
- move.b $DFF007,d0
- move.b $BFD800,d1
- eor.b d1,d0
- rts
-
- This following is better, but takes more cycles :
-
- GETRND: moveq #0,d0
- move.b $DFF007,d0
- move.b $BFD800,d1
- eor.b d1,d0
- move.b d0,d1
- and.w #15,d1
- GRND1: dbf d1,GRND1
- rts
-
- The loop is done so that the time between my bsr GETRND 's will
- wary slightly to produce 'more random' numbers.
-
- Lars
-