From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on inbox.vuxu.org X-Spam-Level: X-Spam-Status: No, score=-0.6 required=5.0 tests=DKIM_ADSP_CUSTOM_MED, DKIM_INVALID,DKIM_SIGNED,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,HTML_MESSAGE,MAILING_LIST_MULTI, T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.4 Received: from minnie.tuhs.org (minnie.tuhs.org [IPv6:2600:3c01:e000:146::1]) by inbox.vuxu.org (Postfix) with ESMTP id 8D95D23DED for ; Wed, 13 Mar 2024 17:42:18 +0100 (CET) Received: from minnie.tuhs.org (localhost [IPv6:::1]) by minnie.tuhs.org (Postfix) with ESMTP id 78B76427BA; Thu, 14 Mar 2024 02:42:07 +1000 (AEST) Received: from mail-lf1-x133.google.com (mail-lf1-x133.google.com [IPv6:2a00:1450:4864:20::133]) by minnie.tuhs.org (Postfix) with ESMTPS id B6AC1427B4 for ; Thu, 14 Mar 2024 02:42:00 +1000 (AEST) Received: by mail-lf1-x133.google.com with SMTP id 2adb3069b0e04-513c847c24dso68172e87.1 for ; Wed, 13 Mar 2024 09:42:00 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1710348119; x=1710952919; darn=tuhs.org; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:from:to:cc:subject:date:message-id:reply-to; bh=msBTD1yh3s84BINjTyAVFXLU1XGDKh7uFU9JkeKVCDY=; b=klk+ktRoQ8NaQ/G4Mh29g6aVB3IWdchz8x1TVaFwE+yHRM4MLFUNz7uH0ysLl2maJj FmR3gdq2TSz7icqhad46tNzN7hCxs6o0mUiuyK2BTUfrtjB5agsJs/QhGeE4ueqOKbnO Qtz2vlJ/qkeRNashD6EfXdDQy4apKsk4mDkJInGTycD8hF+LQ8p1FPk+IjoEmre9QEEr KdQIQ/E0gKM7z1XYrfH7ojCYIQZvnc2CPKs92kuP3bqZfLj9wK0gjiEcvzY40NnEmL5j 2pgVxGt7ANZrwbKTCYNrRMqJZCxtbsDAGwoWNtZRDD1rjAp9DiUv57B4PKfPkWA04Qa7 EHMQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1710348119; x=1710952919; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=msBTD1yh3s84BINjTyAVFXLU1XGDKh7uFU9JkeKVCDY=; b=mIIroa9Hl1tNwn7aJHXG/0eGLsNTl3/IhxYkYIE49ZYZadga9nDqQmAfAmRfap3k/M g1riruQwrm78LFaKx7pbi7pKCIx1TxZ3wlNa3nfmFnwMWbCwiNPY/pQoZ3KjrwGUir7I NGwto/4vYyYIVFtBWbgSLEpbzIWpmkQTq1gFFhGrRfJ7XpguzTdZ+n5ifWYmGfstFPlw gAL9Ss8ztXPeYQBnctvBXD9agUWsWGjNE1AeKcCfbcf7mJGIbwtwzN4nfqyvrsefEZOz HM8l7GodJz8iqgh0YvYSCPxpTx+hmGRJJ7krCnHBvRWYmlpqEF1qO+332bDqGZDzsJIi GbSA== X-Forwarded-Encrypted: i=1; AJvYcCVa7M5E8nvklt+t/r2V5vHrzXpw7Q2hYOtOL4ocmijHN72VdxN0aZD68kQo7NqSynhmHVUamVM00smy60me X-Gm-Message-State: AOJu0YyQmvkIP/4AI48ns50tlrnLYoAdC1/QlYiNoI75absf3ByAbzoi mXHiaLNR4gtqf2SIEGB+c3AYPJl9cjNKuzZBGapfIAIC7pmmEkFgOfX98VW05WaWVlJaRjZdFWw JmqUhHi1929bs+R2u9mFPdUncxH4= X-Google-Smtp-Source: AGHT+IH0am71yMC/VCWVc/KlnieTHc6Fnq8cDE8Km/h8TzkTY+OpcN3NokQZytRB9HjVBE7sVbHMKab+dbtxfK5EG4A= X-Received: by 2002:a05:6512:ba4:b0:513:a72c:de7c with SMTP id b36-20020a0565120ba400b00513a72cde7cmr5644430lfv.46.1710348118727; Wed, 13 Mar 2024 09:41:58 -0700 (PDT) MIME-Version: 1.0 References: In-Reply-To: From: ron minnich Date: Wed, 13 Mar 2024 09:41:46 -0700 Message-ID: To: Jonathan Gray Content-Type: multipart/alternative; boundary="0000000000000f333106138d7460" Message-ID-Hash: GXMX73LQXKQXYFED3V5BLNTWSHYOA25X X-Message-ID-Hash: GXMX73LQXKQXYFED3V5BLNTWSHYOA25X X-MailFrom: rminnich@gmail.com X-Mailman-Rule-Misses: dmarc-mitigation; no-senders; approved; emergency; loop; banned-address; member-moderation; nonmember-moderation; administrivia; implicit-dest; max-recipients; max-size; news-moderation; no-subject; digests; suspicious-header CC: Russ Cox , tuhs@tuhs.org X-Mailman-Version: 3.3.6b1 Precedence: list Subject: [TUHS] Re: early unix rand List-Id: The Unix Heritage Society mailing list Archived-At: List-Archive: List-Help: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: --0000000000000f333106138d7460 Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable by the way, I realize that random number urban legend sounds ridiculous, in light of how hardware design is done today, but those of you who did hardware design in those days (guilty!), and had access to -11 schematics and boards, might wonder if it's not possible. There was a habit, in those days, for performance reasons, of subbing transparent latches for flip-flops to gain a little time. An engineer I knew at Amdahl said that was a pretty hot topic there. Certainly, the technique of design for testability was not really in wide use in the -11 days. Gordon Bell's book "Computer Design" is particularly instructive. E.g., how did you verify the floating point on your new machine? Put an older machine next to a new machine, do lots of computation, see if there is disagreement, you've found a bug in the new machine, right? Maybe. Sometimes, you discover the older machine had a bug the newer one did not ... happened more than once, including on the 360 to 370 transition. On Tue, Mar 12, 2024 at 6:09=E2=80=AFPM ron minnich wr= ote: > There used to be an urban legend about multiply overflow and the PDP 11. > > This would=E2=80=99ve been circa 1976. Someone from DEC told us that on a= multiply > overflow, the contents of the destination register would be =E2=80=9Ckind= of=E2=80=9D > random. I was never able to verify that claim. But that might explain thi= s > code. > > On Tue, Mar 12, 2024 at 16:05 Jonathan Gray wrote: > >> On Tue, Mar 12, 2024 at 08:55:02AM -0400, Russ Cox wrote: >> > Hi all (and TUHS), >> > >> > The Third Edition rand(III) page [1] ends with >> > >> > WARNING The author of this routine has been writing >> > random-number generators for many years and has >> > never been known to write one that worked. >> > >> > My understanding is that Ken wrote the rand implementation. >> > But I'm curious about the origin of this warning. >> > I had assumed that Ken wrote it as a combination warning+joke, >> > but Rob suggested that to him it didn't sound like Ken and >> > perhaps Doug or Dennis had written it. Does anyone remember? >> > >> > Separately, I am trying to find out what the very first >> > Unix rand implementation was. In the TUHS archives, >> > the incomplete V2 sources contain a reference to srand >> > in cmd/bas0.s [2], but there is no definition in the tree. >> > The V3 man pages list it, but as far as I can tell full >> > library sources do not appear in the TUHS archives >> > until the V6 snapshot. The V6 rand [3] is: >> > >> > rand: >> > mov r1,-(sp) >> > mov ranx,r1 >> > mpy $13077.,r1 >> > add $6925.,r1 >> > mov r1,r0 >> > mov r0,ranx >> > bic $100000,r0 >> > mov (sp)+,r1 >> > rts pc >> >> matches V5: >> https://www.tuhs.org/cgi-bin/utree.pl?file=3DV5/usr/source/s3/rand.s >> Distributions/Research/Dennis_v5/v5root.tar.gz >> >> >> > >> > Perhaps this is the original rand as well? It is hard to imagine >> > a much simpler one, other than perhaps removing the addition, >> > but doing so would create a sequence of only odd numbers. >> > >From the man page description it sounds like this has to be the >> > original generator, perhaps with different constants. >> > >> > Thanks! >> > >> > Best, >> > Russ >> > >> > [1] >> > >> https://github.com/dspinellis/unix-history-repo/blob/Research-V3/man/man= 3/rand.3 >> > [2] >> > >> https://github.com/dspinellis/unix-history-repo/blob/Research-V2/cmd/bas= 0.s >> > [3] >> > >> https://github.com/dspinellis/unix-history-repo/blob/Research-V6/usr/sou= rce/s3/rand.s >> > --0000000000000f333106138d7460 Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable
by the way, I realize that random number urban legend soun= ds ridiculous, in light=C2=A0of how hardware design is done today, but thos= e of you who did hardware design in those days (guilty!), and had access to= -11 schematics=C2=A0and boards, might=C2=A0wonder if it's not possible= . There was a habit, in those days,=C2=A0 for performance reasons, of subbi= ng transparent latches for flip-flops to gain a little time. An engineer I = knew at Amdahl said that was a pretty hot topic there. Certainly, the techn= ique of design for testability was not really in wide use in the -11 days. = Gordon Bell's book "Computer Design" is particularly=C2=A0ins= tructive.=C2=A0

