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 41574242A8 for ; Wed, 13 Mar 2024 02:10:11 +0100 (CET) Received: from minnie.tuhs.org (localhost [IPv6:::1]) by minnie.tuhs.org (Postfix) with ESMTP id AC0E842814; Wed, 13 Mar 2024 11:10:04 +1000 (AEST) Received: from mail-lj1-x233.google.com (mail-lj1-x233.google.com [IPv6:2a00:1450:4864:20::233]) by minnie.tuhs.org (Postfix) with ESMTPS id 4C67F42810 for ; Wed, 13 Mar 2024 11:09:55 +1000 (AEST) Received: by mail-lj1-x233.google.com with SMTP id 38308e7fff4ca-2d40fe2181dso58943801fa.1 for ; Tue, 12 Mar 2024 18:09:55 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1710292193; x=1710896993; 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=ZzcOn4yXOMrSNLDEw6rc6MOYRcXF6xENIAItHAf2NmM=; b=asjV1W32t1Mko7yE9hrdNEqgKhN+5YmOuTHBDiA9pTdWhXkO5wFTolGEEd1VcO4zWl WV5DnJF3wuJh/5At2M7g7I7Eq++YfRUi6pWZKRYT4+QtERAWbAbeTcu4fmBbveh7+gAr ex7Yu3dayTrqpg7tEnN6kEKjR00UgrfRKw+jUZyztnTjJG1NJIq9IDe92XaBHuwpuze2 v/Xi5W8v4GCVy67HttfW9kESiIEw9irB9gdrUVFrpaLjf7Gka6qTRXmrtsIqSsHhS1DZ UBd58bONEFURZ40NTio0woN4+SBAsopg/3e79hIkLjgb0a6VhxED3pVHf6FWoFE0vnnL 9OVg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1710292193; x=1710896993; 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=ZzcOn4yXOMrSNLDEw6rc6MOYRcXF6xENIAItHAf2NmM=; b=NlIyblklVxutifJ08P6mHea2+jbeIFUnbxWVPkOQax8IvTokkweRIFCq2rikS50Yrx kDVc4Qxp71ZJ1EkAPHAjxtyNZnrNmkRnStp9KDA2YMShumFLxiOKHwz3bqCRjLWdgr/5 hCrMnG8t/52mZ7AhDAXTkuJnP08FY9IV6wTqipDqnZXqo92zVpIj1PmLn6vl8yqsUwip EjXhlbqu3klCqv7BBoGAeX2XSadvx0mUKtouiPXNKfVbNf4F/RHLJeXb+8RbM0OKXGwE Pu2r4H2Wdxs7UYsx2PVSbZbq9msOBwTtq1C+quTgN/3IrrbdEySwoJ520WtQ+T+HaRf8 kV0A== X-Forwarded-Encrypted: i=1; AJvYcCWN+sKnFV8atT4WKyZ25XE2hgwuR66alHtiYu9UcDQqg6zDk7+C8eMc7VU90dWBLr/GtkvWStPsegQWSGIJ X-Gm-Message-State: AOJu0YwWF7FnU5xY89EJMFjDaYgRLUSarUrS/SCn7pW7V6voeokWFyTb cAC/d09G6bC7XnokTYlJboZZVb7Ak1UQ/yC9vw5mc5I3pJOhKVJ1yidnNLAEzFRWC7jOq6OuQ/K dokfXg6KG6aLvOH2FobVHD6J5Pq4GWmFa X-Google-Smtp-Source: AGHT+IH/wz2jGwoi01VbCYvrZ8s3HT9kVU8fLEgykY2xZWomKBhX0aXfIvLDuQ5bPwN4ftYqAscFIEOi97rQuFgJj4o= X-Received: by 2002:a2e:9d03:0:b0:2d3:4b07:9140 with SMTP id t3-20020a2e9d03000000b002d34b079140mr6472354lji.47.1710292192923; Tue, 12 Mar 2024 18:09:52 -0700 (PDT) MIME-Version: 1.0 References: In-Reply-To: From: ron minnich Date: Tue, 12 Mar 2024 18:09:41 -0700 Message-ID: To: Jonathan Gray Content-Type: multipart/alternative; boundary="0000000000009f19ba0613806ee5" Message-ID-Hash: OKONEIWZ4FFFQN5IGTJ2S7QWGDW3ZE6J X-Message-ID-Hash: OKONEIWZ4FFFQN5IGTJ2S7QWGDW3ZE6J 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: --0000000000009f19ba0613806ee5 Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable 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 m= ultiply overflow, the contents of the destination register would be =E2=80=9Ckind o= f=E2=80=9D random. I was never able to verify that claim. But that might explain this 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/man3= /rand.3 > > [2] > > > https://github.com/dspinellis/unix-history-repo/blob/Research-V2/cmd/bas0= .s > > [3] > > > https://github.com/dspinellis/unix-history-repo/blob/Research-V6/usr/sour= ce/s3/rand.s > --0000000000009f19ba0613806ee5 Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable
There used to be an urban legend about multiply overflow = and the PDP 11.

This wou= ld=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 o= f=E2=80=9D random. I was never able to verify that claim. But that might ex= plain this code.=C2=A0

On Tue, Mar 12, 2024 at 16:05 Jonathan Gray <= jsg@jsg.id.au> wrote:
On Tue, Mar 12, 2024 at 08:55:02AM -0400, Russ C= ox 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=
--0000000000009f19ba0613806ee5--