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