
     1  !%endoflist
     2  !These Pseudo-random numbers were written by P. Reid.  It is not known if
     3  !they are genuinely random or not.
     4  
     5  !**  %routine   INITALISE RANDOM    sets up the random integer SEED          **!
     6  !**  %real %fn  RANDOM REAL (LO,HI) returns uniformly distributed reals      **!
     7  !**                                 between LO and HI inclusive              **!
     8  !**  %short %fn RANDOM INT (LO,HI)  returns uniformly distributed short      **!
     9  !**                                 integers between LO and HI inclusive     **!
    10  
    11  %own %integer Seed=0  {initialised to 0: JHB mod 16/12/86}
    12  
    13  
503 @ 4405:         LINE   11 "regression-compile-tmp/random.imp"
504 @ 4442:         PUSHI  #0x00000000
505 @ 4447:         DEF    SEED p1=V_0081 a/tf=11 b/format=1 c/ostate=21  type=1 (integer) form=1 (simple) special=0 (<special:0>) linkage=1 (own) spec=0 indirect=0 unass=1
506 @ 4463:         INIT   1

    14  %routine Initialise Random
    15  !
    16  ! Set up SEED
    17  !
507 @ 4466:         LINE   14 "regression-compile-tmp/random.imp"
508 @ 4503:         DEF    INITIALISERANDOM (_INITIALISERANDOM) p1=V_0082 a/tf=7 b/format=0 c/ostate=0  type=0 (<type:0>) form=7 (routine) special=0 (<special:0>) linkage=0 (auto) spec=0 indirect=0 unass=0
509 @ 4531:            START  ( FORMAL PARAMETERS  {lev=1 --> 2, nested=0 --> 1}
510 @ 4532:            FINISH ) {lev=1}

    18     Seed = CpuTime
511 @ 4533:            LINE   18 "regression-compile-tmp/random.imp"
512 @ 4570:            PUSH   SEED
513 @ 4573:            PUSH   CPUTIME
514 @ 4576:            CALL  
515 @ 4577:            ASSVAL

    19  %end
    20  
    21  
516 @ 4578:            LINE   19 "regression-compile-tmp/random.imp"
517 @ 4615:         END    _INITIALISERANDOM {lev=1 --> 0}

    22  %realfn Random Real(%real Lo, Hi)
    23  !
    24  ! Returns a random real between LO and HI inclusive
    25  !
518 @ 4616:         LINE   22 "regression-compile-tmp/random.imp"
519 @ 4653:         DEF    RANDOMREAL (_RANDOMREAL) p1=V_0083 a/tf=28 b/format=1 c/ostate=10  type=2 (real) form=8 (function) special=0 (<special:0>) linkage=0 (auto) spec=0 indirect=1 unass=0
520 @ 4675:            START  ( FORMAL PARAMETERS  {lev=1 --> 2, nested=0 --> 1}
521 @ 4676:               DEF    LO p1=V_0084 a/tf=21 b/format=1 c/ostate=0  type=2 (real) form=1 (simple) special=0 (<special:0>) linkage=0 (auto) spec=0 indirect=0 unass=0
522 @ 4690:               DEF    HI p1=V_0085 a/tf=21 b/format=1 c/ostate=0  type=2 (real) form=1 (simple) special=0 (<special:0>) linkage=0 (auto) spec=0 indirect=0 unass=0
523 @ 4704:            FINISH ) {lev=1}

    26     Seed = (23501*Seed + 6923) & 32767
524 @ 4705:            LINE   26 "regression-compile-tmp/random.imp"
525 @ 4742:            PUSH   SEED
526 @ 4745:            PUSHI  #0x00005bcd
527 @ 4750:            PUSH   SEED
528 @ 4753:            MUL   
529 @ 4754:            PUSHI  #0x00001b0b
530 @ 4759:            ADD   
531 @ 4760:            PUSHI  #0x00007fff
532 @ 4765:            AND   
533 @ 4766:            ASSVAL

    27     %result = Lo + (Seed * (Hi - Lo))/32767
534 @ 4767:            LINE   27 "regression-compile-tmp/random.imp"
535 @ 4804:            PUSH   LO
536 @ 4807:            PUSH   SEED
537 @ 4810:            PUSH   HI
538 @ 4813:            PUSH   LO
539 @ 4816:            SUB   
540 @ 4817:            MUL   
541 @ 4818:            PUSHI  #0x00007fff
542 @ 4823:            DIVIDE
543 @ 4824:            ADD   
544 @ 4825:            RESULT

    28  %end
    29  
    30  
545 @ 4826:            LINE   28 "regression-compile-tmp/random.imp"
546 @ 4863:         END    _RANDOMREAL {lev=1 --> 0}

    31  %shortfn Random Int (%short Lo, Hi)
    32  !
    33  ! Returns a random shortinteger between LO and HI inclusive
    34  !
547 @ 4864:         LINE   31 "regression-compile-tmp/random.imp"
548 @ 4901:         DEF    RANDOMINT (_RANDOMINT) p1=V_0084 a/tf=18 b/format=3 c/ostate=10  type=1 (integer) form=8 (function) special=2 (short-integer) linkage=0 (auto) spec=0 indirect=1 unass=0
549 @ 4922:            START  ( FORMAL PARAMETERS  {lev=1 --> 2, nested=0 --> 1}
550 @ 4923:               DEF    LO p1=V_0085 a/tf=11 b/format=3 c/ostate=0  type=1 (integer) form=1 (simple) special=2 (short-integer) linkage=0 (auto) spec=0 indirect=0 unass=0
551 @ 4937:               DEF    HI p1=V_0086 a/tf=11 b/format=3 c/ostate=0  type=1 (integer) form=1 (simple) special=2 (short-integer) linkage=0 (auto) spec=0 indirect=0 unass=0
552 @ 4951:            FINISH ) {lev=1}

    35     Seed = (23501*Seed + 6923) & 32767
553 @ 4952:            LINE   35 "regression-compile-tmp/random.imp"
554 @ 4989:            PUSH   SEED
555 @ 4992:            PUSHI  #0x00005bcd
556 @ 4997:            PUSH   SEED
557 @ 5000:            MUL   
558 @ 5001:            PUSHI  #0x00001b0b
559 @ 5006:            ADD   
560 @ 5007:            PUSHI  #0x00007fff
561 @ 5012:            AND   
562 @ 5013:            ASSVAL

    36     %result = Int(Lo + (Seed * (Hi - Lo))/32767)
563 @ 5014:            LINE   36 "regression-compile-tmp/random.imp"
564 @ 5051:            PUSH   INT
565 @ 5054:            PUSH   LO
566 @ 5057:            PUSH   SEED
567 @ 5060:            PUSH   HI
568 @ 5063:            PUSH   LO
569 @ 5066:            SUB   
570 @ 5067:            MUL   
571 @ 5068:            PUSHI  #0x00007fff
572 @ 5073:            DIVIDE
573 @ 5074:            ADD   
574 @ 5075:            ASSPAR
575 @ 5076:            CALL  
576 @ 5077:            RESULT

    37  %end
    38  
    39  !%list
577 @ 5078:            LINE   37 "regression-compile-tmp/random.imp"
578 @ 5115:         END    _RANDOMINT {lev=1 --> 0}

    40  %endoffile
579 @ 5116:         LINE   40 "regression-compile-tmp/random.imp"
580 @ 5153:         END     {lev=0 --> -1}
581 @ 5154: 

