summaryrefslogtreecommitdiffstats
path: root/include/iprt/asm-watcom-x86-32.h
blob: 2332a5211a7542c8fdd7b7980e1416e0c944cd5a (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
/** @file
 * IPRT - Assembly Functions, x86 32-bit Watcom C/C++ pragma aux.
 */

/*
 * Copyright (C) 2006-2023 Oracle and/or its affiliates.
 *
 * This file is part of VirtualBox base platform packages, as
 * available from https://www.virtualbox.org.
 *
 * This program is free software; you can redistribute it and/or
 * modify it under the terms of the GNU General Public License
 * as published by the Free Software Foundation, in version 3 of the
 * License.
 *
 * This program is distributed in the hope that it will be useful, but
 * WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 * General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program; if not, see <https://www.gnu.org/licenses>.
 *
 * The contents of this file may alternatively be used under the terms
 * of the Common Development and Distribution License Version 1.0
 * (CDDL), a copy of it is provided in the "COPYING.CDDL" file included
 * in the VirtualBox distribution, in which case the provisions of the
 * CDDL are applicable instead of those of the GPL.
 *
 * You may elect to license modified versions of this file under the
 * terms and conditions of either the GPL or the CDDL or both.
 *
 * SPDX-License-Identifier: GPL-3.0-only OR CDDL-1.0
 */

#ifndef IPRT_INCLUDED_asm_watcom_x86_32_h
#define IPRT_INCLUDED_asm_watcom_x86_32_h
/* no pragma once */

#ifndef IPRT_INCLUDED_asm_h
# error "Don't include this header directly."
#endif

#ifndef __FLAT__
# error "Only works with flat pointers! (-mf)"
#endif

/*
 * Note! The #undef that preceds the #pragma aux statements is for undoing
 *       the mangling, because the symbol in #pragma aux [symbol] statements
 *       doesn't get subjected to preprocessing.  This is also why we include
 *       the watcom header at both the top and the bottom of asm.h file.
 */

#undef       ASMCompilerBarrier
#ifdef IPRT_ASM_WATCOM_X86_32_WITH_PRAGMAS
# if 0 /* overkill version. */
#  pragma aux ASMCompilerBarrier = \
    "nop" \
    parm [] \
    modify exact [eax ebx ecx edx es ds fs gs];
# else
#  pragma aux ASMCompilerBarrier = \
    "" \
    parm [] \
    modify exact [];
# endif
#endif

#undef      ASMNopPause
#ifdef IPRT_ASM_WATCOM_X86_32_WITH_PRAGMAS
#pragma aux ASMNopPause = \
    ".686p" \
    ".xmm2" \
    "pause" \
    parm [] nomemory \
    modify exact [] nomemory;
#endif

#undef      ASMAtomicXchgU8
#ifdef IPRT_ASM_WATCOM_X86_32_WITH_PRAGMAS
#pragma aux ASMAtomicXchgU8 = \
    "xchg [ecx], al" \
    parm [ecx] [al] \
    value [al] \
    modify exact [al];
#endif

#undef      ASMAtomicXchgU16
#ifdef IPRT_ASM_WATCOM_X86_32_WITH_PRAGMAS
#pragma aux ASMAtomicXchgU16 = \
    "xchg [ecx], ax" \
    parm [ecx] [ax] \
    value [ax] \
    modify exact [ax];
#endif

#undef      ASMAtomicXchgU32
#ifdef IPRT_ASM_WATCOM_X86_32_WITH_PRAGMAS
#pragma aux ASMAtomicXchgU32 = \
    "xchg [ecx], eax" \
    parm [ecx] [eax] \
    value [eax] \
    modify exact [eax];
#endif

#undef      ASMAtomicXchgU64
#ifdef IPRT_ASM_WATCOM_X86_32_WITH_PRAGMAS
#pragma aux ASMAtomicXchgU64 = \
    ".586" \
    "try_again:" \
    "lock cmpxchg8b [esi]" \
    "jnz try_again" \
    parm [esi] [ebx ecx] \
    value [eax edx] \
    modify exact [edx ecx ebx eax];
#endif

#undef      ASMAtomicCmpXchgU8
#ifdef IPRT_ASM_WATCOM_X86_32_WITH_PRAGMAS
#pragma aux ASMAtomicCmpXchgU8 = \
    ".486" \
    "lock cmpxchg [edx], cl" \
    "setz al" \
    parm [edx] [cl] [al] \
    value [al] \
    modify exact [al];
#endif

#undef      ASMAtomicCmpXchgU16
#ifdef IPRT_ASM_WATCOM_X86_32_WITH_PRAGMAS
#pragma aux ASMAtomicCmpXchgU16 = \
    ".486" \
    "lock cmpxchg [edx], cx" \
    "setz al" \
    parm [edx] [cx] [ax] \
    value [al] \
    modify exact [ax];
#endif

#undef      ASMAtomicCmpXchgU32
#ifdef IPRT_ASM_WATCOM_X86_32_WITH_PRAGMAS
#pragma aux ASMAtomicCmpXchgU32 = \
    ".486" \
    "lock cmpxchg [edx], ecx" \
    "setz al" \
    parm [edx] [ecx] [eax] \
    value [al] \
    modify exact [eax];
#endif

#undef      ASMAtomicCmpXchgU64
#ifdef IPRT_ASM_WATCOM_X86_32_WITH_PRAGMAS
#pragma aux ASMAtomicCmpXchgU64 = \
    ".586" \
    "lock cmpxchg8b [edi]" \
    "setz al" \
    parm [edi] [ebx ecx] [eax edx] \
    value [al] \
    modify exact [eax edx];
#endif

#undef      ASMAtomicCmpXchgExU32
#ifdef IPRT_ASM_WATCOM_X86_32_WITH_PRAGMAS
#pragma aux ASMAtomicCmpXchgExU32 = \
    ".586" \
    "lock cmpxchg [edx], ecx" \
    "mov [edi], eax" \
    "setz al" \
    parm [edx] [ecx] [eax] [edi] \
    value [al] \
    modify exact [eax];
#endif

#undef      ASMAtomicCmpXchgExU64
#ifdef IPRT_ASM_WATCOM_X86_32_WITH_PRAGMAS
#pragma aux ASMAtomicCmpXchgExU64 = \
    ".586" \
    "lock cmpxchg8b [edi]" \
    "mov [esi], eax" \
    "mov [esi + 4], edx" \
    "setz al" \
    parm [edi] [ebx ecx] [eax edx] [esi] \
    value [al] \
    modify exact [eax edx];
#endif

#undef      ASMSerializeInstructionCpuId
#ifdef IPRT_ASM_WATCOM_X86_32_WITH_PRAGMAS
#pragma aux ASMSerializeInstructionCpuId = \
    ".586" \
    "xor eax, eax" \
    "cpuid" \
    parm [] \
    modify exact [eax ebx ecx edx];
#endif

#undef ASMSerializeInstructionIRet
#ifdef IPRT_ASM_WATCOM_X86_32_WITH_PRAGMAS
#pragma aux ASMSerializeInstructionIRet = \
    "pushf" \
    "push cs" \
    "call foo" /* 'push offset done' doesn't work */ \
    "jmp  done" \
    "foo:" \
    "iret" \
    "done:" \
    parm [] \
    modify exact [];
#endif

#undef      ASMSerializeInstructionRdTscp
#ifdef IPRT_ASM_WATCOM_X86_32_WITH_PRAGMAS
#pragma aux ASMSerializeInstructionRdTscp = \
    0x0f 0x01 0xf9 \
    parm [] \
    modify exact [eax edx ecx];
#endif

#undef      ASMAtomicReadU64
#ifdef IPRT_ASM_WATCOM_X86_32_WITH_PRAGMAS
#pragma aux ASMAtomicReadU64 = \
    ".586" \
    "xor eax, eax" \
    "mov edx, eax" \
    "mov ebx, eax" \
    "mov ecx, eax" \
    "lock cmpxchg8b [edi]" \
    parm [edi] \
    value [eax edx] \
    modify exact [eax ebx ecx edx];
#endif

#undef      ASMAtomicUoReadU64
#ifdef IPRT_ASM_WATCOM_X86_32_WITH_PRAGMAS
#pragma aux ASMAtomicUoReadU64 = \
    ".586" \
    "xor eax, eax" \
    "mov edx, eax" \
    "mov ebx, eax" \
    "mov ecx, eax" \
    "lock cmpxchg8b [edi]" \
    parm [edi] \
    value [eax edx] \
    modify exact [eax ebx ecx edx];
#endif

#undef      ASMAtomicAddU16
#ifdef IPRT_ASM_WATCOM_X86_32_WITH_PRAGMAS
#pragma aux ASMAtomicAddU16 = \
    ".486" \
    "lock xadd [ecx], ax" \
    parm [ecx] [ax] \
    value [ax] \
    modify exact [ax];
#endif

#undef      ASMAtomicAddU32
#ifdef IPRT_ASM_WATCOM_X86_32_WITH_PRAGMAS
#pragma aux ASMAtomicAddU32 = \
    ".486" \
    "lock xadd [ecx], eax" \
    parm [ecx] [eax] \
    value [eax] \
    modify exact [eax];
#endif

#undef      ASMAtomicIncU16
#ifdef IPRT_ASM_WATCOM_X86_32_WITH_PRAGMAS
#pragma aux ASMAtomicIncU16 = \
    ".486" \
    "mov ax, 1" \
    "lock xadd [ecx], ax" \
    "inc ax" \
    parm [ecx] \
    value [ax] \
    modify exact [ax];
#endif

#undef      ASMAtomicIncU32
#ifdef IPRT_ASM_WATCOM_X86_32_WITH_PRAGMAS
#pragma aux ASMAtomicIncU32 = \
    ".486" \
    "mov eax, 1" \
    "lock xadd [ecx], eax" \
    "inc eax" \
    parm [ecx] \
    value [eax] \
    modify exact [eax];
#endif

/* ASMAtomicIncU64: Should be done by C inline or in external file. */

#undef      ASMAtomicDecU16
#ifdef IPRT_ASM_WATCOM_X86_32_WITH_PRAGMAS
#pragma aux ASMAtomicDecU16 = \
    ".486" \
    "mov ax, 0ffffh" \
    "lock xadd [ecx], ax" \
    "dec ax" \
    parm [ecx] \
    value [ax] \
    modify exact [ax];
#endif

#undef      ASMAtomicDecU32
#ifdef IPRT_ASM_WATCOM_X86_32_WITH_PRAGMAS
#pragma aux ASMAtomicDecU32 = \
    ".486" \
    "mov eax, 0ffffffffh" \
    "lock xadd [ecx], eax" \
    "dec eax" \
    parm [ecx] \
    value [eax] \
    modify exact [eax];
#endif

/* ASMAtomicDecU64: Should be done by C inline or in external file. */

#undef      ASMAtomicOrU32
#ifdef IPRT_ASM_WATCOM_X86_32_WITH_PRAGMAS
#pragma aux ASMAtomicOrU32 = \
    "lock or [ecx], eax" \
    parm [ecx] [eax] \
    modify exact [];
#endif

/* ASMAtomicOrU64: Should be done by C inline or in external file. */

#undef      ASMAtomicAndU32
#ifdef IPRT_ASM_WATCOM_X86_32_WITH_PRAGMAS
#pragma aux ASMAtomicAndU32 = \
    "lock and [ecx], eax" \
    parm [ecx] [eax] \
    modify exact [];
#endif

/* ASMAtomicAndU64: Should be done by C inline or in external file. */

#undef      ASMAtomicUoOrU32
#ifdef IPRT_ASM_WATCOM_X86_32_WITH_PRAGMAS
#pragma aux ASMAtomicUoOrU32 = \
    "or [ecx], eax" \
    parm [ecx] [eax] \
    modify exact [];
#endif

/* ASMAtomicUoOrU64: Should be done by C inline or in external file. */

#undef      ASMAtomicUoAndU32
#ifdef IPRT_ASM_WATCOM_X86_32_WITH_PRAGMAS
#pragma aux ASMAtomicUoAndU32 = \
    "and [ecx], eax" \
    parm [ecx] [eax] \
    modify exact [];
#endif

/* ASMAtomicUoAndU64: Should be done by C inline or in external file. */

#undef      ASMAtomicUoIncU32
#ifdef IPRT_ASM_WATCOM_X86_32_WITH_PRAGMAS
#pragma aux ASMAtomicUoIncU32 = \
    ".486" \
    "xadd [ecx], eax" \
    "inc eax" \
    parm [ecx] \
    value [eax] \
    modify exact [eax];
#endif

#undef      ASMAtomicUoDecU32
#ifdef IPRT_ASM_WATCOM_X86_32_WITH_PRAGMAS
#pragma aux ASMAtomicUoDecU32 = \
    ".486" \
    "mov eax, 0ffffffffh" \
    "xadd [ecx], eax" \
    "dec eax" \
    parm [ecx] \
    value [eax] \
    modify exact [eax];
#endif

#undef      ASMMemZeroPage
#ifdef IPRT_ASM_WATCOM_X86_32_WITH_PRAGMAS
#pragma aux ASMMemZeroPage = \
    "mov ecx, 1024" \
    "xor eax, eax" \
    "rep stosd"  \
    parm [edi] \
    modify exact [eax ecx edi];
#endif

#undef      ASMMemZero32
#ifdef IPRT_ASM_WATCOM_X86_32_WITH_PRAGMAS
#pragma aux ASMMemZero32 = \
    "shr ecx, 2" \
    "xor eax, eax" \
    "rep stosd"  \
    parm [edi] [ecx] \
    modify exact [eax ecx edi];
#endif

#undef      ASMMemFill32
#ifdef IPRT_ASM_WATCOM_X86_32_WITH_PRAGMAS
#pragma aux ASMMemFill32 = \
    "shr ecx, 2" \
    "rep stosd"  \
    parm [edi] [ecx] [eax]\
    modify exact [ecx edi];
#endif

#undef      ASMProbeReadByte
#ifdef IPRT_ASM_WATCOM_X86_32_WITH_PRAGMAS
#pragma aux ASMProbeReadByte = \
    "mov al, [ecx]" \
    parm [ecx] \
    value [al] \
    modify exact [al];
#endif

#undef      ASMBitSet
#ifdef IPRT_ASM_WATCOM_X86_32_WITH_PRAGMAS
#pragma aux ASMBitSet = \
    "bts [ecx], eax" \
    parm [ecx] [eax] \
    modify exact [];
#endif

#undef      ASMAtomicBitSet
#ifdef IPRT_ASM_WATCOM_X86_32_WITH_PRAGMAS
#pragma aux ASMAtomicBitSet = \
    "lock bts [ecx], eax" \
    parm [ecx] [eax] \
    modify exact [];
#endif

#undef      ASMBitClear
#ifdef IPRT_ASM_WATCOM_X86_32_WITH_PRAGMAS
#pragma aux ASMBitClear = \
    "btr [ecx], eax" \
    parm [ecx] [eax] \
    modify exact [];
#endif

#undef      ASMAtomicBitClear
#ifdef IPRT_ASM_WATCOM_X86_32_WITH_PRAGMAS
#pragma aux ASMAtomicBitClear = \
    "lock btr [ecx], eax" \
    parm [ecx] [eax] \
    modify exact [];
#endif

#undef      ASMBitToggle
#ifdef IPRT_ASM_WATCOM_X86_32_WITH_PRAGMAS
#pragma aux ASMBitToggle = \
    "btc [ecx], eax" \
    parm [ecx] [eax] \
    modify exact [];
#endif

#undef      ASMAtomicBitToggle
#ifdef IPRT_ASM_WATCOM_X86_32_WITH_PRAGMAS
#pragma aux ASMAtomicBitToggle = \
    "lock btc [ecx], eax" \
    parm [ecx] [eax] \
    modify exact [];
#endif


#undef      ASMBitTestAndSet
#ifdef IPRT_ASM_WATCOM_X86_32_WITH_PRAGMAS
#pragma aux ASMBitTestAndSet = \
    "bts [ecx], eax" \
    "setc al" \
    parm [ecx] [eax] \
    value [al] \
    modify exact [eax];
#endif

#undef      ASMAtomicBitTestAndSet
#ifdef IPRT_ASM_WATCOM_X86_32_WITH_PRAGMAS
#pragma aux ASMAtomicBitTestAndSet = \
    "lock bts [ecx], eax" \
    "setc al" \
    parm [ecx] [eax] \
    value [al] \
    modify exact [eax];
#endif

#undef      ASMBitTestAndClear
#ifdef IPRT_ASM_WATCOM_X86_32_WITH_PRAGMAS
#pragma aux ASMBitTestAndClear = \
    "btr [ecx], eax" \
    "setc al" \
    parm [ecx] [eax] \
    value [al] \
    modify exact [eax];
#endif

#undef      ASMAtomicBitTestAndClear
#ifdef IPRT_ASM_WATCOM_X86_32_WITH_PRAGMAS
#pragma aux ASMAtomicBitTestAndClear = \
    "lock btr [ecx], eax" \
    "setc al" \
    parm [ecx] [eax] \
    value [al] \
    modify exact [eax];
#endif

#undef      ASMBitTestAndToggle
#ifdef IPRT_ASM_WATCOM_X86_32_WITH_PRAGMAS
#pragma aux ASMBitTestAndToggle = \
    "btc [ecx], eax" \
    "setc al" \
    parm [ecx] [eax] \
    value [al] \
    modify exact [eax];
#endif

#undef      ASMAtomicBitTestAndToggle
#ifdef IPRT_ASM_WATCOM_X86_32_WITH_PRAGMAS
#pragma aux ASMAtomicBitTestAndToggle = \
    "lock btc [ecx], eax" \
    "setc al" \
    parm [ecx] [eax] \
    value [al] \
    modify exact [eax];
#endif

#undef      ASMBitTest
#ifdef IPRT_ASM_WATCOM_X86_32_WITH_PRAGMAS
#pragma aux ASMBitTest = \
    "bt  [ecx], eax" \
    "setc al" \
    parm [ecx] [eax] nomemory \
    value [al] \
    modify exact [eax] nomemory;
#endif

#if 0
/** @todo this is way to much inline assembly, better off in an external function. */
#undef      ASMBitFirstClear
#ifdef IPRT_ASM_WATCOM_X86_32_WITH_PRAGMAS
#pragma aux ASMBitFirstClear = \
    "mov edx, edi" /* save start of bitmap for later */ \
    "add ecx, 31" \
    "shr ecx, 5" /* cDWord = RT_ALIGN_32(cBits, 32) / 32; */  \
    "mov eax, 0ffffffffh" \
    "repe scasd" \
    "je done" \
    "lea edi, [edi - 4]" /* rewind edi */ \
    "xor eax, [edi]" /* load inverted bits */ \
    "sub edi, edx" /* calc byte offset */ \
    "shl edi, 3" /* convert byte to bit offset */ \
    "mov edx, eax" \
    "bsf eax, edx" \
    "add eax, edi" \
    "done:" \
    parm [edi] [ecx] \
    value [eax] \
    modify exact [eax ecx edx edi];
#endif

/* ASMBitNextClear: Too much work, do when needed. */

/** @todo this is way to much inline assembly, better off in an external function. */
#undef      ASMBitFirstSet
#ifdef IPRT_ASM_WATCOM_X86_32_WITH_PRAGMAS
#pragma aux ASMBitFirstSet = \
    "mov edx, edi" /* save start of bitmap for later */ \
    "add ecx, 31" \
    "shr ecx, 5" /* cDWord = RT_ALIGN_32(cBits, 32) / 32; */  \
    "mov eax, 0ffffffffh" \
    "repe scasd" \
    "je done" \
    "lea edi, [edi - 4]" /* rewind edi */ \
    "mov eax, [edi]" /* reload previous dword */ \
    "sub edi, edx" /* calc byte offset */ \
    "shl edi, 3" /* convert byte to bit offset */ \
    "mov edx, eax" \
    "bsf eax, edx" \
    "add eax, edi" \
    "done:" \
    parm [edi] [ecx] \
    value [eax] \
    modify exact [eax ecx edx edi];
#endif

/* ASMBitNextSet: Too much work, do when needed. */
#else
/* ASMBitFirstClear: External file.  */
/* ASMBitNextClear:  External file.  */
/* ASMBitFirstSet:   External file.  */
/* ASMBitNextSet:    External file.  */
#endif

#undef      ASMBitFirstSetU32
#ifdef IPRT_ASM_WATCOM_X86_32_WITH_PRAGMAS
#pragma aux ASMBitFirstSetU32 = \
    "bsf eax, eax" \
    "jz  not_found" \
    "inc eax" \
    "jmp done" \
    "not_found:" \
    "xor eax, eax" \
    "done:" \
    parm [eax] nomemory \
    value [eax] \
    modify exact [eax] nomemory;
#endif

#undef      ASMBitFirstSetU64
#ifdef IPRT_ASM_WATCOM_X86_32_WITH_PRAGMAS
#pragma aux ASMBitFirstSetU64 = \
    "bsf eax, eax" \
    "jz  not_found_low" \
    "inc eax" \
    "jmp done" \
    \
    "not_found_low:" \
    "bsf eax, edx" \
    "jz  not_found_high" \
    "add eax, 33" \
    "jmp done" \
    \
    "not_found_high:" \
    "xor eax, eax" \
    "done:" \
    parm [eax edx] nomemory \
    value [eax] \
    modify exact [eax] nomemory;
#endif

#undef      ASMBitFirstSetU16
#ifdef IPRT_ASM_WATCOM_X86_32_WITH_PRAGMAS
#pragma aux ASMBitFirstSetU16 = \
    "movzx eax, ax" \
    "bsf eax, eax" \
    "jz  not_found" \
    "inc eax" \
    "jmp done" \
    "not_found:" \
    "xor eax, eax" \
    "done:" \
    parm [ax] nomemory \
    value [eax] \
    modify exact [eax] nomemory;
#endif

#undef      ASMBitLastSetU32
#ifdef IPRT_ASM_WATCOM_X86_32_WITH_PRAGMAS
#pragma aux ASMBitLastSetU32 = \
    "bsr eax, eax" \
    "jz  not_found" \
    "inc eax" \
    "jmp done" \
    "not_found:" \
    "xor eax, eax" \
    "done:" \
    parm [eax] nomemory \
    value [eax] \
    modify exact [eax] nomemory;
#endif

#undef      ASMBitLastSetU64
#ifdef IPRT_ASM_WATCOM_X86_32_WITH_PRAGMAS
#pragma aux ASMBitLastSetU64 = \
    "xchg eax, edx" \
    "bsr eax, eax" \
    "jz  not_found_high" \
    "add eax, 33" \
    "jmp done" \
    \
    "not_found_high:" \
    "bsr eax, edx" \
    "jz  not_found" \
    "inc eax" \
    "jmp done" \
    \
    "not_found:" \
    "xor eax, eax" \
    "done:" \
    parm [eax edx] nomemory \
    value [eax] \
    modify exact [eax edx] nomemory;
#endif

#undef      ASMBitLastSetU16
#ifdef IPRT_ASM_WATCOM_X86_32_WITH_PRAGMAS
#pragma aux ASMBitLastSetU16 = \
    "movzx eax, ax" \
    "bsr eax, eax" \
    "jz  not_found" \
    "inc eax" \
    "jmp done" \
    "not_found:" \
    "xor eax, eax" \
    "done:" \
    parm [ax] nomemory \
    value [eax] \
    modify exact [eax] nomemory;
#endif

#undef      ASMByteSwapU16
#ifdef IPRT_ASM_WATCOM_X86_32_WITH_PRAGMAS
#pragma aux ASMByteSwapU16 = \
    "ror ax, 8" \
    parm [ax] nomemory \
    value [ax] \
    modify exact [ax] nomemory;
#endif

#undef      ASMByteSwapU32
#ifdef IPRT_ASM_WATCOM_X86_32_WITH_PRAGMAS
#pragma aux ASMByteSwapU32 = \
    "bswap eax" \
    parm [eax] nomemory \
    value [eax] \
    modify exact [eax] nomemory;
#endif

#undef      ASMRotateLeftU32
#ifdef IPRT_ASM_WATCOM_X86_32_WITH_PRAGMAS
#pragma aux ASMRotateLeftU32 = \
    "rol    eax, cl" \
    parm [eax] [ecx] nomemory \
    value [eax] \
    modify exact [eax] nomemory;
#endif

#undef      ASMRotateRightU32
#ifdef IPRT_ASM_WATCOM_X86_32_WITH_PRAGMAS
#pragma aux ASMRotateRightU32 = \
    "ror    eax, cl" \
    parm [eax] [ecx] nomemory \
    value [eax] \
    modify exact [eax] nomemory;
#endif

#endif /* !IPRT_INCLUDED_asm_watcom_x86_32_h */