Subversion Repositories Kolibri OS

Rev

Go to most recent revision | Details | Last modification | View Log | RSS feed

Rev Author Line No. Line
31 halyavin 1
; C4
2
; Copyright (c) 2002 Thomas Mathys
3
; killer@vantage.ch
4
;
5
; This file is part of C4.
6
;
7
; C4 is free software; you can redistribute it and/or modify
8
; it under the terms of the GNU General Public License as published by
9
; the Free Software Foundation; either version 2 of the License, or
10
; (at your option) any later version.
11
;
12
; C4 is distributed in the hope that it will be useful,
13
; but WITHOUT ANY WARRANTY; without even the implied warranty of
14
; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
15
; GNU General Public License for more details.
16
;
17
; You should have received a copy of the GNU General Public License
18
; along with C4; if not, write to the Free Software
19
; Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
20
 
21
%ifndef _RNG_INC
22
%define _RNG_INC
23
 
24
	section .data
25
 
26
 
27
; random seed
28
seed		dd	0
29
 
30
 
31
 
32
	section .text
33
 
34
 
35
;**********************************************************
36
; randomize
37
; initialize random number generator.
38
; initialization is done using the get system clock syscall
39
;
40
; input		:	nothing
41
; output	:	nothing
42
; destroys	:	nothing
43
;**********************************************************
44
randomize:
45
	push eax
46
	mov eax,MOS_SC_GETSYSCLOCK
47
	int 0x40
48
	mov [seed],eax
49
	pop eax
50
	ret
51
 
52
 
53
 
54
;**********************************************************
55
; rand
56
; return an unsigned 32 bit "random" number
57
;
58
; input		:	nothing
59
; output	:	eax = unsigned 32 bit random number
60
; destroys	:	nothing
61
;**********************************************************
62
rand:
63
	pushfd
64
	push edx
65
	mov eax,32719
66
	mul dword [seed]
67
	add eax,123
68
	xchg al,ah
69
	rol eax,16
70
	xchg al,ah
71
	mov [seed],eax
72
	pop edx
73
	popfd
74
	ret
75
 
76
%endif