source: branches/gcc-kmk/src/kernel32/asmutil.asm@ 21783

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

Use underscores for symbols defined in .asm as they are cdecl.

IBM VAC seemed to detect they are ASM and not use underscores
when referencing them from C.

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