perm filename RANDOM.MAC[JCR,GUE] blob
sn#000939 filedate 1973-12-30 generic text, type T, neo UTF8
00100 TITLE RANDOM NUMBER GENERATOR FOR FORTRAN
00200 ; COPIED GORIN←SAUTER←KNUTH CHAPTER 3
00300 LEN==↑D64
00400 A=13
00500 B=14
00550 INTERN SEED1,SEED2,ISEED1,ISEED2
00600 ENTRY IRAN,RANDOM
00700 IRAN: 0
00800 MOVE A,ISEED1
00900 MOVEM A,SEED1
01000 MOVE A,ISEED2
01100 MOVEM A,SEED2
01200 MOVSI B,-LEN
01300 IRAN1: MOVE A,SEED1
01400 IMUL A,[↑D3141592653]
01500 JFCL ;IGNORE OVERFLOW
01600 ADD A,[↑D2718281829]
01700 JFCL
01800 MOVEM A,TBLR(B)
01900 MOVEM A,SEED1
02000 AOBJN B,IRAN1
02100 JRA 16,0(16)
02200 RANDOM: 0
02300 MOVE A,SEED1
02400 IMUL A,[↑D3141592653]
02500 JFCL
02600 ADD A,[↑D2718281829]
02700 JFCL
02800 MOVEM A,SEED1
02900 HLRZS A
03000 IDIVI A,LEN
03100 MOVE A,SEED2
03200 IMUL A,[↑D2718281829]
03300 JFCL
03400 ADD A,[↑D3141592653]
03500 JFCL
03600 MOVEM A,SEED2
03700 EXCH A,TBLR(B)
03800 HLRZ B,A
03900 FSC B,211
04000 HRLI A,0
04100 FSC A,167
04200 FAD A,B
04300 MOVEM A,0
04400 JRA 16,0(16)
04500 TBLR: BLOCK LEN
04600 SEED1: 0
04700 SEED2: 0
04710 ISEED1: ↑D5772156649
04720 ISEED2: ↑D1781072418
04800 END