Article View: comp.os.msdos.programmer
Article #941Re: Random numbers in assembly language
From: Denis Beauregard
Date: Mon, 17 Aug 1992 18:45
Date: Mon, 17 Aug 1992 18:45
36 lines
1962 bytes
1962 bytes
I don't see how you could generate random numbers using a timer, except for the 1st number ;-) So, another solution : From Electronics, May 27, 1976. You will have to consider a word or a byte and a few bits (or taps) in it. You shift the word and insert a value (i.e. carry) that is one or zero depending on the added value of the taps (with a xor operator). carry = A xor B xor C, when A, B and C etc. are taps. For the longer sequence, with one byte, use: bits 1 and 7 or 3 and 7 (i.e. carry depends on bits 1 and 7, then do a ROT). For a word (15 bits in the example), you will get 32767 consecutive different pseudo-random values from : 1 and 15, or 4 and 15 or 7 and 15. For a double word (31 bits), taps are 3 and 31, 6 and 31, 7 and 31 or 13 and 31 (2,146,483,647 values). For the exact programming, I leave it to the original poster! After all, you selected Assembly because it was too easy otherwise... P.S. I used taps because the original article is for an electronics device. Taps are selected bits. P.P.S. You still select the initial value from a true random event like the initial clock value, but don't use the 18.2 clock (not enough random). -- \_\ Denis Beauregard * internet:beaurega@ireq.hydro.qc.ca / \ Genealogiste officiel : Beauregard/Jarret/Jarest/Vincent J __> Barthelemy Jarret (1471) -> Andre Jarret, sieur de Beauregard (1665) \_.-=== -> Denis Beauregard (1992) Opinions ? Et pis non !
Technical Details
Message-ID:
<Bt55GE.8t9@ireq.hydro.qc.ca>Path:
arc1-ca.pugleaf.net!sparky!uunet!bonnie.concordia.ca!hobbit.ireq.hydro.qc.ca!beauregaReferences:
<92220.125612F13@psuvm.psu.edu>Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!sparky!uunet!bonnie.concordia.ca!hobbit.ireq.hydro.qc.ca!beaurega From: beaurega@ireq.hydro.qc.ca (Denis Beauregard) Newsgroups: comp.os.msdos.programmer Subject: Re: Random numbers in assembly language Message-ID: <Bt55GE.8t9@ireq.hydro.qc.ca> Date: 17 Aug 92 18:45:50 GMT References: <92220.125612F13@psuvm.psu.edu> Sender: news@ireq.hydro.qc.ca (Netnews Admin) Organization: Institut de recherche d'Hydro-Quebec, Varennes, Canada Lines: 36