Google
 

Trailing-Edge - PDP-10 Archives - decuslib20-01 - decus/20-0013/random.mac
There are 5 other files named random.mac in the archive. Click here to see a list.
	TITLE	RANDOM REAL NUMBER UNIFORM BETWEEN TWO LIMITS
	SUBTTL	V.001  R.S.TOMLINSON 17 AUG 68
	ENTRY	RANDOM
	INTERN	RANDOM
	EXTERN	RAND

; CALL:	JSA 16,RANDOM
;	ARG 02,<LOWER LIMIT>
;	ARG 02,<UPPER LIMIT>
; RETURNS RESULT IN AC0
; 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 <lower limit>
;		    exp <upper limit>]
;	pushj	17,random
;	result in ac0

RANDOM:	pushj	17,rand	; GET 36 BIT RANDOM NUMBER IN AC0
	JFFO 0,.+1	; COUNT NUMBER OF LEADING ZEROES
	LSH 0,-9(1)	; PUT FIRST ONE IN BIT POSITION 9
	JUMPE 0,RAN1	; JUST ADD LOWER LIMIT IF ZERO
	MOVN 1,1	; NEGATE NUMBER OF LEADING ZEROES
	FSC 0,200(1)	; INSERT EXPONENT GIVING NUMBER FROM 0.0 TO 1.0
	MOVE 1,@1(16)	; GET UPPER LIMIT
	FSBR 1,@0(16)	; MINUS LOWER LIMIT
	FMPR 0,1	; TIMES RANDOM NUMBER BETWEEN 0.0 AND 1.0
RAN1:	FADR 0,@0(16)	; PLUS LOWER LIMIT
	popj	17,

	END