         Edinburgh IMP77 Compiler - Version 8.4
    1 !%endoflist
		.Ltext0:
				.comm	SEED,4,4
		INITIALISERANDOM:
		.LFB189:
    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
   14 %routine Initialise Random
				pushl	%ebp
				movl	%esp, %ebp
				pushl	%ebx
				subl	$4, %esp
				call	__x86.get_pc_thunk.bx
				addl	$_GLOBAL_OFFSET_TABLE_, %ebx
		.LBB10:
		.LBB11:
				call	_imp_cputime@PLT
		.LBE11:
		.LBE10:
   15 !
   16 ! Set up SEED
   17 !
   18    Seed = CpuTime
				movl	%eax, SEED@GOTOFF(%ebx)
   19 %end
				nop
				addl	$4, %esp
				popl	%ebx
				popl	%ebp
				ret
		.LFE189:
		RANDOMREAL:
		.LFB190:
   20
   21
   22 %realfn Random Real(%real Lo, Hi)
				pushl	%ebp
				movl	%esp, %ebp
				subl	$4, %esp
				call	__x86.get_pc_thunk.ax
				addl	$_GLOBAL_OFFSET_TABLE_, %eax
   23 !
   24 ! Returns a random real between LO and HI inclusive
   25 !
   26    Seed = (23501*Seed + 6923) & 32767
				movl	SEED@GOTOFF(%eax), %edx
				imull	$23501, %edx, %edx
				addl	$6923, %edx
				andl	$32767, %edx
				movl	%edx, SEED@GOTOFF(%eax)
   27    %result = Lo + (Seed * (Hi - Lo))/32767
				movl	SEED@GOTOFF(%eax), %edx
				movl	%edx, -4(%ebp)
				fildl	-4(%ebp)
				flds	12(%ebp)
				fsubs	8(%ebp)
				fmulp	%st, %st(1)
				flds	.LC0@GOTOFF(%eax)
				fdivrp	%st, %st(1)
				fadds	8(%ebp)
   28 %end
				leave
				ret
		.LFE190:
		RANDOMINT:
		.LFB191:
   29
   30
   31 %shortfn Random Int (%short Lo, Hi)
				pushl	%ebp
				movl	%esp, %ebp
				pushl	%ebx
				subl	$36, %esp
				call	__x86.get_pc_thunk.cx
				addl	$_GLOBAL_OFFSET_TABLE_, %ecx
				movl	8(%ebp), %edx
				movl	12(%ebp), %eax
				movw	%dx, -28(%ebp)
				movw	%ax, -32(%ebp)
   32 !
   33 ! Returns a random shortinteger between LO and HI inclusive
   34 !
   35    Seed = (23501*Seed + 6923) & 32767
				movl	SEED@GOTOFF(%ecx), %eax
				imull	$23501, %eax, %eax
				addl	$6923, %eax
				andl	$32767, %eax
				movl	%eax, SEED@GOTOFF(%ecx)
   36    %result = Int(Lo + (Seed * (Hi - Lo))/32767)
				filds	-28(%ebp)
				movswl	-32(%ebp), %edx
				movswl	-28(%ebp), %eax
				subl	%eax, %edx
				movl	SEED@GOTOFF(%ecx), %eax
				movl	%edx, %ebx
				imull	%eax, %ebx
				movl	$-2147418109, %edx
				movl	%ebx, %eax
				imull	%edx
				leal	(%edx,%ebx), %eax
				sarl	$14, %eax
				movl	%eax, %edx
				movl	%ebx, %eax
				sarl	$31, %eax
				subl	%eax, %edx
				movl	%edx, %eax
				movl	%eax, -40(%ebp)
				fildl	-40(%ebp)
				faddp	%st, %st(1)
				fstpl	-24(%ebp)
		.LBB12:
		.LBB13:
				fldl	-24(%ebp)
				fldl	.LC1@GOTOFF(%ecx)
				faddp	%st, %st(1)
				fstpl	-16(%ebp)
		.LBB14:
		.LBB15:
				subl	$8, %esp
				pushl	-12(%ebp)
				pushl	-16(%ebp)
				movl	%ecx, %ebx
				call	floor@PLT
				addl	$16, %esp
				fnstcw	-30(%ebp)
				movzwl	-30(%ebp), %eax
				orb	$12, %ah
				movw	%ax, -26(%ebp)
				fldcw	-26(%ebp)
				fistpl	-36(%ebp)
				fldcw	-30(%ebp)
				movl	-36(%ebp), %eax
		.LBE15:
		.LBE14:
		.LBE13:
		.LBE12:
   37 %end
				movl	-4(%ebp), %ebx
				leave
				ret
		.LFE191:
				.section	.rodata
				.align 4
		.LC0:
				.long	1191181824
				.align 8
		.LC1:
				.long	0
				.long	1071644672
				.section	.text.__x86.get_pc_thunk.ax,"axG",@progbits,__x86.get_pc_thunk.ax,comdat
				.globl	__x86.get_pc_thunk.ax
				.hidden	__x86.get_pc_thunk.ax
		__x86.get_pc_thunk.ax:
		.LFB192:
				movl	(%esp), %eax
				ret
		.LFE192:
				.section	.text.__x86.get_pc_thunk.cx,"axG",@progbits,__x86.get_pc_thunk.cx,comdat
				.globl	__x86.get_pc_thunk.cx
				.hidden	__x86.get_pc_thunk.cx
		__x86.get_pc_thunk.cx:
		.LFB193:
				movl	(%esp), %ecx
				ret
		.LFE193:
				.section	.text.__x86.get_pc_thunk.bx,"axG",@progbits,__x86.get_pc_thunk.bx,comdat
				.globl	__x86.get_pc_thunk.bx
				.hidden	__x86.get_pc_thunk.bx
		__x86.get_pc_thunk.bx:
		.LFB194:
				movl	(%esp), %ebx
				ret
		.LFE194:
		.Letext0:
   38
   39 !%list
   40 %endoffile
   13 Statements compiled
