source: trunk/src/kernel32/asmutil.asm

Last change on this file was 21916, checked in by dmik, 14 years ago

Merge branch gcc-kmk to trunk.

File size: 4.6 KB
RevLine 
[9946]1; $Id: asmutil.asm,v 1.3 2003-03-27 14:13:10 sandervl Exp $
[8401]2
3;/*
4; * Project Odin Software License can be found in LICENSE.TXT
5; * Win32 Exception handling + misc functions for OS/2
6; *
7; * Copyright 1998 Sander van Leeuwen
8; *
9; */
10.386p
11 NAME except
12
[21916]13DATA32 segment dword use32 public 'DATA'
14DATA32 ends
15CONST32_RO segment dword use32 public 'CONST'
16CONST32_RO ends
17BSS32 segment dword use32 public 'BSS'
18BSS32 ends
19DGROUP group BSS32, DATA32
20 assume cs:FLAT, ds:FLAT, ss:FLAT, es:FLAT
[8401]21
[9946]22extrn Dos32TIB:abs
23
[8401]24CODE32 SEGMENT DWORD PUBLIC USE32 'CODE'
25
[21916]26 PUBLIC _getEAX
27_getEAX proc near
[8401]28 ret
[21916]29_getEAX endp
[8401]30
[21916]31 PUBLIC _getEDX
32_getEDX proc near
33 mov EAX, EDX
34 ret
35_getEDX endp
[8401]36
[21916]37 PUBLIC _getEBX
38_getEBX proc near
[8401]39 mov eax, ebx
40 ret
[21916]41_getEBX endp
[8401]42
43 PUBLIC GetFS
44GetFS proc near
45 mov eax, fs
46 ret
47GetFS endp
48
49 PUBLIC SetFS
50SetFS proc near
51 mov eax, [esp+4]
52 mov fs, eax
53 ret
[21916]54SetFS endp
[8401]55
[21916]56 PUBLIC _getCS
57_getCS proc near
[8401]58 mov eax, cs
59 ret
[21916]60_getCS endp
[8401]61
[21916]62 PUBLIC _getDS
63_getDS proc near
[8401]64 mov eax, ds
65 ret
[21916]66_getDS endp
[8401]67
68 PUBLIC SetReturnFS
69SetReturnFS proc near
70 push fs
71 mov eax, [esp+8]
72 mov fs, eax
73 pop eax
74 ret
75SetReturnFS endp
76
[21916]77 PUBLIC _getSS
78_getSS proc near
[8401]79 mov ax, ss
80 ret
[21916]81_getSS endp
[8401]82
[21916]83 PUBLIC _getES
84_getES proc near
[8401]85 mov eax, es
86 ret
[21916]87_getES endp
[8401]88
[21916]89 PUBLIC _getGS
90_getGS proc near
[8401]91 mov eax, gs
92 ret
[21916]93_getGS endp
[8401]94
[21916]95 PUBLIC _getESP
96_getESP proc near
[8401]97 mov eax, esp
98 ret
[21916]99_getESP endp
[8401]100
101 PUBLIC RestoreOS2FS
102RestoreOS2FS proc near
[9946]103 push Dos32TIB
[8401]104 mov ax, fs
105 pop fs
106 ret
107RestoreOS2FS endp
108
109 PUBLIC _Mul32x32to64
110_Mul32x32to64 proc near
111 push ebp
112 mov ebp, esp
113 push eax
114 push edx
115 push edi
116
117 mov edi, [ebp+8] ;64 bits result
118 mov eax, [ebp+12] ;op1
119 mov edx, [ebp+16] ;op2
120 mul edx
121 mov [edi], eax
122 mov [edi+4], edx
123
124 pop edi
125 pop edx
126 pop eax
127 pop ebp
128 ret
129_Mul32x32to64 endp
130
[21916]131 align 4h
[8401]132
[21916]133 public _Sub64
134_Sub64 proc
[8401]135
136; 34 c = a - b;
137 push ebp
138 mov ebp, esp
139 push esi
140 push edi
141 push edx
142
143 mov edi, [ebp+10h] ;&c
144 mov esi, [ebp+08h] ;&a
[21916]145 mov eax,[esi] ;a.low
146 mov edx,[esi+04h] ;a.high
[8401]147 mov esi, [ebp+0ch] ;&b
[21916]148 sub eax,[esi] ;b.low
149 sbb edx,[esi+04h] ;b.high
[8401]150
151 mov [edi], eax ;c.low
152 mov [edi+4], edx ;c.high
153
154 pop edx
155 pop edi
156 pop esi
157 leave
[21916]158 ret
159_Sub64 endp
[8401]160
[21916]161 align 4h
[8401]162
[21916]163 public _Add64
164_Add64 proc
[8401]165
166; 25 c = a + b;
167 push ebp
168 mov ebp, esp
169 push esi
170 push edi
171 push edx
172
173 mov edi, [ebp+10h] ;&c
174 mov esi, [ebp+08h] ;&a
[21916]175 mov eax,[esi] ;a.low
176 mov edx,[esi+04h] ;a.high
[8401]177 mov esi, [ebp+0ch] ;&b
[21916]178 add eax,[esi] ;b.low
179 adc edx,[esi+04h] ;b.high
[8401]180
181 mov [edi], eax ;c.low
182 mov [edi+4], edx ;c.high
183
184 pop edx
185 pop edi
186 pop esi
187 leave
[21916]188 ret
[8401]189
[21916]190_Add64 endp
[8401]191
192
[21916]193 align 4h
[9946]194
[21916]195 public _set_bit
[9946]196;void CDECL set_bit(int bitnr, void *addr);
197_set_bit proc near
198 push esi
199
200 mov esi, [esp+12]
201 mov eax, [esp+8]
202
203 bts dword ptr [esi], eax
204
205 pop esi
206 ret
207_set_bit endp
208
[21916]209 align 4h
[9946]210
[21916]211 public _test_bit
[9946]212;int CDECL test_bit(int bitnr, void *addr);
213_test_bit proc near
214 push esi
215
216 mov esi, [esp+12]
217 mov eax, [esp+8]
218
219 bt dword ptr [esi], eax
220 setc al
221 movzx eax, al
222
223 pop esi
224 ret
225_test_bit endp
226
[21916]227 public _clear_bit
[9946]228;void CDECL clear_bit(int bitnr, void *addr);
229_clear_bit proc near
230 push esi
231
232 mov esi, [esp+12]
233 mov eax, [esp+8]
234
235 btr dword ptr [esi], eax
236
237 pop esi
238 ret
239_clear_bit endp
240
[21343]241rdtsc macro
242 db 0Fh, 31h
243endm
244
245 public GetPentiumTSC
246GetPentiumTSC proc near
247 mov ecx , [esp + 4]
248 rdtsc
249 mov [ecx] , eax
250 mov [ecx + 4] , edx
251 xor eax , eax
252 ret
253GetPentiumTSC endp
254
[8401]255CODE32 ENDS
256
257 END
Note: See TracBrowser for help on using the repository browser.