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