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