E.g., how did you verify the floating po= int on your new machine? Put an older machine next to a new machine, do lot= s of computation, see if there is disagreement, you've found a bug in t= he new machine, right? Maybe. Sometimes,=C2=A0 you discover=C2=A0the older = machine had a bug the newer one did not ... happened=C2=A0more than once, i= ncluding on the 360 to 370 transition.

On Tue, Mar 12, 2024 at 6:09=E2= =80=AFPM ron minnich <rminnich@gma= il.com> wrote:
There used to be an urban legend about multiply ove= rflow and the PDP 11.

Th= is would=E2=80=99ve been circa 1976. Someone from DEC told us that on a mul= tiply overflow, the contents of the destination register would be =E2=80=9C= kind of=E2=80=9D random. I was never able to verify that claim. But that mi= ght explain this code.=C2=A0

On Tue, Mar 12, 2024 at 16:05 Jonathan Gra= y <jsg@jsg.id.au&= gt; wrote:
On Tu= e, Mar 12, 2024 at 08:55:02AM -0400, Russ Cox wrote:
> Hi all (and TUHS),
>
> The Third Edition rand(III) page [1] ends with
>
> WARNING=C2=A0 The author of this routine has been writing
>=C2=A0 =C2=A0 =C2=A0random-number generators for many years and has
>=C2=A0 =C2=A0 =C2=A0never been known to write one that worked.
>
> My understanding is that Ken wrote the rand implementation.
> But I'm curious about the origin of this warning.
> I had assumed that Ken wrote it as a combination warning+joke,
> but Rob suggested that to him it didn't sound like Ken and
> perhaps Doug or Dennis had written it. Does anyone remember?
>
> Separately, I am trying to find out what the very first
> Unix rand implementation was. In the TUHS archives,
> the incomplete V2 sources contain a reference to srand
> in cmd/bas0.s [2], but there is no definition in the tree.
> The V3 man pages list it, but as far as I can tell full
> library sources do not appear in the TUHS archives
> until the V6 snapshot. The V6 rand [3] is:
>
> rand:
>=C2=A0 =C2=A0 =C2=A0mov r1,-(sp)
>=C2=A0 =C2=A0 =C2=A0mov ranx,r1
>=C2=A0 =C2=A0 =C2=A0mpy $13077.,r1
>=C2=A0 =C2=A0 =C2=A0add $6925.,r1
>=C2=A0 =C2=A0 =C2=A0mov r1,r0
>=C2=A0 =C2=A0 =C2=A0mov r0,ranx
>=C2=A0 =C2=A0 =C2=A0bic $100000,r0
>=C2=A0 =C2=A0 =C2=A0mov (sp)+,r1
>=C2=A0 =C2=A0 =C2=A0rts pc

matches V5:
https://www.tuhs.org/cgi-bin/utree.pl?file=3DV5/usr/source/s3= /rand.s
Distributions/Research/Dennis_v5/v5root.tar.gz


>
> Perhaps this is the original rand as well? It is hard to imagine
> a much simpler one, other than perhaps removing the addition,
> but doing so would create a sequence of only odd numbers.
> >From the man page description it sounds like this has to be the > original generator, perhaps with different constants.
>
> Thanks!
>
> Best,
> Russ
>
> [1]
> https://github.= com/dspinellis/unix-history-repo/blob/Research-V3/man/man3/rand.3
> [2]
> https://github.com/d= spinellis/unix-history-repo/blob/Research-V2/cmd/bas0.s
> [3]
> https://gi= thub.com/dspinellis/unix-history-repo/blob/Research-V6/usr/source/s3/rand.s=
--0000000000000f333106138d7460--