source: trunk/src/kernel32/asmutil.asm@ 10010

Last change on this file since 10010 was 9946, checked in by sandervl, 22 years ago

memory map updates

File size: 4.1 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 PUBLIC getEBX
28getEAX proc near
29 ret
30getEAX endp
31
32public getEDX
33getEDX proc near
34 mov EAX, EDX
35 ret
36endp
37
38getEBX proc near
39 mov eax, ebx
40 ret
41getEBX endp
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
54SetFS endp
55
56 PUBLIC getCS
57getCS proc near
58 mov eax, cs
59 ret
60getCS endp
61
62 PUBLIC getDS
63getDS proc near
64 mov eax, ds
65 ret
66getDS endp
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
77 PUBLIC getSS
78getSS proc near
79 mov ax, ss
80 ret
81getSS endp
82
83 PUBLIC getES
84getES proc near
85 mov eax, es
86 ret
87getES endp
88
89 PUBLIC getGS
90getGS proc near
91 mov eax, gs
92 ret
93getGS endp
94
95 PUBLIC getESP
96getESP proc near
97 mov eax, esp
98 ret
99getESP endp
100
101 PUBLIC RestoreOS2FS
102RestoreOS2FS proc near
103 push Dos32TIB
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
131 align 4h
132
133 public _Sub64
134_Sub64 proc
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
145 mov eax,[esi] ;a.low
146 mov edx,[esi+04h] ;a.high
147 mov esi, [ebp+0ch] ;&b
148 sub eax,[esi] ;b.low
149 sbb edx,[esi+04h] ;b.high
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
158 ret
159_Sub64 endp
160
161 align 4h
162
163 public _Add64
164_Add64 proc
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
175 mov eax,[esi] ;a.low
176 mov edx,[esi+04h] ;a.high
177 mov esi, [ebp+0ch] ;&b
178 add eax,[esi] ;b.low
179 adc edx,[esi+04h] ;b.high
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
188 ret
189
190_Add64 endp
191
192
193 align 4h
194
195 public _set_bit
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
209 align 4h
210
211 public _test_bit
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
227 public _clear_bit
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
241CODE32 ENDS
242
243 END
Note: See TracBrowser for help on using the repository browser.