The atarisim code is :It can be compiled with :Quote:
cl65 -tatari -Catari-asm.cfg 1995prng.asm
and can be run with :Quote:
./atarisim 1995prng | xxd -r -p | rng_test stdin8
Code:
.export start
ICPTL = $0346
ICPTH = $0347
.zeropage
zp_start:
cnt: .res 6
zp_end:
.code
.proc init
init:
ldx #0
stx storex
stx storey
loop:
lda array1,x
sta array,x
inx
bne loop
rts
.endproc
.proc begin
ldx storex
inx
lda array,x
pha
clc
adc storey
sta storey
ldy storey
lda array,y
sta array,x
pla
sta array,y
clc
adc array,x
stx storex
tax
lda array,x
sta rndbyte
rts
.endproc
storex: .byte $00
storey: .byte $00
rndbyte: .byte $00
array: .byte 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0
array1: .byte 85,40,23,156,235,170,177,134,56,192,69,86,100,230,141,164,109,218,155,97,144,132,117,130,37,153,6,0,129,43,175,187,53,16,71,160,244,173,202,176,229,34,105,92,248,77,14,119,126,242,169,17,213,158,201,165,101,57,46,78,231,253,13,237,120,111,221,58,54,197,210,133,114,42,110,118,48,50,240,36,123,190,74,139,25,135,196,191,59,84,89,255,226,161,62,205,146,232,172,157,182,224,24,72,20,174,168,95,102,15,140,233,211,108,239,44,219,107,112,149,125,9,220,186,223,147,96,238,104,33,3,193,116,18,208,38,52,41,188,87,70,8,7,83,142,27,79,121,179,152,166,145,93,189,99,67,234,136,198,90,216,51,63,251,206,98,209,204,73,200,91,115,183,5,138,181,131,167,113,254,31,243,246,150,137,76,203,4,245,49,11,21,252,94,39,128,212,80,60,30,1,236,28,103,185,66,214,82,64,61,12,249,55,47,215,2,22,75,81,29,171,154,250,68,178,127,32,162,222,159,35,19,26,227,199,225,184,45,195,10,148,106,88,194,217,207,180,163,151,124,228,143,241,247,122,65
.proc print_hex_byte
pha
lsr
lsr
lsr
lsr
jsr print_hex
pla
print_hex:
and #$0F
tax
lda hextab,x
; Fall through
::putc:
ldx #0
jump: jmp $FFFF
hextab: .byte "0123456789ABCDEF"
.endproc
start:
; Init fast putchar
jsr init
lda ICPTL
clc
adc #1
sta print_hex_byte::jump+1
lda ICPTH
adc #0
sta print_hex_byte::jump+2
; Clear state
ldx #zp_end-zp_start-1
lda #0
zpclr:
sta zp_start, x
dex
bpl zpclr
; Generate and print numbers
loop:
jsr begin
lda rndbyte
jsr print_hex_byte
; lda #$9B
; jsr putc
inc cnt
bne loop
inc cnt+1
bne loop
inc cnt+2
bne loop
inc cnt+3
bne loop
inc cnt+4
bne loop
inc cnt+5
bne loop
rts