Article View: comp.os.msdos.programmer
Article #7756Re: Random number function (SUPPLIED)
From: Bittware
Date: Tue, 26 Jan 1993 02:11
Date: Tue, 26 Jan 1993 02:11
33 lines
1190 bytes
1190 bytes
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;
}
Technical Details
Message-ID:
<1993Jan26.021158.10416@grebyn.com>Path:
arc1-ca.pugleaf.net!sparky!uunet!grebyn!daily!bittwareReferences:
<1jv5udINNl5u@duncan.cs.utk.edu> <1k1gh3INN9r5@darkstar.UCSC.EDU>Show Full Headers
Complete Article Headers
Newsgroups: comp.os.msdos.programmer,comp.os.msdos.misc,comp.programming Path: arc1-ca.pugleaf.net!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