Details | Last modification | View Log | RSS feed
Rev | Author | Line No. | Line |
---|---|---|---|
8725 | rgimad | 1 | ; note: proc that defines without stdcall, call using "call" |
2 | ; note: by stdcall convention callee is responsible for cleaning up the stack, |
||
3 | ; arguments are pushed onto the stack in right-to-left order |
||
4 | align 4 |
||
5 | proc _memset stdcall, dest:dword, val:byte, cnt:dword ; doesnt clobber any registers |
||
6 | ;DEBUGF DBG_INFO, "memset(%x, %u, %u)\n", [dest], [val], [cnt] |
||
7 | push eax ecx edi |
||
8 | mov edi, dword [dest] |
||
9 | mov al, byte [val] |
||
10 | mov ecx, dword [cnt] |
||
11 | rep stosb |
||
12 | pop edi ecx eax |
||
13 | ret |
||
14 | endp |
||
15 | |||
16 | align 4 |
||
17 | proc _srand stdcall, seed:dword |
||
18 | push eax |
||
19 | ;DEBUGF DBG_INFO, "_srand: next_rand = %u\n", [next_rand] |
||
20 | mov eax, dword [seed] |
||
21 | mov dword [next_rand], eax |
||
22 | pop eax |
||
23 | ret |
||
24 | endp |
||
25 | |||
26 | align 4 |
||
27 | proc _rand stdcall |
||
28 | push ebx edx |
||
29 | ;DEBUGF DBG_INFO, "_rand: next_rand = %u\n", [next_rand] |
||
30 | mov eax, dword [next_rand] |
||
31 | mov ebx, 214013 |
||
32 | mul ebx |
||
33 | add eax, 2531011 |
||
34 | mov dword [next_rand], eax |
||
35 | shr eax, 16 |
||
36 | and eax, 0x7fff |
||
37 | pop edx ebx |
||
38 | ret |
||
39 | endp |
||
40 | |||
41 | align 4 |
||
42 | proc _getseed stdcall |
||
43 | push edx |
||
44 | rdtsc |
||
45 | xor eax, edx |
||
46 | pop edx |
||
47 | ret |
||
48 | endp |
||
49 | |||
50 | ; calculate (num % num_mod) / num_div |
||
51 | align 4 |
||
52 | proc mod_div stdcall, num: dword, num_mod: dword, num_div:dword ; TODO check |
||
53 | ; in: num - number |
||
54 | ; num_mod - first divisor |
||
55 | ; num_div - second divisor |
||
56 | ; out: eax - the result |
||
57 | ; destroys: mb flags |
||
58 | push ecx edx |
||
59 | xor edx, edx |
||
60 | mov eax, dword [num] |
||
61 | mov ecx, dword [num_mod] |
||
62 | div ecx |
||
63 | |||
64 | mov eax, edx |
||
65 | xor edx, edx |
||
66 | mov ecx, dword [num_div] |
||
67 | div ecx |
||
68 | pop edx ecx |
||
69 | ret |
||
70 | endp |
||
71 | |||
72 | ; update key map; TODO impl; |
||
73 | align 4 |
||
74 | proc keyboard_update stdcall, _code: dword |
||
75 | push eax ebx ecx edx |
||
76 | mov eax, dword [_code] |
||
77 | |||
78 | mov edx, eax |
||
79 | and edx, 0xF000 |
||
80 | |||
81 | mov ebx, eax |
||
82 | and ebx, 0x0F00 |
||
83 | shr ebx, 8 |
||
84 | |||
85 | xor ecx, ecx |
||
86 | cmp edx, 0x6000 |
||
87 | jne .if1_end |
||
88 | mov ecx, 0x9 |
||
89 | .if1_end: |
||
90 | add ebx, ecx |
||
91 | ; DEBUGF DBG_INFO, "keynum %x\n", ebx |
||
92 | cmp ebx, KEY_SIZE |
||
93 | jae .ret |
||
94 | DEBUGF DBG_INFO, "keynum %x\n", ebx |
||
95 | mov byte [key + ebx], 1 |
||
96 | |||
97 | .ret: |
||
98 | pop edx ecx ebx eax |
||
99 | ret |
||
100 | endp |
||
101 | |||
102 | ; ; get seconds count |
||
103 | ; align 4 |
||
104 | ; proc get_clock stdcall |
||
105 | ; ; out: eax - time from system start in 10^-2 secs |
||
106 | ; push ebx |
||
107 | ; mov eax, 26 |
||
108 | ; mov ebx, 9 |
||
109 | ; int 0x40 |
||
110 | ; pop ebx |
||
111 | ; ret |
||
112 | ; endp |