Google
 

Trailing-Edge - PDP-10 Archives - decuslib20-01 - decus/20-0013/setran.mac
There are 2 other files named setran.mac in the archive. Click here to see a list.
	TITLE	SETRAN SET RANDOM NUMBER SEED
	SUBTTL	V.001  R.S.TOMLINSON 19 AUG 68
	ENTRY	SETRAN
	INTERN	SETRAN
	EXTERN	RAND,RND,RND1

; SET RANDOM NUMBER SEED
; THIS ROUTINE SETS THE ORIGIN OF THE RANDOM NUMBER SEQUENCE AND
; IS USED IN CONJUNCTION WITH GETRAN TO ALLOW A "RANDOM" NUMBER
; SEQUENCE TO BE REPEATED.
; THE FIRST RANDOM NUMBER GENERATED AFTER A CALL TO GETRAN WILL BE
; THE SAME AS THE FIRST RANDOM NUMBER GENERATED AFTER A CALL TO SETRAN
; WITH THE SAME ARGUMENTS.  THUS IN THE FOLLOWING PROGRAM:
;	CALL GETRAN(I,J)
;	X=RANDOM(1.0,2.0)
;	CALL SETRAN(I,J)
;	Y=RANDOM(1.0,2.0)
; X AND Y WILL BE SET TO THE SAME NUMBER.

; CALL:	JSA 16,SETRAN
;	ARG 00,<WHERE TO GET HIGH PART>
;	ARG 00,<WHERE TO GET LOW PART>
;	. . .
; Modified to PUSHJ/POPJ calling convention 11 Oct 1980
; by Paul T. Robinson, Wesleyan Univ. for DECUS conversion to DEC-20
; call:	movei	16,[exp <where to get high part>
;		    exp <where to get low part>]
;	pushj	17,setran

SETRAN:	MOVE 0,@0(16)	; GET HIGH ORDER PART
	MOVEM 0,RND	; PUT IT IN RANDOM # SEED
	MOVE 0,@1(16)	; GET LOW ORDER PART
	IORI 0,1	; FORCE NUMBER TO BE ODD
	MOVEM 0,RND1	; PUT IT IN RANDOM # SEED
	popj	17,

	END