I also give you my LCG 64 which dates from 1990,
It generates a random sequence of (2^64)-1 bytes. It's a 64-bit Linear Congruential Generator. Each call to the routine generates an 8-bit byte. There is no short cycle for all seed values.
First a 8-bytes seed must be put at
seed:The seed can vary from 0 to $FFFFFFFFFFFFFFFF.
Each call to the
begin: function returns a pseudorandom byte in
rndbyte:First
init: must be call one time.
After
begin: must be call for each generated byte (
rndbyte:) that can be use directly.
The test vector is :
For a seed = $FFFFFFFFFFFFFFFF
the first 50 bytes are :Quote:
AE 0B D2 B3 F2 5B 8B 4B AD 23 58 5C 68 BB 62 AD 96 07 4F 7C E3 58 54 17 6F 3B EF 9A ED A5 19 A2 C9 6B 47 71 0F 3A 2A 23 38 F5 4F 34 23 9B BF 21 4C 03
Code:
//----------------------------------------------------
// Pukall LCG 64
// 1990
//----------------------------------------------------
//----------------------------------------------------
// Main Program
//----------------------------------------------------
init:
lda #6
sta pos
rts
begin:
ldx pos
cpx #6
bne rnd
jsr start
ldx #0
clc
php
loop0:
lda seed,x
plp
adc dda,x
php
sta seed,x
inx
cpx #8
bne loop0
plp
rnd:
ldx pos
lda seed,x
sta rndbyte
dex
cpx #2
bne end2
end:
lda #6
sta pos
rts
end2:
stx pos
rts
start:
lda #0
ldx #15
loop:
sta result,x
dex
cpx #7
bne loop
ldy #64
part1:
sty storey
ldx #7
lsr seed,x
php
dex
loop1:
plp
ror seed,x
php
dex
cpx #0
bne loop1
plp
ror seed
bcc part2
ldx #7
ldy #0
clc
php
loop2:
inx
lda result,x
plp
adc two,y
php
sta result,x
iny
cpy #8
bne loop2
plp
part2:
ror
php
ldx #15
sta result,x
loop3:
dex
plp
ror result,x
php
cpx #0
bne loop3
plp
ldy storey
dey
bne jump
ldx #0
loop4:
lda result,x
sta seed,x
inx
cpx #8
bne loop4
rts
jump:
jmp part1
seed: .byte $FF,$FF,$FF,$FF,$FF,$FF,$FF,$FF
rndbyte: .byte $FF
result: .byte $FF,$FF,$FF,$FF,$FF,$FF,$FF,$FF,$FF,$FF,$FF,$FF,$FF,$FF,$FF,$FF
two: .byte $2D,$7F,$95,$4C,$2D,$F4,$51,$58
dda: .byte $01,$00,$00,$00,$00,$00,$00,$00
storey: .byte $FF
pos: .byte $FF