1 | /** @file
|
---|
2 | * IPRT - Assembly Functions, x86 32-bit Watcom C/C++ pragma aux.
|
---|
3 | */
|
---|
4 |
|
---|
5 | /*
|
---|
6 | * Copyright (C) 2006-2019 Oracle Corporation
|
---|
7 | *
|
---|
8 | * This file is part of VirtualBox Open Source Edition (OSE), as
|
---|
9 | * available from http://www.virtualbox.org. This file is free software;
|
---|
10 | * you can redistribute it and/or modify it under the terms of the GNU
|
---|
11 | * General Public License (GPL) as published by the Free Software
|
---|
12 | * Foundation, in version 2 as it comes in the "COPYING" file of the
|
---|
13 | * VirtualBox OSE distribution. VirtualBox OSE is distributed in the
|
---|
14 | * hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
|
---|
15 | *
|
---|
16 | * The contents of this file may alternatively be used under the terms
|
---|
17 | * of the Common Development and Distribution License Version 1.0
|
---|
18 | * (CDDL) only, as it comes in the "COPYING.CDDL" file of the
|
---|
19 | * VirtualBox OSE distribution, in which case the provisions of the
|
---|
20 | * CDDL are applicable instead of those of the GPL.
|
---|
21 | *
|
---|
22 | * You may elect to license modified versions of this file under the
|
---|
23 | * terms and conditions of either the GPL or the CDDL or both.
|
---|
24 | */
|
---|
25 |
|
---|
26 | #ifndef IPRT_INCLUDED_asm_watcom_x86_32_h
|
---|
27 | #define IPRT_INCLUDED_asm_watcom_x86_32_h
|
---|
28 | /* no pragma once */
|
---|
29 |
|
---|
30 | #ifndef IPRT_INCLUDED_asm_h
|
---|
31 | # error "Don't include this header directly."
|
---|
32 | #endif
|
---|
33 |
|
---|
34 | #ifndef __FLAT__
|
---|
35 | # error "Only works with flat pointers! (-mf)"
|
---|
36 | #endif
|
---|
37 |
|
---|
38 | /*
|
---|
39 | * Note! The #undef that preceds the #pragma aux statements is for undoing
|
---|
40 | * the mangling, because the symbol in #pragma aux [symbol] statements
|
---|
41 | * doesn't get subjected to preprocessing. This is also why we include
|
---|
42 | * the watcom header at both the top and the bottom of asm.h file.
|
---|
43 | */
|
---|
44 |
|
---|
45 | #undef ASMCompilerBarrier
|
---|
46 | #ifdef IPRT_ASM_WATCOM_X86_32_WITH_PRAGMAS
|
---|
47 | # if 0 /* overkill version. */
|
---|
48 | # pragma aux ASMCompilerBarrier = \
|
---|
49 | "nop" \
|
---|
50 | parm [] \
|
---|
51 | modify exact [eax ebx ecx edx es ds fs gs];
|
---|
52 | # else
|
---|
53 | # pragma aux ASMCompilerBarrier = \
|
---|
54 | "" \
|
---|
55 | parm [] \
|
---|
56 | modify exact [];
|
---|
57 | # endif
|
---|
58 | #endif
|
---|
59 |
|
---|
60 | #undef ASMNopPause
|
---|
61 | #ifdef IPRT_ASM_WATCOM_X86_32_WITH_PRAGMAS
|
---|
62 | #pragma aux ASMNopPause = \
|
---|
63 | ".686p" \
|
---|
64 | ".xmm2" \
|
---|
65 | "pause" \
|
---|
66 | parm [] nomemory \
|
---|
67 | modify exact [] nomemory;
|
---|
68 | #endif
|
---|
69 |
|
---|
70 | #undef ASMAtomicXchgU8
|
---|
71 | #ifdef IPRT_ASM_WATCOM_X86_32_WITH_PRAGMAS
|
---|
72 | #pragma aux ASMAtomicXchgU8 = \
|
---|
73 | "xchg [ecx], al" \
|
---|
74 | parm [ecx] [al] \
|
---|
75 | value [al] \
|
---|
76 | modify exact [al];
|
---|
77 | #endif
|
---|
78 |
|
---|
79 | #undef ASMAtomicXchgU16
|
---|
80 | #ifdef IPRT_ASM_WATCOM_X86_32_WITH_PRAGMAS
|
---|
81 | #pragma aux ASMAtomicXchgU16 = \
|
---|
82 | "xchg [ecx], ax" \
|
---|
83 | parm [ecx] [ax] \
|
---|
84 | value [ax] \
|
---|
85 | modify exact [ax];
|
---|
86 | #endif
|
---|
87 |
|
---|
88 | #undef ASMAtomicXchgU32
|
---|
89 | #ifdef IPRT_ASM_WATCOM_X86_32_WITH_PRAGMAS
|
---|
90 | #pragma aux ASMAtomicXchgU32 = \
|
---|
91 | "xchg [ecx], eax" \
|
---|
92 | parm [ecx] [eax] \
|
---|
93 | value [eax] \
|
---|
94 | modify exact [eax];
|
---|
95 | #endif
|
---|
96 |
|
---|
97 | #undef ASMAtomicXchgU64
|
---|
98 | #ifdef IPRT_ASM_WATCOM_X86_32_WITH_PRAGMAS
|
---|
99 | #pragma aux ASMAtomicXchgU64 = \
|
---|
100 | ".586" \
|
---|
101 | "try_again:" \
|
---|
102 | "lock cmpxchg8b [esi]" \
|
---|
103 | "jnz try_again" \
|
---|
104 | parm [esi] [ebx ecx] \
|
---|
105 | value [eax edx] \
|
---|
106 | modify exact [edx ecx ebx eax];
|
---|
107 | #endif
|
---|
108 |
|
---|
109 | #undef ASMAtomicCmpXchgU8
|
---|
110 | #ifdef IPRT_ASM_WATCOM_X86_32_WITH_PRAGMAS
|
---|
111 | #pragma aux ASMAtomicCmpXchgU8 = \
|
---|
112 | ".486" \
|
---|
113 | "lock cmpxchg [edx], cl" \
|
---|
114 | "setz al" \
|
---|
115 | parm [edx] [cl] [al] \
|
---|
116 | value [al] \
|
---|
117 | modify exact [al];
|
---|
118 | #endif
|
---|
119 |
|
---|
120 | #undef ASMAtomicCmpXchgU16
|
---|
121 | #ifdef IPRT_ASM_WATCOM_X86_32_WITH_PRAGMAS
|
---|
122 | #pragma aux ASMAtomicCmpXchgU16 = \
|
---|
123 | ".486" \
|
---|
124 | "lock cmpxchg [edx], cx" \
|
---|
125 | "setz al" \
|
---|
126 | parm [edx] [cx] [ax] \
|
---|
127 | value [al] \
|
---|
128 | modify exact [ax];
|
---|
129 | #endif
|
---|
130 |
|
---|
131 | #undef ASMAtomicCmpXchgU32
|
---|
132 | #ifdef IPRT_ASM_WATCOM_X86_32_WITH_PRAGMAS
|
---|
133 | #pragma aux ASMAtomicCmpXchgU32 = \
|
---|
134 | ".486" \
|
---|
135 | "lock cmpxchg [edx], ecx" \
|
---|
136 | "setz al" \
|
---|
137 | parm [edx] [ecx] [eax] \
|
---|
138 | value [al] \
|
---|
139 | modify exact [eax];
|
---|
140 | #endif
|
---|
141 |
|
---|
142 | #undef ASMAtomicCmpXchgU64
|
---|
143 | #ifdef IPRT_ASM_WATCOM_X86_32_WITH_PRAGMAS
|
---|
144 | #pragma aux ASMAtomicCmpXchgU64 = \
|
---|
145 | ".586" \
|
---|
146 | "lock cmpxchg8b [edi]" \
|
---|
147 | "setz al" \
|
---|
148 | parm [edi] [ebx ecx] [eax edx] \
|
---|
149 | value [al] \
|
---|
150 | modify exact [eax edx];
|
---|
151 | #endif
|
---|
152 |
|
---|
153 | #undef ASMAtomicCmpXchgExU32
|
---|
154 | #ifdef IPRT_ASM_WATCOM_X86_32_WITH_PRAGMAS
|
---|
155 | #pragma aux ASMAtomicCmpXchgExU32 = \
|
---|
156 | ".586" \
|
---|
157 | "lock cmpxchg [edx], ecx" \
|
---|
158 | "mov [edi], eax" \
|
---|
159 | "setz al" \
|
---|
160 | parm [edx] [ecx] [eax] [edi] \
|
---|
161 | value [al] \
|
---|
162 | modify exact [eax];
|
---|
163 | #endif
|
---|
164 |
|
---|
165 | #undef ASMAtomicCmpXchgExU64
|
---|
166 | #ifdef IPRT_ASM_WATCOM_X86_32_WITH_PRAGMAS
|
---|
167 | #pragma aux ASMAtomicCmpXchgExU64 = \
|
---|
168 | ".586" \
|
---|
169 | "lock cmpxchg8b [edi]" \
|
---|
170 | "mov [esi], eax" \
|
---|
171 | "mov [esi + 4], edx" \
|
---|
172 | "setz al" \
|
---|
173 | parm [edi] [ebx ecx] [eax edx] [esi] \
|
---|
174 | value [al] \
|
---|
175 | modify exact [eax edx];
|
---|
176 | #endif
|
---|
177 |
|
---|
178 | #undef ASMSerializeInstructionCpuId
|
---|
179 | #ifdef IPRT_ASM_WATCOM_X86_32_WITH_PRAGMAS
|
---|
180 | #pragma aux ASMSerializeInstructionCpuId = \
|
---|
181 | ".586" \
|
---|
182 | "xor eax, eax" \
|
---|
183 | "cpuid" \
|
---|
184 | parm [] \
|
---|
185 | modify exact [eax ebx ecx edx];
|
---|
186 | #endif
|
---|
187 |
|
---|
188 | #undef ASMSerializeInstructionIRet
|
---|
189 | #ifdef IPRT_ASM_WATCOM_X86_32_WITH_PRAGMAS
|
---|
190 | #pragma aux ASMSerializeInstructionIRet = \
|
---|
191 | "pushf" \
|
---|
192 | "push cs" \
|
---|
193 | "call foo" /* 'push offset done' doesn't work */ \
|
---|
194 | "jmp done" \
|
---|
195 | "foo:" \
|
---|
196 | "iret" \
|
---|
197 | "done:" \
|
---|
198 | parm [] \
|
---|
199 | modify exact [];
|
---|
200 | #endif
|
---|
201 |
|
---|
202 | #undef ASMSerializeInstructionRdTscp
|
---|
203 | #ifdef IPRT_ASM_WATCOM_X86_32_WITH_PRAGMAS
|
---|
204 | #pragma aux ASMSerializeInstructionRdTscp = \
|
---|
205 | 0x0f 0x01 0xf9 \
|
---|
206 | parm [] \
|
---|
207 | modify exact [eax edx ecx];
|
---|
208 | #endif
|
---|
209 |
|
---|
210 | #undef ASMAtomicReadU64
|
---|
211 | #ifdef IPRT_ASM_WATCOM_X86_32_WITH_PRAGMAS
|
---|
212 | #pragma aux ASMAtomicReadU64 = \
|
---|
213 | ".586" \
|
---|
214 | "xor eax, eax" \
|
---|
215 | "mov edx, eax" \
|
---|
216 | "mov ebx, eax" \
|
---|
217 | "mov ecx, eax" \
|
---|
218 | "lock cmpxchg8b [edi]" \
|
---|
219 | parm [edi] \
|
---|
220 | value [eax edx] \
|
---|
221 | modify exact [eax ebx ecx edx];
|
---|
222 | #endif
|
---|
223 |
|
---|
224 | #undef ASMAtomicUoReadU64
|
---|
225 | #ifdef IPRT_ASM_WATCOM_X86_32_WITH_PRAGMAS
|
---|
226 | #pragma aux ASMAtomicUoReadU64 = \
|
---|
227 | ".586" \
|
---|
228 | "xor eax, eax" \
|
---|
229 | "mov edx, eax" \
|
---|
230 | "mov ebx, eax" \
|
---|
231 | "mov ecx, eax" \
|
---|
232 | "lock cmpxchg8b [edi]" \
|
---|
233 | parm [edi] \
|
---|
234 | value [eax edx] \
|
---|
235 | modify exact [eax ebx ecx edx];
|
---|
236 | #endif
|
---|
237 |
|
---|
238 | #undef ASMAtomicAddU16
|
---|
239 | #ifdef IPRT_ASM_WATCOM_X86_32_WITH_PRAGMAS
|
---|
240 | #pragma aux ASMAtomicAddU16 = \
|
---|
241 | ".486" \
|
---|
242 | "lock xadd [ecx], ax" \
|
---|
243 | parm [ecx] [ax] \
|
---|
244 | value [ax] \
|
---|
245 | modify exact [ax];
|
---|
246 | #endif
|
---|
247 |
|
---|
248 | #undef ASMAtomicAddU32
|
---|
249 | #ifdef IPRT_ASM_WATCOM_X86_32_WITH_PRAGMAS
|
---|
250 | #pragma aux ASMAtomicAddU32 = \
|
---|
251 | ".486" \
|
---|
252 | "lock xadd [ecx], eax" \
|
---|
253 | parm [ecx] [eax] \
|
---|
254 | value [eax] \
|
---|
255 | modify exact [eax];
|
---|
256 | #endif
|
---|
257 |
|
---|
258 | #undef ASMAtomicIncU16
|
---|
259 | #ifdef IPRT_ASM_WATCOM_X86_32_WITH_PRAGMAS
|
---|
260 | #pragma aux ASMAtomicIncU16 = \
|
---|
261 | ".486" \
|
---|
262 | "mov ax, 1" \
|
---|
263 | "lock xadd [ecx], ax" \
|
---|
264 | "inc ax" \
|
---|
265 | parm [ecx] \
|
---|
266 | value [ax] \
|
---|
267 | modify exact [ax];
|
---|
268 | #endif
|
---|
269 |
|
---|
270 | #undef ASMAtomicIncU32
|
---|
271 | #ifdef IPRT_ASM_WATCOM_X86_32_WITH_PRAGMAS
|
---|
272 | #pragma aux ASMAtomicIncU32 = \
|
---|
273 | ".486" \
|
---|
274 | "mov eax, 1" \
|
---|
275 | "lock xadd [ecx], eax" \
|
---|
276 | "inc eax" \
|
---|
277 | parm [ecx] \
|
---|
278 | value [eax] \
|
---|
279 | modify exact [eax];
|
---|
280 | #endif
|
---|
281 |
|
---|
282 | /* ASMAtomicIncU64: Should be done by C inline or in external file. */
|
---|
283 |
|
---|
284 | #undef ASMAtomicDecU16
|
---|
285 | #ifdef IPRT_ASM_WATCOM_X86_32_WITH_PRAGMAS
|
---|
286 | #pragma aux ASMAtomicDecU16 = \
|
---|
287 | ".486" \
|
---|
288 | "mov ax, 0ffffh" \
|
---|
289 | "lock xadd [ecx], ax" \
|
---|
290 | "dec ax" \
|
---|
291 | parm [ecx] \
|
---|
292 | value [ax] \
|
---|
293 | modify exact [ax];
|
---|
294 | #endif
|
---|
295 |
|
---|
296 | #undef ASMAtomicDecU32
|
---|
297 | #ifdef IPRT_ASM_WATCOM_X86_32_WITH_PRAGMAS
|
---|
298 | #pragma aux ASMAtomicDecU32 = \
|
---|
299 | ".486" \
|
---|
300 | "mov eax, 0ffffffffh" \
|
---|
301 | "lock xadd [ecx], eax" \
|
---|
302 | "dec eax" \
|
---|
303 | parm [ecx] \
|
---|
304 | value [eax] \
|
---|
305 | modify exact [eax];
|
---|
306 | #endif
|
---|
307 |
|
---|
308 | /* ASMAtomicDecU64: Should be done by C inline or in external file. */
|
---|
309 |
|
---|
310 | #undef ASMAtomicOrU32
|
---|
311 | #ifdef IPRT_ASM_WATCOM_X86_32_WITH_PRAGMAS
|
---|
312 | #pragma aux ASMAtomicOrU32 = \
|
---|
313 | "lock or [ecx], eax" \
|
---|
314 | parm [ecx] [eax] \
|
---|
315 | modify exact [];
|
---|
316 | #endif
|
---|
317 |
|
---|
318 | /* ASMAtomicOrU64: Should be done by C inline or in external file. */
|
---|
319 |
|
---|
320 | #undef ASMAtomicAndU32
|
---|
321 | #ifdef IPRT_ASM_WATCOM_X86_32_WITH_PRAGMAS
|
---|
322 | #pragma aux ASMAtomicAndU32 = \
|
---|
323 | "lock and [ecx], eax" \
|
---|
324 | parm [ecx] [eax] \
|
---|
325 | modify exact [];
|
---|
326 | #endif
|
---|
327 |
|
---|
328 | /* ASMAtomicAndU64: Should be done by C inline or in external file. */
|
---|
329 |
|
---|
330 | #undef ASMAtomicUoOrU32
|
---|
331 | #ifdef IPRT_ASM_WATCOM_X86_32_WITH_PRAGMAS
|
---|
332 | #pragma aux ASMAtomicUoOrU32 = \
|
---|
333 | "or [ecx], eax" \
|
---|
334 | parm [ecx] [eax] \
|
---|
335 | modify exact [];
|
---|
336 | #endif
|
---|
337 |
|
---|
338 | /* ASMAtomicUoOrU64: Should be done by C inline or in external file. */
|
---|
339 |
|
---|
340 | #undef ASMAtomicUoAndU32
|
---|
341 | #ifdef IPRT_ASM_WATCOM_X86_32_WITH_PRAGMAS
|
---|
342 | #pragma aux ASMAtomicUoAndU32 = \
|
---|
343 | "and [ecx], eax" \
|
---|
344 | parm [ecx] [eax] \
|
---|
345 | modify exact [];
|
---|
346 | #endif
|
---|
347 |
|
---|
348 | /* ASMAtomicUoAndU64: Should be done by C inline or in external file. */
|
---|
349 |
|
---|
350 | #undef ASMAtomicUoIncU32
|
---|
351 | #ifdef IPRT_ASM_WATCOM_X86_32_WITH_PRAGMAS
|
---|
352 | #pragma aux ASMAtomicUoIncU32 = \
|
---|
353 | ".486" \
|
---|
354 | "xadd [ecx], eax" \
|
---|
355 | "inc eax" \
|
---|
356 | parm [ecx] \
|
---|
357 | value [eax] \
|
---|
358 | modify exact [eax];
|
---|
359 | #endif
|
---|
360 |
|
---|
361 | #undef ASMAtomicUoDecU32
|
---|
362 | #ifdef IPRT_ASM_WATCOM_X86_32_WITH_PRAGMAS
|
---|
363 | #pragma aux ASMAtomicUoDecU32 = \
|
---|
364 | ".486" \
|
---|
365 | "mov eax, 0ffffffffh" \
|
---|
366 | "xadd [ecx], eax" \
|
---|
367 | "dec eax" \
|
---|
368 | parm [ecx] \
|
---|
369 | value [eax] \
|
---|
370 | modify exact [eax];
|
---|
371 | #endif
|
---|
372 |
|
---|
373 | #undef ASMMemZeroPage
|
---|
374 | #ifdef IPRT_ASM_WATCOM_X86_32_WITH_PRAGMAS
|
---|
375 | #pragma aux ASMMemZeroPage = \
|
---|
376 | "mov ecx, 1024" \
|
---|
377 | "xor eax, eax" \
|
---|
378 | "rep stosd" \
|
---|
379 | parm [edi] \
|
---|
380 | modify exact [eax ecx edi];
|
---|
381 | #endif
|
---|
382 |
|
---|
383 | #undef ASMMemZero32
|
---|
384 | #ifdef IPRT_ASM_WATCOM_X86_32_WITH_PRAGMAS
|
---|
385 | #pragma aux ASMMemZero32 = \
|
---|
386 | "shr ecx, 2" \
|
---|
387 | "xor eax, eax" \
|
---|
388 | "rep stosd" \
|
---|
389 | parm [edi] [ecx] \
|
---|
390 | modify exact [eax ecx edi];
|
---|
391 | #endif
|
---|
392 |
|
---|
393 | #undef ASMMemFill32
|
---|
394 | #ifdef IPRT_ASM_WATCOM_X86_32_WITH_PRAGMAS
|
---|
395 | #pragma aux ASMMemFill32 = \
|
---|
396 | "shr ecx, 2" \
|
---|
397 | "rep stosd" \
|
---|
398 | parm [edi] [ecx] [eax]\
|
---|
399 | modify exact [ecx edi];
|
---|
400 | #endif
|
---|
401 |
|
---|
402 | #undef ASMProbeReadByte
|
---|
403 | #ifdef IPRT_ASM_WATCOM_X86_32_WITH_PRAGMAS
|
---|
404 | #pragma aux ASMProbeReadByte = \
|
---|
405 | "mov al, [ecx]" \
|
---|
406 | parm [ecx] \
|
---|
407 | value [al] \
|
---|
408 | modify exact [al];
|
---|
409 | #endif
|
---|
410 |
|
---|
411 | #undef ASMBitSet
|
---|
412 | #ifdef IPRT_ASM_WATCOM_X86_32_WITH_PRAGMAS
|
---|
413 | #pragma aux ASMBitSet = \
|
---|
414 | "bts [ecx], eax" \
|
---|
415 | parm [ecx] [eax] \
|
---|
416 | modify exact [];
|
---|
417 | #endif
|
---|
418 |
|
---|
419 | #undef ASMAtomicBitSet
|
---|
420 | #ifdef IPRT_ASM_WATCOM_X86_32_WITH_PRAGMAS
|
---|
421 | #pragma aux ASMAtomicBitSet = \
|
---|
422 | "lock bts [ecx], eax" \
|
---|
423 | parm [ecx] [eax] \
|
---|
424 | modify exact [];
|
---|
425 | #endif
|
---|
426 |
|
---|
427 | #undef ASMBitClear
|
---|
428 | #ifdef IPRT_ASM_WATCOM_X86_32_WITH_PRAGMAS
|
---|
429 | #pragma aux ASMBitClear = \
|
---|
430 | "btr [ecx], eax" \
|
---|
431 | parm [ecx] [eax] \
|
---|
432 | modify exact [];
|
---|
433 | #endif
|
---|
434 |
|
---|
435 | #undef ASMAtomicBitClear
|
---|
436 | #ifdef IPRT_ASM_WATCOM_X86_32_WITH_PRAGMAS
|
---|
437 | #pragma aux ASMAtomicBitClear = \
|
---|
438 | "lock btr [ecx], eax" \
|
---|
439 | parm [ecx] [eax] \
|
---|
440 | modify exact [];
|
---|
441 | #endif
|
---|
442 |
|
---|
443 | #undef ASMBitToggle
|
---|
444 | #ifdef IPRT_ASM_WATCOM_X86_32_WITH_PRAGMAS
|
---|
445 | #pragma aux ASMBitToggle = \
|
---|
446 | "btc [ecx], eax" \
|
---|
447 | parm [ecx] [eax] \
|
---|
448 | modify exact [];
|
---|
449 | #endif
|
---|
450 |
|
---|
451 | #undef ASMAtomicBitToggle
|
---|
452 | #ifdef IPRT_ASM_WATCOM_X86_32_WITH_PRAGMAS
|
---|
453 | #pragma aux ASMAtomicBitToggle = \
|
---|
454 | "lock btc [ecx], eax" \
|
---|
455 | parm [ecx] [eax] \
|
---|
456 | modify exact [];
|
---|
457 | #endif
|
---|
458 |
|
---|
459 |
|
---|
460 | #undef ASMBitTestAndSet
|
---|
461 | #ifdef IPRT_ASM_WATCOM_X86_32_WITH_PRAGMAS
|
---|
462 | #pragma aux ASMBitTestAndSet = \
|
---|
463 | "bts [ecx], eax" \
|
---|
464 | "setc al" \
|
---|
465 | parm [ecx] [eax] \
|
---|
466 | value [al] \
|
---|
467 | modify exact [eax];
|
---|
468 | #endif
|
---|
469 |
|
---|
470 | #undef ASMAtomicBitTestAndSet
|
---|
471 | #ifdef IPRT_ASM_WATCOM_X86_32_WITH_PRAGMAS
|
---|
472 | #pragma aux ASMAtomicBitTestAndSet = \
|
---|
473 | "lock bts [ecx], eax" \
|
---|
474 | "setc al" \
|
---|
475 | parm [ecx] [eax] \
|
---|
476 | value [al] \
|
---|
477 | modify exact [eax];
|
---|
478 | #endif
|
---|
479 |
|
---|
480 | #undef ASMBitTestAndClear
|
---|
481 | #ifdef IPRT_ASM_WATCOM_X86_32_WITH_PRAGMAS
|
---|
482 | #pragma aux ASMBitTestAndClear = \
|
---|
483 | "btr [ecx], eax" \
|
---|
484 | "setc al" \
|
---|
485 | parm [ecx] [eax] \
|
---|
486 | value [al] \
|
---|
487 | modify exact [eax];
|
---|
488 | #endif
|
---|
489 |
|
---|
490 | #undef ASMAtomicBitTestAndClear
|
---|
491 | #ifdef IPRT_ASM_WATCOM_X86_32_WITH_PRAGMAS
|
---|
492 | #pragma aux ASMAtomicBitTestAndClear = \
|
---|
493 | "lock btr [ecx], eax" \
|
---|
494 | "setc al" \
|
---|
495 | parm [ecx] [eax] \
|
---|
496 | value [al] \
|
---|
497 | modify exact [eax];
|
---|
498 | #endif
|
---|
499 |
|
---|
500 | #undef ASMBitTestAndToggle
|
---|
501 | #ifdef IPRT_ASM_WATCOM_X86_32_WITH_PRAGMAS
|
---|
502 | #pragma aux ASMBitTestAndToggle = \
|
---|
503 | "btc [ecx], eax" \
|
---|
504 | "setc al" \
|
---|
505 | parm [ecx] [eax] \
|
---|
506 | value [al] \
|
---|
507 | modify exact [eax];
|
---|
508 | #endif
|
---|
509 |
|
---|
510 | #undef ASMAtomicBitTestAndToggle
|
---|
511 | #ifdef IPRT_ASM_WATCOM_X86_32_WITH_PRAGMAS
|
---|
512 | #pragma aux ASMAtomicBitTestAndToggle = \
|
---|
513 | "lock btc [ecx], eax" \
|
---|
514 | "setc al" \
|
---|
515 | parm [ecx] [eax] \
|
---|
516 | value [al] \
|
---|
517 | modify exact [eax];
|
---|
518 | #endif
|
---|
519 |
|
---|
520 | #undef ASMBitTest
|
---|
521 | #ifdef IPRT_ASM_WATCOM_X86_32_WITH_PRAGMAS
|
---|
522 | #pragma aux ASMBitTest = \
|
---|
523 | "bt [ecx], eax" \
|
---|
524 | "setc al" \
|
---|
525 | parm [ecx] [eax] nomemory \
|
---|
526 | value [al] \
|
---|
527 | modify exact [eax] nomemory;
|
---|
528 | #endif
|
---|
529 |
|
---|
530 | #if 0
|
---|
531 | /** @todo this is way to much inline assembly, better off in an external function. */
|
---|
532 | #undef ASMBitFirstClear
|
---|
533 | #ifdef IPRT_ASM_WATCOM_X86_32_WITH_PRAGMAS
|
---|
534 | #pragma aux ASMBitFirstClear = \
|
---|
535 | "mov edx, edi" /* save start of bitmap for later */ \
|
---|
536 | "add ecx, 31" \
|
---|
537 | "shr ecx, 5" /* cDWord = RT_ALIGN_32(cBits, 32) / 32; */ \
|
---|
538 | "mov eax, 0ffffffffh" \
|
---|
539 | "repe scasd" \
|
---|
540 | "je done" \
|
---|
541 | "lea edi, [edi - 4]" /* rewind edi */ \
|
---|
542 | "xor eax, [edi]" /* load inverted bits */ \
|
---|
543 | "sub edi, edx" /* calc byte offset */ \
|
---|
544 | "shl edi, 3" /* convert byte to bit offset */ \
|
---|
545 | "mov edx, eax" \
|
---|
546 | "bsf eax, edx" \
|
---|
547 | "add eax, edi" \
|
---|
548 | "done:" \
|
---|
549 | parm [edi] [ecx] \
|
---|
550 | value [eax] \
|
---|
551 | modify exact [eax ecx edx edi];
|
---|
552 | #endif
|
---|
553 |
|
---|
554 | /* ASMBitNextClear: Too much work, do when needed. */
|
---|
555 |
|
---|
556 | /** @todo this is way to much inline assembly, better off in an external function. */
|
---|
557 | #undef ASMBitFirstSet
|
---|
558 | #ifdef IPRT_ASM_WATCOM_X86_32_WITH_PRAGMAS
|
---|
559 | #pragma aux ASMBitFirstSet = \
|
---|
560 | "mov edx, edi" /* save start of bitmap for later */ \
|
---|
561 | "add ecx, 31" \
|
---|
562 | "shr ecx, 5" /* cDWord = RT_ALIGN_32(cBits, 32) / 32; */ \
|
---|
563 | "mov eax, 0ffffffffh" \
|
---|
564 | "repe scasd" \
|
---|
565 | "je done" \
|
---|
566 | "lea edi, [edi - 4]" /* rewind edi */ \
|
---|
567 | "mov eax, [edi]" /* reload previous dword */ \
|
---|
568 | "sub edi, edx" /* calc byte offset */ \
|
---|
569 | "shl edi, 3" /* convert byte to bit offset */ \
|
---|
570 | "mov edx, eax" \
|
---|
571 | "bsf eax, edx" \
|
---|
572 | "add eax, edi" \
|
---|
573 | "done:" \
|
---|
574 | parm [edi] [ecx] \
|
---|
575 | value [eax] \
|
---|
576 | modify exact [eax ecx edx edi];
|
---|
577 | #endif
|
---|
578 |
|
---|
579 | /* ASMBitNextSet: Too much work, do when needed. */
|
---|
580 | #else
|
---|
581 | /* ASMBitFirstClear: External file. */
|
---|
582 | /* ASMBitNextClear: External file. */
|
---|
583 | /* ASMBitFirstSet: External file. */
|
---|
584 | /* ASMBitNextSet: External file. */
|
---|
585 | #endif
|
---|
586 |
|
---|
587 | #undef ASMBitFirstSetU32
|
---|
588 | #ifdef IPRT_ASM_WATCOM_X86_32_WITH_PRAGMAS
|
---|
589 | #pragma aux ASMBitFirstSetU32 = \
|
---|
590 | "bsf eax, eax" \
|
---|
591 | "jz not_found" \
|
---|
592 | "inc eax" \
|
---|
593 | "jmp done" \
|
---|
594 | "not_found:" \
|
---|
595 | "xor eax, eax" \
|
---|
596 | "done:" \
|
---|
597 | parm [eax] nomemory \
|
---|
598 | value [eax] \
|
---|
599 | modify exact [eax] nomemory;
|
---|
600 | #endif
|
---|
601 |
|
---|
602 | #undef ASMBitFirstSetU64
|
---|
603 | #ifdef IPRT_ASM_WATCOM_X86_32_WITH_PRAGMAS
|
---|
604 | #pragma aux ASMBitFirstSetU64 = \
|
---|
605 | "bsf eax, eax" \
|
---|
606 | "jz not_found_low" \
|
---|
607 | "inc eax" \
|
---|
608 | "jmp done" \
|
---|
609 | \
|
---|
610 | "not_found_low:" \
|
---|
611 | "bsf eax, edx" \
|
---|
612 | "jz not_found_high" \
|
---|
613 | "add eax, 33" \
|
---|
614 | "jmp done" \
|
---|
615 | \
|
---|
616 | "not_found_high:" \
|
---|
617 | "xor eax, eax" \
|
---|
618 | "done:" \
|
---|
619 | parm [eax edx] nomemory \
|
---|
620 | value [eax] \
|
---|
621 | modify exact [eax] nomemory;
|
---|
622 | #endif
|
---|
623 |
|
---|
624 | #undef ASMBitFirstSetU16
|
---|
625 | #ifdef IPRT_ASM_WATCOM_X86_32_WITH_PRAGMAS
|
---|
626 | #pragma aux ASMBitFirstSetU16 = \
|
---|
627 | "movzx eax, ax" \
|
---|
628 | "bsf eax, eax" \
|
---|
629 | "jz not_found" \
|
---|
630 | "inc eax" \
|
---|
631 | "jmp done" \
|
---|
632 | "not_found:" \
|
---|
633 | "xor eax, eax" \
|
---|
634 | "done:" \
|
---|
635 | parm [ax] nomemory \
|
---|
636 | value [eax] \
|
---|
637 | modify exact [eax] nomemory;
|
---|
638 | #endif
|
---|
639 |
|
---|
640 | #undef ASMBitLastSetU32
|
---|
641 | #ifdef IPRT_ASM_WATCOM_X86_32_WITH_PRAGMAS
|
---|
642 | #pragma aux ASMBitLastSetU32 = \
|
---|
643 | "bsr eax, eax" \
|
---|
644 | "jz not_found" \
|
---|
645 | "inc eax" \
|
---|
646 | "jmp done" \
|
---|
647 | "not_found:" \
|
---|
648 | "xor eax, eax" \
|
---|
649 | "done:" \
|
---|
650 | parm [eax] nomemory \
|
---|
651 | value [eax] \
|
---|
652 | modify exact [eax] nomemory;
|
---|
653 | #endif
|
---|
654 |
|
---|
655 | #undef ASMBitLastSetU64
|
---|
656 | #ifdef IPRT_ASM_WATCOM_X86_32_WITH_PRAGMAS
|
---|
657 | #pragma aux ASMBitLastSetU64 = \
|
---|
658 | "bsf eax, eax" \
|
---|
659 | "jz not_found_low" \
|
---|
660 | "inc eax" \
|
---|
661 | "jmp done" \
|
---|
662 | \
|
---|
663 | "not_found_low:" \
|
---|
664 | "bsf eax, edx" \
|
---|
665 | "jz not_found_high" \
|
---|
666 | "add eax, 33" \
|
---|
667 | "jmp done" \
|
---|
668 | \
|
---|
669 | "not_found_high:" \
|
---|
670 | "xor eax, eax" \
|
---|
671 | "done:" \
|
---|
672 | parm [eax edx] nomemory \
|
---|
673 | value [eax] \
|
---|
674 | modify exact [eax] nomemory;
|
---|
675 | #endif
|
---|
676 |
|
---|
677 | #undef ASMBitLastSetU16
|
---|
678 | #ifdef IPRT_ASM_WATCOM_X86_32_WITH_PRAGMAS
|
---|
679 | #pragma aux ASMBitLastSetU16 = \
|
---|
680 | "movzx eax, ax" \
|
---|
681 | "bsr eax, eax" \
|
---|
682 | "jz not_found" \
|
---|
683 | "inc eax" \
|
---|
684 | "jmp done" \
|
---|
685 | "not_found:" \
|
---|
686 | "xor eax, eax" \
|
---|
687 | "done:" \
|
---|
688 | parm [ax] nomemory \
|
---|
689 | value [eax] \
|
---|
690 | modify exact [eax] nomemory;
|
---|
691 | #endif
|
---|
692 |
|
---|
693 | #undef ASMByteSwapU16
|
---|
694 | #ifdef IPRT_ASM_WATCOM_X86_32_WITH_PRAGMAS
|
---|
695 | #pragma aux ASMByteSwapU16 = \
|
---|
696 | "ror ax, 8" \
|
---|
697 | parm [ax] nomemory \
|
---|
698 | value [ax] \
|
---|
699 | modify exact [ax] nomemory;
|
---|
700 | #endif
|
---|
701 |
|
---|
702 | #undef ASMByteSwapU32
|
---|
703 | #ifdef IPRT_ASM_WATCOM_X86_32_WITH_PRAGMAS
|
---|
704 | #pragma aux ASMByteSwapU32 = \
|
---|
705 | "bswap eax" \
|
---|
706 | parm [eax] nomemory \
|
---|
707 | value [eax] \
|
---|
708 | modify exact [eax] nomemory;
|
---|
709 | #endif
|
---|
710 |
|
---|
711 | #undef ASMRotateLeftU32
|
---|
712 | #ifdef IPRT_ASM_WATCOM_X86_32_WITH_PRAGMAS
|
---|
713 | #pragma aux ASMRotateLeftU32 = \
|
---|
714 | "rol eax, cl" \
|
---|
715 | parm [eax] [ecx] nomemory \
|
---|
716 | value [eax] \
|
---|
717 | modify exact [eax] nomemory;
|
---|
718 | #endif
|
---|
719 |
|
---|
720 | #undef ASMRotateRightU32
|
---|
721 | #ifdef IPRT_ASM_WATCOM_X86_32_WITH_PRAGMAS
|
---|
722 | #pragma aux ASMRotateRightU32 = \
|
---|
723 | "ror eax, cl" \
|
---|
724 | parm [eax] [ecx] nomemory \
|
---|
725 | value [eax] \
|
---|
726 | modify exact [eax] nomemory;
|
---|
727 | #endif
|
---|
728 |
|
---|
729 | #endif /* !IPRT_INCLUDED_asm_watcom_x86_32_h */
|
---|
730 |
|
---|