home *** CD-ROM | disk | FTP | other *** search
- Xref: sparky comp.os.msdos.programmer:12453 comp.os.msdos.misc:7195 comp.programming:3597
- Newsgroups: comp.os.msdos.programmer,comp.os.msdos.misc,comp.programming
- Path: sparky!uunet!grebyn!daily!bittware
- From: bittware@grebyn.com (Bittware)
- Subject: Re: Random number function (SUPPLIED)
- Message-ID: <1993Jan26.021158.10416@grebyn.com>
- Organization: Grebyn Timesharing
- References: <1jv5udINNl5u@duncan.cs.utk.edu> <1k1gh3INN9r5@darkstar.UCSC.EDU>
- Date: Tue, 26 Jan 1993 02:11:58 GMT
- Lines: 34
-
- I coded this up from an article I think in EDN, by an engineer at
- Tektronix. The code in the article was in some DSP assembler, and I
- converted it to C (isn't that backwards??). Anyway, it works. I tested
- it on a DSP32c output to a D/A and to a spectrum analyzer.
-
- -----BEGIN RAN32.C-----
-
- #include <math.h>
-
- /* generate 32-bit random noise using DSP32c */
-
- void ran32 (ioval)
- unsigned long *ioval;
- {
-
- #define C 0x234567
- #define Alo 0x007465
- #define Ahi 0x000010
-
- unsigned long Rlo, Rhi;
- unsigned long ar1, ar2, ar3;
- unsigned long t1, t2, t3;
-
- Rlo = *ioval & 0x00ffff;
- Rhi = *ioval >> 16;
- ar1 = Alo * Rlo;
- ar2 = Alo * Rhi;
- ar3 = Ahi * Rlo;
- t1 = (ar2 + ar3);
- t2 = t1 << 16;
- t3 = ar1 + t2;
- *ioval = C + t3;
- }
-
-