Trailing-Edge
-
PDP-10 Archives
-
decuslib10-01
-
43,50053/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
RANDOM: 0
JSA 16,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
JRA 16,2(16)
END