Tausworthe Generator

When I started programming microcomputers I found a repeated need for random numbers. Dave Dodson suggested the Tausworthe feedback shift register which would fit nicely into a 16-bit word.

Dave passed along a paper that included some theory about primitive polynomials, some suggested coefficients, and a block diagram for one that I copied many times.

I believe I coded this generator first for the Imlac PDS-1 which had a 16-bit word.

I coded it for the Motorola 6800 using 16-bit arithmetic realized with 8-bit instructions.

* SUBROUTINE RANDOM * * TAUSWORTH GENERATOR USING PRIMITIVE TRINOMIAL * X**15 + X**4 + 1 WITH PERIOD 2**15 - 1. * RETURNS 0 < (B,A) < 2**15. * REF COMM. ACM 11,9 (SEPT 68) 641-644 RANDOM LDA A SEED+1 W=SEED LDA B SEED ASR B X=SHIFT(W,-4) ROR A ASR B ROR A ASR B ROR A ASR B ROR A EOR A SEED+1 Y=XOR(W,X) EOR B SEED STA A SEED+1 STA B SEED TAB Z=SHIFT(Y,15-4) ASL B ASL B ASL B AND B #$7F EOR B SEED SEED=XOR(Y,Z) STA B SEED RTS

I coded it for the Intel 8080 transcribing the 6800 version. I'm surprised that the documented polynomials don't agree and wonder if this is a typo. It's possible my Autocorrelation Test lead to an improvement.

* SUBROUTINE RANDOM * * TAUSWORTH GENERATOR USING PRIMITIVE TRINOMIAL * X**15 + X + 1 WITH PERIOD 2**15 - 1. * RETURNS 0 < (D,E) < 2**15. RANDOM LXI H,SEED MOV A,M STC CMC RAL MOV D,A INX H MOV A,M RAR XRA M MOV M,A MOV A,D DCX H XRA M JNC RAN1 XRI 60H RAN1 MOV M,A MOV E,A RET SPC 4