VirtualBox

source: vbox/trunk/include/iprt/asm-watcom-x86-16.h@ 65948

Last change on this file since 65948 was 62473, checked in by vboxsync, 8 years ago

(C) 2016

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 21.6 KB
Line 
1/** @file
2 * IPRT - Assembly Functions, x86 16-bit Watcom C/C++ pragma aux.
3 */
4
5/*
6 * Copyright (C) 2006-2016 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_16_h
30#define ___iprt_asm_watcom_x86_16_h
31
32#if !RT_FAR_DATA
33# error "Only works with far data pointers!"
34#endif
35
36/*
37 * Turns out we cannot use 'ds' for segment stuff here because the compiler
38 * seems to insists on loading the DGROUP segment into 'ds' before calling
39 * stuff when using -ecc. Using 'es' instead as this seems to work fine.
40 *
41 * Note! The #undef that preceds the #pragma aux statements is for undoing
42 * the mangling, because the symbol in #pragma aux [symbol] statements
43 * doesn't get subjected to preprocessing. This is also why we include
44 * the watcom header at the top rather than at the bottom of the
45 * asm-amd64-x86.h file.
46 */
47
48#undef ASMCompilerBarrier
49#if 0 /* overkill version. */
50# pragma aux ASMCompilerBarrier = \
51 "nop" \
52 parm [] \
53 modify exact [ax bx cx dx es ds];
54#else
55# pragma aux ASMCompilerBarrier = \
56 "" \
57 parm [] \
58 modify exact [];
59#endif
60
61#undef ASMNopPause
62#pragma aux ASMNopPause = \
63 ".686p" \
64 ".xmm2" \
65 "pause" \
66 parm [] nomemory \
67 modify exact [] nomemory;
68
69#undef ASMAtomicXchgU8
70#pragma aux ASMAtomicXchgU8 = \
71 "xchg es:[bx], al" \
72 parm [es bx] [al] \
73 value [al] \
74 modify exact [al];
75
76#undef ASMAtomicXchgU16
77#pragma aux ASMAtomicXchgU16 = \
78 "xchg es:[bx], ax" \
79 parm [es bx] [ax] \
80 value [ax] \
81 modify exact [ax];
82
83#undef ASMAtomicXchgU32
84#pragma aux ASMAtomicXchgU32 = \
85 ".386" \
86 "shl ecx, 16" \
87 "mov cx, ax" \
88 "xchg es:[bx], ecx" \
89 "mov eax, ecx" \
90 "shr ecx, 16" \
91 parm [es bx] [ax cx] \
92 value [ax cx] \
93 modify exact [ax cx];
94
95#undef ASMAtomicXchgU64
96#pragma aux ASMAtomicXchgU64 = \
97 ".586" \
98 "shl eax, 16" \
99 "mov ax, bx" /* eax = high dword */ \
100 "shl ecx, 16" \
101 "mov cx, dx" /* ecx = low dword */ \
102 "mov ebx, ecx" /* ebx = low */ \
103 "mov ecx, eax" /* ecx = high */ \
104 "try_again:" \
105 "lock cmpxchg8b es:[si]" \
106 "jnz try_again" \
107 "xchg eax, edx" \
108 "mov ebx, eax" \
109 "shr eax, 16" \
110 "mov ecx, edx" \
111 "shr ecx, 16" \
112 parm [es si] [dx cx bx ax] \
113 value [dx cx bx ax] \
114 modify exact [dx cx bx ax];
115
116#undef ASMAtomicCmpXchgU8
117#pragma aux ASMAtomicCmpXchgU8 = \
118 ".486" \
119 "lock cmpxchg es:[bx], cl" \
120 "setz al" \
121 parm [es bx] [cl] [al] \
122 value [al] \
123 modify exact [al];
124
125#undef ASMAtomicCmpXchgU16
126#pragma aux ASMAtomicCmpXchgU16 = \
127 ".486" \
128 "lock cmpxchg es:[bx], cx" \
129 "setz al" \
130 parm [es bx] [cx] [ax] \
131 value [al] \
132 modify exact [ax];
133
134#undef ASMAtomicCmpXchgU32
135#pragma aux ASMAtomicCmpXchgU32 = \
136 ".486" \
137 "shl ecx, 16" \
138 "mov cx, dx" \
139 "shl eax, 16" \
140 "mov ax, di" \
141 "rol eax, 16" \
142 "lock cmpxchg es:[bx], ecx" \
143 "setz al" \
144 parm [es bx] [cx dx] [ax di] \
145 value [al] \
146 modify exact [ax cx];
147
148/* ASMAtomicCmpXchgU64: External assembly implementation, too few registers for parameters. */
149/* ASMAtomicCmpXchgExU32: External assembly implementation, too few registers for parameters. */
150/* ASMAtomicCmpXchgExU64: External assembly implementation, too few registers for parameters. */
151
152#undef ASMSerializeInstructionCpuId
153#pragma aux ASMSerializeInstructionCpuId = \
154 ".586" \
155 "xor eax, eax" \
156 "cpuid" \
157 parm [] \
158 modify exact [ax bx cx dx];
159
160#undef ASMSerializeInstructionIRet
161#pragma aux ASMSerializeInstructionIRet = \
162 "pushf" \
163 "push cs" \
164 "call foo" /* 'push offset done' doesn't work */ \
165 "jmp done" \
166 "foo:" \
167 "iret" \
168 "done:" \
169 parm [] \
170 modify exact [];
171
172#undef ASMSerializeInstructionRdTscp
173#pragma aux ASMSerializeInstructionRdTscp = \
174 0x0f 0x01 0xf9 \
175 parm [] \
176 modify exact [ax dx cx];
177
178#undef ASMAtomicReadU64
179#pragma aux ASMAtomicReadU64 = \
180 ".586" \
181 "xor eax, eax" \
182 "xor edx, edx" \
183 "xor ebx, ebx" \
184 "xor ecx, ecx" \
185 "lock cmpxchg8b es:[si]" \
186 "xchg eax, edx" \
187 "mov ebx, eax" \
188 "shr eax, 16" \
189 "mov ecx, edx" \
190 "shr ecx, 16" \
191 parm [es si] \
192 value [dx cx bx ax] \
193 modify exact [dx cx bx ax];
194
195#undef ASMAtomicUoReadU64
196#pragma aux ASMAtomicUoReadU64 = \
197 ".586" \
198 "xor eax, eax" \
199 "xor edx, edx" \
200 "xor ebx, ebx" \
201 "xor ecx, ecx" \
202 "lock cmpxchg8b es:[si]" \
203 "xchg eax, edx" \
204 "mov ebx, eax" \
205 "shr eax, 16" \
206 "mov ecx, edx" \
207 "shr ecx, 16" \
208 parm [es si] \
209 value [dx cx bx ax] \
210 modify exact [dx cx bx ax];
211
212#undef ASMAtomicAddU16
213#pragma aux ASMAtomicAddU16 = \
214 ".486" \
215 "lock xadd es:[bx], ax" \
216 parm [es bx] [ax] \
217 value [ax] \
218 modify exact [ax];
219
220#undef ASMAtomicAddU32
221#pragma aux ASMAtomicAddU32 = \
222 ".486" \
223 "shl edx, 16" \
224 "mov dx, ax" \
225 "lock xadd es:[bx], edx" \
226 "mov ax, dx" \
227 "shr edx, 16" \
228 parm [es bx] [ax dx] \
229 value [ax dx] \
230 modify exact [ax dx];
231
232#undef ASMAtomicIncU16
233#pragma aux ASMAtomicIncU16 = \
234 ".486" \
235 "mov ax, 1" \
236 "lock xadd es:[bx], ax" \
237 "inc ax" \
238 parm [es bx] \
239 value [ax] \
240 modify exact [ax];
241
242#undef ASMAtomicIncU32
243#pragma aux ASMAtomicIncU32 = \
244 ".486" \
245 "mov edx, 1" \
246 "lock xadd es:[bx], edx" \
247 "inc edx" \
248 "mov ax, dx" \
249 "shr edx, 16" \
250 parm [es bx] \
251 value [ax dx] \
252 modify exact [ax dx];
253
254/* ASMAtomicIncU64: Should be done by C inline or in external file. */
255
256#undef ASMAtomicDecU16
257#pragma aux ASMAtomicDecU16 = \
258 ".486" \
259 "mov ax, 0ffffh" \
260 "lock xadd es:[bx], ax" \
261 "dec ax" \
262 parm [es bx] \
263 value [ax] \
264 modify exact [ax];
265
266#undef ASMAtomicDecU32
267#pragma aux ASMAtomicDecU32 = \
268 ".486" \
269 "mov edx, 0ffffffffh" \
270 "lock xadd es:[bx], edx" \
271 "dec edx" \
272 "mov ax, dx" \
273 "shr edx, 16" \
274 parm [es bx] \
275 value [ax dx] \
276 modify exact [ax dx];
277
278/* ASMAtomicDecU64: Should be done by C inline or in external file. */
279
280#undef ASMAtomicOrU32
281#pragma aux ASMAtomicOrU32 = \
282 ".386" \
283 "shl edx, 16" \
284 "mov dx, ax" \
285 "lock or es:[bx], edx" \
286 parm [es bx] [ax dx] \
287 modify exact [dx];
288
289/* ASMAtomicOrU64: Should be done by C inline or in external file. */
290
291#undef ASMAtomicAndU32
292#pragma aux ASMAtomicAndU32 = \
293 ".386" \
294 "shl edx, 16" \
295 "mov dx, ax" \
296 "lock and es:[bx], edx" \
297 parm [es bx] [ax dx] \
298 modify exact [dx];
299
300/* ASMAtomicAndU64: Should be done by C inline or in external file. */
301
302#undef ASMAtomicUoOrU32
303#pragma aux ASMAtomicUoOrU32 = \
304 ".386" \
305 "shl edx, 16" \
306 "mov dx, ax" \
307 "or es:[bx], edx" \
308 parm [es bx] [ax dx] \
309 modify exact [dx];
310
311/* ASMAtomicUoOrU64: Should be done by C inline or in external file. */
312
313#undef ASMAtomicUoAndU32
314#pragma aux ASMAtomicUoAndU32 = \
315 ".386" \
316 "shl edx, 16" \
317 "mov dx, ax" \
318 "and es:[bx], edx" \
319 parm [es bx] [ax dx] \
320 modify exact [dx];
321
322/* ASMAtomicUoAndU64: Should be done by C inline or in external file. */
323
324#undef ASMAtomicUoIncU32
325#pragma aux ASMAtomicUoIncU32 = \
326 ".486" \
327 "mov edx, 1" \
328 "xadd es:[bx], edx" \
329 "inc edx" \
330 "mov ax, dx" \
331 "shr edx, 16" \
332 parm [es bx] \
333 value [ax dx] \
334 modify exact [ax dx];
335
336#undef ASMAtomicUoDecU32
337#pragma aux ASMAtomicUoDecU32 = \
338 ".486" \
339 "mov edx, 0ffffffffh" \
340 "xadd es:[bx], edx" \
341 "dec edx" \
342 "mov ax, dx" \
343 "shr edx, 16" \
344 parm [es bx] \
345 value [ax dx] \
346 modify exact [ax dx];
347
348#undef ASMMemZeroPage
349#if defined(__SW_0) || defined(__SW_1) || defined(__SW_2)
350# pragma aux ASMMemZeroPage = \
351 "mov cx, 2048" \
352 "xor ax, ax" \
353 "rep stosw" \
354 parm [es di] \
355 modify exact [ax cx di];
356#else
357# pragma aux ASMMemZeroPage = \
358 "mov ecx, 1024" \
359 "xor eax, eax" \
360 "rep stosd" \
361 parm [es di] \
362 modify exact [ax cx di];
363#endif
364
365#undef ASMMemZero32
366#if defined(__SW_0) || defined(__SW_1) || defined(__SW_2)
367# pragma aux ASMMemZero32 = \
368 "xor ax, ax" \
369 "shr cx, 1" \
370 "shr cx, 1" \
371 "rep stosw" \
372 parm [es di] [cx] \
373 modify exact [ax dx cx di];
374#else
375# pragma aux ASMMemZero32 = \
376 "and ecx, 0ffffh" /* probably not necessary, lazy bird should check... */ \
377 "shr ecx, 2" \
378 "xor eax, eax" \
379 "rep stosd" \
380 parm [es di] [cx] \
381 modify exact [ax cx di];
382#endif
383
384#undef ASMMemFill32
385#if defined(__SW_0) || defined(__SW_1) || defined(__SW_2)
386# pragma aux ASMMemFill32 = \
387 " shr cx, 1" \
388 " shr cx, 1" \
389 " jz done" \
390 "again:" \
391 " stosw" \
392 " xchg ax, dx" \
393 " stosw" \
394 " xchg ax, dx" \
395 " dec cx" \
396 " jnz again" \
397 "done:" \
398 parm [es di] [cx] [ax dx]\
399 modify exact [cx di];
400#else
401# pragma aux ASMMemFill32 = \
402 "and ecx, 0ffffh" /* probably not necessary, lazy bird should check... */ \
403 "shr ecx, 2" \
404 "shl eax, 16" \
405 "mov ax, dx" \
406 "rol eax, 16" \
407 "rep stosd" \
408 parm [es di] [cx] [ax dx]\
409 modify exact [ax cx di];
410#endif
411
412#undef ASMProbeReadByte
413#pragma aux ASMProbeReadByte = \
414 "mov al, es:[bx]" \
415 parm [es bx] \
416 value [al] \
417 modify exact [al];
418
419#undef ASMBitSet
420#if defined(__SW_0) || defined(__SW_1) || defined(__SW_2)
421# pragma aux ASMBitSet = \
422 " mov ch, cl" /* Only the three lowest bits are relevant due to 64KB segments */ \
423 " mov cl, 5" \
424 " shl ch, cl" \
425 " add bh, ch" /* Adjust the pointer. */ \
426 " mov cl, al" \
427 " shr ax, 1" /* convert to byte offset */ \
428 " shr ax, 1" \
429 " shr ax, 1" \
430 " add bx, ax" /* adjust pointer again */\
431 " and cl, 7" \
432 " mov al, 1" \
433 " shl al, cl" /* al=bitmask */ \
434 " or es:[bx], al" \
435 parm [es bx] [ax cx] \
436 modify exact [ax bx cx];
437#else
438# pragma aux ASMBitSet = \
439 "shl edx, 16" \
440 "mov dx, ax" \
441 "bts es:[bx], edx" \
442 parm [es bx] [ax dx] \
443 modify exact [dx];
444#endif
445
446#undef ASMAtomicBitSet
447#pragma aux ASMAtomicBitSet = \
448 ".386" \
449 "shl edx, 16" \
450 "mov dx, ax" \
451 "lock bts es:[bx], edx" \
452 parm [es bx] [ax dx] \
453 modify exact [dx];
454
455#undef ASMBitClear
456#if defined(__SW_0) || defined(__SW_1) || defined(__SW_2)
457# pragma aux ASMBitClear = \
458 " mov ch, cl" /* Only the three lowest bits are relevant due to 64KB segments */ \
459 " mov cl, 5" \
460 " shl ch, cl" \
461 " add bh, ch" /* Adjust the pointer. */ \
462 " mov cl, al" \
463 " shr ax, 1" /* convert to byte offset */ \
464 " shr ax, 1" \
465 " shr ax, 1" \
466 " add bx, ax" /* adjust pointer again */\
467 " and cl, 7" \
468 " mov al, 1" \
469 " shl al, cl" \
470 " not al" /* al=bitmask */ \
471 " and es:[bx], al" \
472 parm [es bx] [ax cx] \
473 modify exact [ax bx cx];
474#else
475# pragma aux ASMBitClear = \
476 "shl edx, 16" \
477 "mov dx, ax" \
478 "btr es:[bx], edx" \
479 parm [es bx] [ax dx] \
480 modify exact [dx];
481#endif
482
483#undef ASMAtomicBitClear
484#pragma aux ASMAtomicBitClear = \
485 ".386" \
486 "shl edx, 16" \
487 "mov dx, ax" \
488 "lock btr es:[bx], edx" \
489 parm [es bx] [ax dx] \
490 modify exact [dx];
491
492#undef ASMBitToggle
493#if defined(__SW_0) || defined(__SW_1) || defined(__SW_2)
494# pragma aux ASMBitToggle = \
495 " mov ch, cl" /* Only the three lowest bits are relevant due to 64KB segments */ \
496 " mov cl, 5" \
497 " shl ch, cl" \
498 " add bh, ch" /* Adjust the pointer. */ \
499 " mov cl, al" \
500 " shr ax, 1" /* convert to byte offset */ \
501 " shr ax, 1" \
502 " shr ax, 1" \
503 " add bx, ax" /* adjust pointer again */\
504 " and cl, 7" \
505 " mov al, 1" \
506 " shl al, cl" /* al=bitmask */ \
507 " xor es:[bx], al" \
508 parm [es bx] [ax cx] \
509 modify exact [ax bx cx];
510#else
511# pragma aux ASMBitToggle = \
512 "shl edx, 16" \
513 "mov dx, ax" \
514 "btc es:[bx], edx" \
515 parm [es bx] [ax dx] \
516 modify exact [dx];
517#endif
518
519#undef ASMAtomicBitToggle
520#pragma aux ASMAtomicBitToggle = \
521 ".386" \
522 "shl edx, 16" \
523 "mov dx, ax" \
524 "lock btc es:[bx], edx" \
525 parm [es bx] [ax dx] \
526 modify exact [dx];
527
528#undef ASMBitTestAndSet
529#if defined(__SW_0) || defined(__SW_1) || defined(__SW_2)
530# pragma aux ASMBitTestAndSet = \
531 " mov ch, cl" /* Only the three lowest bits are relevant due to 64KB segments */ \
532 " mov cl, 5" \
533 " shl ch, cl" \
534 " add bh, ch" /* Adjust the pointer. */ \
535 " mov cl, al" \
536 " shr ax, 1" /* convert to byte offset */ \
537 " shr ax, 1" \
538 " shr ax, 1" \
539 " add bx, ax" /* adjust pointer again */\
540 " and cl, 7" /* cl=byte shift count */ \
541 " mov ah, 1" \
542 " shl ah, cl" /* ah=bitmask */ \
543 " mov al, es:[bx]" \
544 " or ah, al" \
545 " mov es:[bx], ah" \
546 " shr al, cl" \
547 " and al, 1" \
548 parm [es bx] [ax cx] \
549 value [al] \
550 modify exact [ax bx cx];
551#else
552# pragma aux ASMBitTestAndSet = \
553 "shl edx, 16" \
554 "mov dx, ax" \
555 "bts es:[bx], edx" \
556 "setc al" \
557 parm [es bx] [ax dx] \
558 value [al] \
559 modify exact [ax dx];
560#endif
561
562#undef ASMAtomicBitTestAndSet
563#pragma aux ASMAtomicBitTestAndSet = \
564 ".386" \
565 "shl edx, 16" \
566 "mov dx, ax" \
567 "lock bts es:[bx], edx" \
568 "setc al" \
569 parm [es bx] [ax dx] \
570 value [al] \
571 modify exact [ax dx];
572
573#undef ASMBitTestAndClear
574#if defined(__SW_0) || defined(__SW_1) || defined(__SW_2)
575# pragma aux ASMBitTestAndClear = \
576 " mov ch, cl" /* Only the three lowest bits are relevant due to 64KB segments */ \
577 " mov cl, 5" \
578 " shl ch, cl" \
579 " add bh, ch" /* Adjust the pointer. */ \
580 " mov cl, al" \
581 " shr ax, 1" /* convert to byte offset */ \
582 " shr ax, 1" \
583 " shr ax, 1" \
584 " add bx, ax" /* adjust pointer again */\
585 " and cl, 7" /* cl=byte shift count */ \
586 " mov ah, 1" \
587 " shl ah, cl" \
588 " not ah" /* ah=bitmask */ \
589 " mov al, es:[bx]" \
590 " and ah, al" \
591 " mov es:[bx], ah" \
592 " shr al, cl" \
593 " and al, 1" \
594 parm [es bx] [ax cx] \
595 value [al] \
596 modify exact [ax bx cx];
597#else
598# pragma aux ASMBitTestAndClear = \
599 "shl edx, 16" \
600 "mov dx, ax" \
601 "btr es:[bx], edx" \
602 "setc al" \
603 parm [es bx] [ax dx] \
604 value [al] \
605 modify exact [ax dx];
606#endif
607
608#undef ASMAtomicBitTestAndClear
609#pragma aux ASMAtomicBitTestAndClear = \
610 ".386" \
611 "shl edx, 16" \
612 "mov dx, ax" \
613 "lock btr es:[bx], edx" \
614 "setc al" \
615 parm [es bx] [ax dx] \
616 value [al] \
617 modify exact [ax dx];
618
619#undef ASMBitTestAndToggle
620#if defined(__SW_0) || defined(__SW_1) || defined(__SW_2)
621# pragma aux ASMBitTestAndToggle = \
622 " mov ch, cl" /* Only the three lowest bits are relevant due to 64KB segments */ \
623 " mov cl, 5" \
624 " shl ch, cl" \
625 " add bh, ch" /* Adjust the pointer. */ \
626 " mov cl, al" \
627 " shr ax, 1" /* convert to byte offset */ \
628 " shr ax, 1" \
629 " shr ax, 1" \
630 " add bx, ax" /* adjust pointer again */\
631 " and cl, 7" /* cl=byte shift count */ \
632 " mov ah, 1" \
633 " shl ah, cl" /* ah=bitmask */ \
634 " mov al, es:[bx]" \
635 " xor ah, al" \
636 " mov es:[bx], ah" \
637 " shr al, cl" \
638 " and al, 1" \
639 parm [es bx] [ax cx] \
640 value [al] \
641 modify exact [ax bx cx];
642#else
643# pragma aux ASMBitTestAndToggle = \
644 "shl edx, 16" \
645 "mov dx, ax" \
646 "btc es:[bx], edx" \
647 "setc al" \
648 parm [es bx] [ax dx] \
649 value [al] \
650 modify exact [ax dx];
651#endif
652
653#undef ASMAtomicBitTestAndToggle
654#pragma aux ASMAtomicBitTestAndToggle = \
655 ".386" \
656 "shl edx, 16" \
657 "mov dx, ax" \
658 "lock btc es:[bx], edx" \
659 "setc al" \
660 parm [es bx] [ax dx] \
661 value [al] \
662 modify exact [ax dx];
663
664#undef ASMBitTest
665#if defined(__SW_0) || defined(__SW_1) || defined(__SW_2)
666# pragma aux ASMBitTest = \
667 " mov ch, cl" /* Only the three lowest bits are relevant due to 64KB segments */ \
668 " mov cl, 5" \
669 " shl ch, cl" \
670 " add bh, ch" /* Adjust the pointer. */ \
671 " mov cl, al" \
672 " shr ax, 1" /* convert to byte offset */ \
673 " shr ax, 1" \
674 " shr ax, 1" \
675 " add bx, ax" /* adjust pointer again */\
676 " and cl, 7" \
677 " mov al, es:[bx]" \
678 " shr al, cl" \
679 " and al, 1" \
680 parm [es bx] [ax cx] \
681 value [al] \
682 modify exact [ax bx cx];
683#else
684# pragma aux ASMBitTest = \
685 "shl edx, 16" \
686 "mov dx, ax" \
687 "bt es:[bx], edx" \
688 "setc al" \
689 parm [es bx] [ax dx] nomemory \
690 value [al] \
691 modify exact [ax dx] nomemory;
692#endif
693
694/* ASMBitFirstClear: External file. */
695/* ASMBitNextClear: External file. */
696/* ASMBitFirstSet: External file. */
697/* ASMBitNextSet: External file. */
698
699#if defined(__SW_0) || defined(__SW_1) || defined(__SW_2)
700/* ASMBitFirstSetU32: External file. */
701#else
702# undef ASMBitFirstSetU32
703# pragma aux ASMBitFirstSetU32 = \
704 "shl edx, 16" \
705 "mov dx, ax" \
706 "bsf eax, edx" \
707 "jz not_found" \
708 "inc ax" \
709 "jmp done" \
710 "not_found:" \
711 "xor ax, ax" \
712 "done:" \
713 parm [ax dx] nomemory \
714 value [ax] \
715 modify exact [ax dx] nomemory;
716#endif
717
718#if defined(__SW_0) || defined(__SW_1) || defined(__SW_2)
719/* ASMBitFirstSetU64: External file. */
720#else
721# undef ASMBitFirstSetU64
722# pragma aux ASMBitFirstSetU64 = \
723 ".386" \
724 "shl ecx, 16" \
725 "mov cx, dx" \
726 "bsf ecx, ecx" \
727 "jz not_found_low" \
728 "mov ax, cx" \
729 "inc ax" \
730 "jmp done" \
731 \
732 "not_found_low:" \
733 "shr eax, 16" \
734 "mov ax, bx" \
735 "bsf eax, eax" \
736 "jz not_found_high" \
737 "add ax, 33" \
738 "jmp done" \
739 \
740 "not_found_high:" \
741 "xor ax, ax" \
742 "done:" \
743 parm [dx cx bx ax] nomemory \
744 value [ax] \
745 modify exact [ax cx] nomemory;
746#endif
747
748#if defined(__SW_0) || defined(__SW_1) || defined(__SW_2)
749/* ASMBitFirstSetU16: External file. */
750#else
751# undef ASMBitFirstSetU16
752# pragma aux ASMBitFirstSetU16 = \
753 "bsf ax, ax" \
754 "jz not_found" \
755 "inc ax" \
756 "jmp done" \
757 "not_found:" \
758 "xor ax, ax" \
759 "done:" \
760 parm [ax] nomemory \
761 value [ax] \
762 modify exact [ax] nomemory;
763#endif
764
765#if defined(__SW_0) || defined(__SW_1) || defined(__SW_2)
766/* ASMBitLastSetU32: External file. */
767#else
768# undef ASMBitLastSetU32
769# pragma aux ASMBitLastSetU32 = \
770 "shl edx, 16" \
771 "mov dx, ax" \
772 "bsr eax, edx" \
773 "jz not_found" \
774 "inc ax" \
775 "jmp done" \
776 "not_found:" \
777 "xor ax, ax" \
778 "done:" \
779 parm [ax dx] nomemory \
780 value [ax] \
781 modify exact [ax dx] nomemory;
782#endif
783
784#if defined(__SW_0) || defined(__SW_1) || defined(__SW_2)
785/* ASMBitLastSetU64: External file. */
786#else
787# undef ASMBitLastSetU64
788# pragma aux ASMBitLastSetU64 = \
789 ".386" \
790 "shl ecx, 16" \
791 "mov cx, dx" \
792 "bsf ecx, ecx" \
793 "jz not_found_low" \
794 "mov ax, cx" \
795 "inc ax" \
796 "jmp done" \
797 \
798 "not_found_low:" \
799 "shr eax, 16" \
800 "mov ax, bx" \
801 "bsf eax, eax" \
802 "jz not_found_high" \
803 "add ax, 33" \
804 "jmp done" \
805 \
806 "not_found_high:" \
807 "xor ax, ax" \
808 "done:" \
809 parm [dx cx bx ax] nomemory \
810 value [ax] \
811 modify exact [ax cx] nomemory;
812#endif
813
814#if defined(__SW_0) || defined(__SW_1) || defined(__SW_2)
815/* ASMBitLastSetU16: External file. */
816#else
817# undef ASMBitLastSetU16
818# pragma aux ASMBitLastSetU16 = \
819 "bsr ax, ax" \
820 "jz not_found" \
821 "inc ax" \
822 "jmp done" \
823 "not_found:" \
824 "xor ax, ax" \
825 "done:" \
826 parm [ax] nomemory \
827 value [ax] \
828 modify exact [ax] nomemory;
829#endif
830
831#undef ASMByteSwapU16
832#pragma aux ASMByteSwapU16 = \
833 "xchg al, ah" \
834 parm [ax] nomemory \
835 value [ax] \
836 modify exact [ax] nomemory;
837
838#undef ASMByteSwapU32
839#pragma aux ASMByteSwapU32 = \
840 "xchg dh, al" \
841 "xchg dl, ah" \
842 parm [ax dx] nomemory \
843 value [ax dx] \
844 modify exact [ax dx] nomemory;
845
846#undef ASMRotateLeftU32
847#pragma aux ASMRotateLeftU32 = \
848 ".386" \
849 "shl edx, 16" \
850 "mov dx, ax" \
851 "rol edx, cl" \
852 "mov eax, edx" \
853 "shr edx, 16" \
854 parm [ax dx] [cx] nomemory \
855 value [ax dx] \
856 modify exact [ax dx] nomemory;
857
858#undef ASMRotateRightU32
859#pragma aux ASMRotateRightU32 = \
860 ".386" \
861 "shl edx, 16" \
862 "mov dx, ax" \
863 "ror edx, cl" \
864 "mov eax, edx" \
865 "shr edx, 16" \
866 parm [ax dx] [cx] nomemory \
867 value [ax dx] \
868 modify exact [ax dx] nomemory;
869
870#endif
Note: See TracBrowser for help on using the repository browser.

© 2024 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette