1 /****************************************************************************
3 * Realmode X86 Emulator Library
5 * Copyright (C) 1996-1999 SciTech Software, Inc.
6 * Copyright (C) David Mosberger-Tang
7 * Copyright (C) 1999 Egbert Eich
9 * ========================================================================
11 * Permission to use, copy, modify, distribute, and sell this software and
12 * its documentation for any purpose is hereby granted without fee,
13 * provided that the above copyright notice appear in all copies and that
14 * both that copyright notice and this permission notice appear in
15 * supporting documentation, and that the name of the authors not be used
16 * in advertising or publicity pertaining to distribution of the software
17 * without specific, written prior permission. The authors makes no
18 * representations about the suitability of this software for any purpose.
19 * It is provided "as is" without express or implied warranty.
21 * THE AUTHORS DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
22 * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
23 * EVENT SHALL THE AUTHORS BE LIABLE FOR ANY SPECIAL, INDIRECT OR
24 * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF
25 * USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
26 * OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
27 * PERFORMANCE OF THIS SOFTWARE.
29 * ========================================================================
33 * Developer: Kendall Bennett
35 * Description: This file includes subroutines to implement the decoding
36 * and emulation of all the x86 extended two-byte processor
39 ****************************************************************************/
41 #include "x86emu/x86emui.h"
44 #define bswap_32(x) (((x & 0xff000000) >> 24) | \
45 ((x & 0x00ff0000) >> 8) | \
46 ((x & 0x0000ff00) << 8) | \
47 ((x & 0x000000ff) << 24))
49 /*----------------------------- Implementation ----------------------------*/
51 /****************************************************************************
53 op1 - Instruction op code
56 Handles illegal opcodes.
57 ****************************************************************************/
59 x86emuOp2_illegal_op(u8 op2
)
62 DECODE_PRINTF("ILLEGAL EXTENDED X86 OPCODE\n");
64 printk("%04x:%04x: %02X ILLEGAL EXTENDED X86 OPCODE!\n",
65 M
.x86
.R_CS
, M
.x86
.R_IP
- 2, op2
);
70 #define xorl(a,b) ((a) && !(b)) || (!(a) && (b))
72 /****************************************************************************
74 Handles opcode 0x0f,0x31
75 ****************************************************************************/
77 x86emuOp2_rdtsc(u8
X86EMU_UNUSED(op2
))
79 #ifdef __HAS_LONG_LONG__
80 static u64 counter
= 0;
82 static u32 counter
= 0;
87 /* read timestamp counter */
89 * Note that instead of actually trying to accurately measure this, we just
90 * increase the counter by a fixed amount every time we hit one of these
91 * instructions. Feel free to come up with a better method.
94 DECODE_PRINTF("RDTSC\n");
96 #ifdef __HAS_LONG_LONG__
97 M
.x86
.R_EAX
= counter
& 0xffffffff;
98 M
.x86
.R_EDX
= counter
>> 32;
100 M
.x86
.R_EAX
= counter
;
103 DECODE_CLEAR_SEGOVR();
107 /****************************************************************************
109 Handles opcode 0x0f,0x80-0x8F
110 ****************************************************************************/
112 x86emuOp2_long_jump(u8 op2
)
115 const char *name
= NULL
;
118 /* conditional jump to word offset. */
123 cond
= ACCESS_FLAG(F_OF
);
127 cond
= !ACCESS_FLAG(F_OF
);
131 cond
= ACCESS_FLAG(F_CF
);
135 cond
= !ACCESS_FLAG(F_CF
);
139 cond
= ACCESS_FLAG(F_ZF
);
143 cond
= !ACCESS_FLAG(F_ZF
);
147 cond
= ACCESS_FLAG(F_CF
) || ACCESS_FLAG(F_ZF
);
151 cond
= !(ACCESS_FLAG(F_CF
) || ACCESS_FLAG(F_ZF
));
155 cond
= ACCESS_FLAG(F_SF
);
159 cond
= !ACCESS_FLAG(F_SF
);
163 cond
= ACCESS_FLAG(F_PF
);
167 cond
= !ACCESS_FLAG(F_PF
);
171 cond
= xorl(ACCESS_FLAG(F_SF
), ACCESS_FLAG(F_OF
));
175 cond
= !(xorl(ACCESS_FLAG(F_SF
), ACCESS_FLAG(F_OF
)));
179 cond
= (xorl(ACCESS_FLAG(F_SF
), ACCESS_FLAG(F_OF
)) ||
184 cond
= !(xorl(ACCESS_FLAG(F_SF
), ACCESS_FLAG(F_OF
)) ||
190 target
= (s16
) fetch_word_imm();
191 target
+= (s16
) M
.x86
.R_IP
;
192 DECODE_PRINTF2("%04x\n", target
);
195 M
.x86
.R_IP
= (u16
) target
;
196 DECODE_CLEAR_SEGOVR();
200 /****************************************************************************
202 Handles opcode 0x0f,0x90-0x9F
203 ****************************************************************************/
205 x86emuOp2_set_byte(u8 op2
)
210 const char *name
= NULL
;
217 cond
= ACCESS_FLAG(F_OF
);
221 cond
= !ACCESS_FLAG(F_OF
);
225 cond
= ACCESS_FLAG(F_CF
);
229 cond
= !ACCESS_FLAG(F_CF
);
233 cond
= ACCESS_FLAG(F_ZF
);
237 cond
= !ACCESS_FLAG(F_ZF
);
241 cond
= ACCESS_FLAG(F_CF
) || ACCESS_FLAG(F_ZF
);
245 cond
= !(ACCESS_FLAG(F_CF
) || ACCESS_FLAG(F_ZF
));
249 cond
= ACCESS_FLAG(F_SF
);
253 cond
= !ACCESS_FLAG(F_SF
);
257 cond
= ACCESS_FLAG(F_PF
);
261 cond
= !ACCESS_FLAG(F_PF
);
265 cond
= xorl(ACCESS_FLAG(F_SF
), ACCESS_FLAG(F_OF
));
269 cond
= xorl(ACCESS_FLAG(F_SF
), ACCESS_FLAG(F_OF
));
273 cond
= (xorl(ACCESS_FLAG(F_SF
), ACCESS_FLAG(F_OF
)) ||
278 cond
= !(xorl(ACCESS_FLAG(F_SF
), ACCESS_FLAG(F_OF
)) ||
284 FETCH_DECODE_MODRM(mod
, rh
, rl
);
287 destoffset
= decode_rm00_address(rl
);
289 store_data_byte(destoffset
, cond
? 0x01 : 0x00);
292 destoffset
= decode_rm01_address(rl
);
294 store_data_byte(destoffset
, cond
? 0x01 : 0x00);
297 destoffset
= decode_rm10_address(rl
);
299 store_data_byte(destoffset
, cond
? 0x01 : 0x00);
301 case 3: /* register to register */
302 destreg
= DECODE_RM_BYTE_REGISTER(rl
);
304 *destreg
= cond
? 0x01 : 0x00;
307 DECODE_CLEAR_SEGOVR();
311 /****************************************************************************
313 Handles opcode 0x0f,0xa0
314 ****************************************************************************/
316 x86emuOp2_push_FS(u8
X86EMU_UNUSED(op2
))
319 DECODE_PRINTF("PUSH\tFS\n");
321 push_word(M
.x86
.R_FS
);
322 DECODE_CLEAR_SEGOVR();
326 /****************************************************************************
328 Handles opcode 0x0f,0xa1
329 ****************************************************************************/
331 x86emuOp2_pop_FS(u8
X86EMU_UNUSED(op2
))
334 DECODE_PRINTF("POP\tFS\n");
336 M
.x86
.R_FS
= pop_word();
337 DECODE_CLEAR_SEGOVR();
341 /****************************************************************************
342 REMARKS: CPUID takes EAX/ECX as inputs, writes EAX/EBX/ECX/EDX as output
343 Handles opcode 0x0f,0xa2
344 ****************************************************************************/
346 x86emuOp2_cpuid(u8
X86EMU_UNUSED(op2
))
349 DECODE_PRINTF("CPUID\n");
352 DECODE_CLEAR_SEGOVR();
356 /****************************************************************************
358 Handles opcode 0x0f,0xa3
359 ****************************************************************************/
361 x86emuOp2_bt_R(u8
X86EMU_UNUSED(op2
))
368 DECODE_PRINTF("BT\t");
369 FETCH_DECODE_MODRM(mod
, rh
, rl
);
372 if (M
.x86
.mode
& SYSMODE_PREFIX_DATA
) {
376 srcoffset
= decode_rm00_address(rl
);
378 shiftreg
= DECODE_RM_LONG_REGISTER(rh
);
380 bit
= *shiftreg
& 0x1F;
381 disp
= (s16
) * shiftreg
>> 5;
382 srcval
= fetch_data_long(srcoffset
+ disp
);
383 CONDITIONAL_SET_FLAG(srcval
& (0x1 << bit
), F_CF
);
389 srcoffset
= decode_rm00_address(rl
);
391 shiftreg
= DECODE_RM_WORD_REGISTER(rh
);
393 bit
= *shiftreg
& 0xF;
394 disp
= (s16
) * shiftreg
>> 4;
395 srcval
= fetch_data_word(srcoffset
+ disp
);
396 CONDITIONAL_SET_FLAG(srcval
& (0x1 << bit
), F_CF
);
400 if (M
.x86
.mode
& SYSMODE_PREFIX_DATA
) {
404 srcoffset
= decode_rm01_address(rl
);
406 shiftreg
= DECODE_RM_LONG_REGISTER(rh
);
408 bit
= *shiftreg
& 0x1F;
409 disp
= (s16
) * shiftreg
>> 5;
410 srcval
= fetch_data_long(srcoffset
+ disp
);
411 CONDITIONAL_SET_FLAG(srcval
& (0x1 << bit
), F_CF
);
417 srcoffset
= decode_rm01_address(rl
);
419 shiftreg
= DECODE_RM_WORD_REGISTER(rh
);
421 bit
= *shiftreg
& 0xF;
422 disp
= (s16
) * shiftreg
>> 4;
423 srcval
= fetch_data_word(srcoffset
+ disp
);
424 CONDITIONAL_SET_FLAG(srcval
& (0x1 << bit
), F_CF
);
428 if (M
.x86
.mode
& SYSMODE_PREFIX_DATA
) {
432 srcoffset
= decode_rm10_address(rl
);
434 shiftreg
= DECODE_RM_LONG_REGISTER(rh
);
436 bit
= *shiftreg
& 0x1F;
437 disp
= (s16
) * shiftreg
>> 5;
438 srcval
= fetch_data_long(srcoffset
+ disp
);
439 CONDITIONAL_SET_FLAG(srcval
& (0x1 << bit
), F_CF
);
445 srcoffset
= decode_rm10_address(rl
);
447 shiftreg
= DECODE_RM_WORD_REGISTER(rh
);
449 bit
= *shiftreg
& 0xF;
450 disp
= (s16
) * shiftreg
>> 4;
451 srcval
= fetch_data_word(srcoffset
+ disp
);
452 CONDITIONAL_SET_FLAG(srcval
& (0x1 << bit
), F_CF
);
455 case 3: /* register to register */
456 if (M
.x86
.mode
& SYSMODE_PREFIX_DATA
) {
457 u32
*srcreg
, *shiftreg
;
459 srcreg
= DECODE_RM_LONG_REGISTER(rl
);
461 shiftreg
= DECODE_RM_LONG_REGISTER(rh
);
463 bit
= *shiftreg
& 0x1F;
464 CONDITIONAL_SET_FLAG(*srcreg
& (0x1 << bit
), F_CF
);
467 u16
*srcreg
, *shiftreg
;
469 srcreg
= DECODE_RM_WORD_REGISTER(rl
);
471 shiftreg
= DECODE_RM_WORD_REGISTER(rh
);
473 bit
= *shiftreg
& 0xF;
474 CONDITIONAL_SET_FLAG(*srcreg
& (0x1 << bit
), F_CF
);
478 DECODE_CLEAR_SEGOVR();
482 /****************************************************************************
484 Handles opcode 0x0f,0xa4
485 ****************************************************************************/
487 x86emuOp2_shld_IMM(u8
X86EMU_UNUSED(op2
))
494 DECODE_PRINTF("SHLD\t");
495 FETCH_DECODE_MODRM(mod
, rh
, rl
);
498 if (M
.x86
.mode
& SYSMODE_PREFIX_DATA
) {
502 destoffset
= decode_rm00_address(rl
);
504 shiftreg
= DECODE_RM_LONG_REGISTER(rh
);
506 shift
= fetch_byte_imm();
507 DECODE_PRINTF2("%d\n", shift
);
509 destval
= fetch_data_long(destoffset
);
510 destval
= shld_long(destval
, *shiftreg
, shift
);
511 store_data_long(destoffset
, destval
);
517 destoffset
= decode_rm00_address(rl
);
519 shiftreg
= DECODE_RM_WORD_REGISTER(rh
);
521 shift
= fetch_byte_imm();
522 DECODE_PRINTF2("%d\n", shift
);
524 destval
= fetch_data_word(destoffset
);
525 destval
= shld_word(destval
, *shiftreg
, shift
);
526 store_data_word(destoffset
, destval
);
530 if (M
.x86
.mode
& SYSMODE_PREFIX_DATA
) {
534 destoffset
= decode_rm01_address(rl
);
536 shiftreg
= DECODE_RM_LONG_REGISTER(rh
);
538 shift
= fetch_byte_imm();
539 DECODE_PRINTF2("%d\n", shift
);
541 destval
= fetch_data_long(destoffset
);
542 destval
= shld_long(destval
, *shiftreg
, shift
);
543 store_data_long(destoffset
, destval
);
549 destoffset
= decode_rm01_address(rl
);
551 shiftreg
= DECODE_RM_WORD_REGISTER(rh
);
553 shift
= fetch_byte_imm();
554 DECODE_PRINTF2("%d\n", shift
);
556 destval
= fetch_data_word(destoffset
);
557 destval
= shld_word(destval
, *shiftreg
, shift
);
558 store_data_word(destoffset
, destval
);
562 if (M
.x86
.mode
& SYSMODE_PREFIX_DATA
) {
566 destoffset
= decode_rm10_address(rl
);
568 shiftreg
= DECODE_RM_LONG_REGISTER(rh
);
570 shift
= fetch_byte_imm();
571 DECODE_PRINTF2("%d\n", shift
);
573 destval
= fetch_data_long(destoffset
);
574 destval
= shld_long(destval
, *shiftreg
, shift
);
575 store_data_long(destoffset
, destval
);
581 destoffset
= decode_rm10_address(rl
);
583 shiftreg
= DECODE_RM_WORD_REGISTER(rh
);
585 shift
= fetch_byte_imm();
586 DECODE_PRINTF2("%d\n", shift
);
588 destval
= fetch_data_word(destoffset
);
589 destval
= shld_word(destval
, *shiftreg
, shift
);
590 store_data_word(destoffset
, destval
);
593 case 3: /* register to register */
594 if (M
.x86
.mode
& SYSMODE_PREFIX_DATA
) {
595 u32
*destreg
, *shiftreg
;
597 destreg
= DECODE_RM_LONG_REGISTER(rl
);
599 shiftreg
= DECODE_RM_LONG_REGISTER(rh
);
601 shift
= fetch_byte_imm();
602 DECODE_PRINTF2("%d\n", shift
);
604 *destreg
= shld_long(*destreg
, *shiftreg
, shift
);
607 u16
*destreg
, *shiftreg
;
609 destreg
= DECODE_RM_WORD_REGISTER(rl
);
611 shiftreg
= DECODE_RM_WORD_REGISTER(rh
);
613 shift
= fetch_byte_imm();
614 DECODE_PRINTF2("%d\n", shift
);
616 *destreg
= shld_word(*destreg
, *shiftreg
, shift
);
620 DECODE_CLEAR_SEGOVR();
624 /****************************************************************************
626 Handles opcode 0x0f,0xa5
627 ****************************************************************************/
629 x86emuOp2_shld_CL(u8
X86EMU_UNUSED(op2
))
635 DECODE_PRINTF("SHLD\t");
636 FETCH_DECODE_MODRM(mod
, rh
, rl
);
639 if (M
.x86
.mode
& SYSMODE_PREFIX_DATA
) {
643 destoffset
= decode_rm00_address(rl
);
645 shiftreg
= DECODE_RM_LONG_REGISTER(rh
);
646 DECODE_PRINTF(",CL\n");
648 destval
= fetch_data_long(destoffset
);
649 destval
= shld_long(destval
, *shiftreg
, M
.x86
.R_CL
);
650 store_data_long(destoffset
, destval
);
656 destoffset
= decode_rm00_address(rl
);
658 shiftreg
= DECODE_RM_WORD_REGISTER(rh
);
659 DECODE_PRINTF(",CL\n");
661 destval
= fetch_data_word(destoffset
);
662 destval
= shld_word(destval
, *shiftreg
, M
.x86
.R_CL
);
663 store_data_word(destoffset
, destval
);
667 if (M
.x86
.mode
& SYSMODE_PREFIX_DATA
) {
671 destoffset
= decode_rm01_address(rl
);
673 shiftreg
= DECODE_RM_LONG_REGISTER(rh
);
674 DECODE_PRINTF(",CL\n");
676 destval
= fetch_data_long(destoffset
);
677 destval
= shld_long(destval
, *shiftreg
, M
.x86
.R_CL
);
678 store_data_long(destoffset
, destval
);
684 destoffset
= decode_rm01_address(rl
);
686 shiftreg
= DECODE_RM_WORD_REGISTER(rh
);
687 DECODE_PRINTF(",CL\n");
689 destval
= fetch_data_word(destoffset
);
690 destval
= shld_word(destval
, *shiftreg
, M
.x86
.R_CL
);
691 store_data_word(destoffset
, destval
);
695 if (M
.x86
.mode
& SYSMODE_PREFIX_DATA
) {
699 destoffset
= decode_rm10_address(rl
);
701 shiftreg
= DECODE_RM_LONG_REGISTER(rh
);
702 DECODE_PRINTF(",CL\n");
704 destval
= fetch_data_long(destoffset
);
705 destval
= shld_long(destval
, *shiftreg
, M
.x86
.R_CL
);
706 store_data_long(destoffset
, destval
);
712 destoffset
= decode_rm10_address(rl
);
714 shiftreg
= DECODE_RM_WORD_REGISTER(rh
);
715 DECODE_PRINTF(",CL\n");
717 destval
= fetch_data_word(destoffset
);
718 destval
= shld_word(destval
, *shiftreg
, M
.x86
.R_CL
);
719 store_data_word(destoffset
, destval
);
722 case 3: /* register to register */
723 if (M
.x86
.mode
& SYSMODE_PREFIX_DATA
) {
724 u32
*destreg
, *shiftreg
;
726 destreg
= DECODE_RM_LONG_REGISTER(rl
);
728 shiftreg
= DECODE_RM_LONG_REGISTER(rh
);
729 DECODE_PRINTF(",CL\n");
731 *destreg
= shld_long(*destreg
, *shiftreg
, M
.x86
.R_CL
);
734 u16
*destreg
, *shiftreg
;
736 destreg
= DECODE_RM_WORD_REGISTER(rl
);
738 shiftreg
= DECODE_RM_WORD_REGISTER(rh
);
739 DECODE_PRINTF(",CL\n");
741 *destreg
= shld_word(*destreg
, *shiftreg
, M
.x86
.R_CL
);
745 DECODE_CLEAR_SEGOVR();
749 /****************************************************************************
751 Handles opcode 0x0f,0xa8
752 ****************************************************************************/
754 x86emuOp2_push_GS(u8
X86EMU_UNUSED(op2
))
757 DECODE_PRINTF("PUSH\tGS\n");
759 push_word(M
.x86
.R_GS
);
760 DECODE_CLEAR_SEGOVR();
764 /****************************************************************************
766 Handles opcode 0x0f,0xa9
767 ****************************************************************************/
769 x86emuOp2_pop_GS(u8
X86EMU_UNUSED(op2
))
772 DECODE_PRINTF("POP\tGS\n");
774 M
.x86
.R_GS
= pop_word();
775 DECODE_CLEAR_SEGOVR();
779 /****************************************************************************
781 Handles opcode 0x0f,0xab
782 ****************************************************************************/
784 x86emuOp2_bts_R(u8
X86EMU_UNUSED(op2
))
791 DECODE_PRINTF("BTS\t");
792 FETCH_DECODE_MODRM(mod
, rh
, rl
);
795 if (M
.x86
.mode
& SYSMODE_PREFIX_DATA
) {
799 srcoffset
= decode_rm00_address(rl
);
801 shiftreg
= DECODE_RM_LONG_REGISTER(rh
);
803 bit
= *shiftreg
& 0x1F;
804 disp
= (s16
) * shiftreg
>> 5;
805 srcval
= fetch_data_long(srcoffset
+ disp
);
807 CONDITIONAL_SET_FLAG(srcval
& mask
, F_CF
);
808 store_data_long(srcoffset
+ disp
, srcval
| mask
);
814 srcoffset
= decode_rm00_address(rl
);
816 shiftreg
= DECODE_RM_WORD_REGISTER(rh
);
818 bit
= *shiftreg
& 0xF;
819 disp
= (s16
) * shiftreg
>> 4;
820 srcval
= fetch_data_word(srcoffset
+ disp
);
821 mask
= (u16
) (0x1 << bit
);
822 CONDITIONAL_SET_FLAG(srcval
& mask
, F_CF
);
823 store_data_word(srcoffset
+ disp
, srcval
| mask
);
827 if (M
.x86
.mode
& SYSMODE_PREFIX_DATA
) {
831 srcoffset
= decode_rm01_address(rl
);
833 shiftreg
= DECODE_RM_LONG_REGISTER(rh
);
835 bit
= *shiftreg
& 0x1F;
836 disp
= (s16
) * shiftreg
>> 5;
837 srcval
= fetch_data_long(srcoffset
+ disp
);
839 CONDITIONAL_SET_FLAG(srcval
& mask
, F_CF
);
840 store_data_long(srcoffset
+ disp
, srcval
| mask
);
846 srcoffset
= decode_rm01_address(rl
);
848 shiftreg
= DECODE_RM_WORD_REGISTER(rh
);
850 bit
= *shiftreg
& 0xF;
851 disp
= (s16
) * shiftreg
>> 4;
852 srcval
= fetch_data_word(srcoffset
+ disp
);
853 mask
= (u16
) (0x1 << bit
);
854 CONDITIONAL_SET_FLAG(srcval
& mask
, F_CF
);
855 store_data_word(srcoffset
+ disp
, srcval
| mask
);
859 if (M
.x86
.mode
& SYSMODE_PREFIX_DATA
) {
863 srcoffset
= decode_rm10_address(rl
);
865 shiftreg
= DECODE_RM_LONG_REGISTER(rh
);
867 bit
= *shiftreg
& 0x1F;
868 disp
= (s16
) * shiftreg
>> 5;
869 srcval
= fetch_data_long(srcoffset
+ disp
);
871 CONDITIONAL_SET_FLAG(srcval
& mask
, F_CF
);
872 store_data_long(srcoffset
+ disp
, srcval
| mask
);
878 srcoffset
= decode_rm10_address(rl
);
880 shiftreg
= DECODE_RM_WORD_REGISTER(rh
);
882 bit
= *shiftreg
& 0xF;
883 disp
= (s16
) * shiftreg
>> 4;
884 srcval
= fetch_data_word(srcoffset
+ disp
);
885 mask
= (u16
) (0x1 << bit
);
886 CONDITIONAL_SET_FLAG(srcval
& mask
, F_CF
);
887 store_data_word(srcoffset
+ disp
, srcval
| mask
);
890 case 3: /* register to register */
891 if (M
.x86
.mode
& SYSMODE_PREFIX_DATA
) {
892 u32
*srcreg
, *shiftreg
;
895 srcreg
= DECODE_RM_LONG_REGISTER(rl
);
897 shiftreg
= DECODE_RM_LONG_REGISTER(rh
);
899 bit
= *shiftreg
& 0x1F;
901 CONDITIONAL_SET_FLAG(*srcreg
& mask
, F_CF
);
905 u16
*srcreg
, *shiftreg
;
908 srcreg
= DECODE_RM_WORD_REGISTER(rl
);
910 shiftreg
= DECODE_RM_WORD_REGISTER(rh
);
912 bit
= *shiftreg
& 0xF;
913 mask
= (u16
) (0x1 << bit
);
914 CONDITIONAL_SET_FLAG(*srcreg
& mask
, F_CF
);
919 DECODE_CLEAR_SEGOVR();
923 /****************************************************************************
925 Handles opcode 0x0f,0xac
926 ****************************************************************************/
928 x86emuOp2_shrd_IMM(u8
X86EMU_UNUSED(op2
))
935 DECODE_PRINTF("SHLD\t");
936 FETCH_DECODE_MODRM(mod
, rh
, rl
);
939 if (M
.x86
.mode
& SYSMODE_PREFIX_DATA
) {
943 destoffset
= decode_rm00_address(rl
);
945 shiftreg
= DECODE_RM_LONG_REGISTER(rh
);
947 shift
= fetch_byte_imm();
948 DECODE_PRINTF2("%d\n", shift
);
950 destval
= fetch_data_long(destoffset
);
951 destval
= shrd_long(destval
, *shiftreg
, shift
);
952 store_data_long(destoffset
, destval
);
958 destoffset
= decode_rm00_address(rl
);
960 shiftreg
= DECODE_RM_WORD_REGISTER(rh
);
962 shift
= fetch_byte_imm();
963 DECODE_PRINTF2("%d\n", shift
);
965 destval
= fetch_data_word(destoffset
);
966 destval
= shrd_word(destval
, *shiftreg
, shift
);
967 store_data_word(destoffset
, destval
);
971 if (M
.x86
.mode
& SYSMODE_PREFIX_DATA
) {
975 destoffset
= decode_rm01_address(rl
);
977 shiftreg
= DECODE_RM_LONG_REGISTER(rh
);
979 shift
= fetch_byte_imm();
980 DECODE_PRINTF2("%d\n", shift
);
982 destval
= fetch_data_long(destoffset
);
983 destval
= shrd_long(destval
, *shiftreg
, shift
);
984 store_data_long(destoffset
, destval
);
990 destoffset
= decode_rm01_address(rl
);
992 shiftreg
= DECODE_RM_WORD_REGISTER(rh
);
994 shift
= fetch_byte_imm();
995 DECODE_PRINTF2("%d\n", shift
);
997 destval
= fetch_data_word(destoffset
);
998 destval
= shrd_word(destval
, *shiftreg
, shift
);
999 store_data_word(destoffset
, destval
);
1003 if (M
.x86
.mode
& SYSMODE_PREFIX_DATA
) {
1007 destoffset
= decode_rm10_address(rl
);
1009 shiftreg
= DECODE_RM_LONG_REGISTER(rh
);
1011 shift
= fetch_byte_imm();
1012 DECODE_PRINTF2("%d\n", shift
);
1014 destval
= fetch_data_long(destoffset
);
1015 destval
= shrd_long(destval
, *shiftreg
, shift
);
1016 store_data_long(destoffset
, destval
);
1022 destoffset
= decode_rm10_address(rl
);
1024 shiftreg
= DECODE_RM_WORD_REGISTER(rh
);
1026 shift
= fetch_byte_imm();
1027 DECODE_PRINTF2("%d\n", shift
);
1029 destval
= fetch_data_word(destoffset
);
1030 destval
= shrd_word(destval
, *shiftreg
, shift
);
1031 store_data_word(destoffset
, destval
);
1034 case 3: /* register to register */
1035 if (M
.x86
.mode
& SYSMODE_PREFIX_DATA
) {
1036 u32
*destreg
, *shiftreg
;
1038 destreg
= DECODE_RM_LONG_REGISTER(rl
);
1040 shiftreg
= DECODE_RM_LONG_REGISTER(rh
);
1042 shift
= fetch_byte_imm();
1043 DECODE_PRINTF2("%d\n", shift
);
1045 *destreg
= shrd_long(*destreg
, *shiftreg
, shift
);
1048 u16
*destreg
, *shiftreg
;
1050 destreg
= DECODE_RM_WORD_REGISTER(rl
);
1052 shiftreg
= DECODE_RM_WORD_REGISTER(rh
);
1054 shift
= fetch_byte_imm();
1055 DECODE_PRINTF2("%d\n", shift
);
1057 *destreg
= shrd_word(*destreg
, *shiftreg
, shift
);
1061 DECODE_CLEAR_SEGOVR();
1065 /****************************************************************************
1067 Handles opcode 0x0f,0xad
1068 ****************************************************************************/
1070 x86emuOp2_shrd_CL(u8
X86EMU_UNUSED(op2
))
1076 DECODE_PRINTF("SHLD\t");
1077 FETCH_DECODE_MODRM(mod
, rh
, rl
);
1080 if (M
.x86
.mode
& SYSMODE_PREFIX_DATA
) {
1084 destoffset
= decode_rm00_address(rl
);
1086 shiftreg
= DECODE_RM_LONG_REGISTER(rh
);
1087 DECODE_PRINTF(",CL\n");
1089 destval
= fetch_data_long(destoffset
);
1090 destval
= shrd_long(destval
, *shiftreg
, M
.x86
.R_CL
);
1091 store_data_long(destoffset
, destval
);
1097 destoffset
= decode_rm00_address(rl
);
1099 shiftreg
= DECODE_RM_WORD_REGISTER(rh
);
1100 DECODE_PRINTF(",CL\n");
1102 destval
= fetch_data_word(destoffset
);
1103 destval
= shrd_word(destval
, *shiftreg
, M
.x86
.R_CL
);
1104 store_data_word(destoffset
, destval
);
1108 if (M
.x86
.mode
& SYSMODE_PREFIX_DATA
) {
1112 destoffset
= decode_rm01_address(rl
);
1114 shiftreg
= DECODE_RM_LONG_REGISTER(rh
);
1115 DECODE_PRINTF(",CL\n");
1117 destval
= fetch_data_long(destoffset
);
1118 destval
= shrd_long(destval
, *shiftreg
, M
.x86
.R_CL
);
1119 store_data_long(destoffset
, destval
);
1125 destoffset
= decode_rm01_address(rl
);
1127 shiftreg
= DECODE_RM_WORD_REGISTER(rh
);
1128 DECODE_PRINTF(",CL\n");
1130 destval
= fetch_data_word(destoffset
);
1131 destval
= shrd_word(destval
, *shiftreg
, M
.x86
.R_CL
);
1132 store_data_word(destoffset
, destval
);
1136 if (M
.x86
.mode
& SYSMODE_PREFIX_DATA
) {
1140 destoffset
= decode_rm10_address(rl
);
1142 shiftreg
= DECODE_RM_LONG_REGISTER(rh
);
1143 DECODE_PRINTF(",CL\n");
1145 destval
= fetch_data_long(destoffset
);
1146 destval
= shrd_long(destval
, *shiftreg
, M
.x86
.R_CL
);
1147 store_data_long(destoffset
, destval
);
1153 destoffset
= decode_rm10_address(rl
);
1155 shiftreg
= DECODE_RM_WORD_REGISTER(rh
);
1156 DECODE_PRINTF(",CL\n");
1158 destval
= fetch_data_word(destoffset
);
1159 destval
= shrd_word(destval
, *shiftreg
, M
.x86
.R_CL
);
1160 store_data_word(destoffset
, destval
);
1163 case 3: /* register to register */
1164 if (M
.x86
.mode
& SYSMODE_PREFIX_DATA
) {
1165 u32
*destreg
, *shiftreg
;
1167 destreg
= DECODE_RM_LONG_REGISTER(rl
);
1169 shiftreg
= DECODE_RM_LONG_REGISTER(rh
);
1170 DECODE_PRINTF(",CL\n");
1172 *destreg
= shrd_long(*destreg
, *shiftreg
, M
.x86
.R_CL
);
1175 u16
*destreg
, *shiftreg
;
1177 destreg
= DECODE_RM_WORD_REGISTER(rl
);
1179 shiftreg
= DECODE_RM_WORD_REGISTER(rh
);
1180 DECODE_PRINTF(",CL\n");
1182 *destreg
= shrd_word(*destreg
, *shiftreg
, M
.x86
.R_CL
);
1186 DECODE_CLEAR_SEGOVR();
1190 /****************************************************************************
1192 Handles opcode 0x0f,0xaf
1193 ****************************************************************************/
1195 x86emuOp2_imul_R_RM(u8
X86EMU_UNUSED(op2
))
1201 DECODE_PRINTF("IMUL\t");
1202 FETCH_DECODE_MODRM(mod
, rh
, rl
);
1205 if (M
.x86
.mode
& SYSMODE_PREFIX_DATA
) {
1210 destreg
= DECODE_RM_LONG_REGISTER(rh
);
1212 srcoffset
= decode_rm00_address(rl
);
1213 srcval
= fetch_data_long(srcoffset
);
1215 imul_long_direct(&res_lo
, &res_hi
, (s32
) * destreg
, (s32
) srcval
);
1224 *destreg
= (u32
) res_lo
;
1231 destreg
= DECODE_RM_WORD_REGISTER(rh
);
1233 srcoffset
= decode_rm00_address(rl
);
1234 srcval
= fetch_data_word(srcoffset
);
1236 res
= (s16
) * destreg
* (s16
) srcval
;
1245 *destreg
= (u16
) res
;
1249 if (M
.x86
.mode
& SYSMODE_PREFIX_DATA
) {
1254 destreg
= DECODE_RM_LONG_REGISTER(rh
);
1256 srcoffset
= decode_rm01_address(rl
);
1257 srcval
= fetch_data_long(srcoffset
);
1259 imul_long_direct(&res_lo
, &res_hi
, (s32
) * destreg
, (s32
) srcval
);
1268 *destreg
= (u32
) res_lo
;
1275 destreg
= DECODE_RM_WORD_REGISTER(rh
);
1277 srcoffset
= decode_rm01_address(rl
);
1278 srcval
= fetch_data_word(srcoffset
);
1280 res
= (s16
) * destreg
* (s16
) srcval
;
1289 *destreg
= (u16
) res
;
1293 if (M
.x86
.mode
& SYSMODE_PREFIX_DATA
) {
1298 destreg
= DECODE_RM_LONG_REGISTER(rh
);
1300 srcoffset
= decode_rm10_address(rl
);
1301 srcval
= fetch_data_long(srcoffset
);
1303 imul_long_direct(&res_lo
, &res_hi
, (s32
) * destreg
, (s32
) srcval
);
1312 *destreg
= (u32
) res_lo
;
1319 destreg
= DECODE_RM_WORD_REGISTER(rh
);
1321 srcoffset
= decode_rm10_address(rl
);
1322 srcval
= fetch_data_word(srcoffset
);
1324 res
= (s16
) * destreg
* (s16
) srcval
;
1333 *destreg
= (u16
) res
;
1336 case 3: /* register to register */
1337 if (M
.x86
.mode
& SYSMODE_PREFIX_DATA
) {
1338 u32
*destreg
, *srcreg
;
1341 destreg
= DECODE_RM_LONG_REGISTER(rh
);
1343 srcreg
= DECODE_RM_LONG_REGISTER(rl
);
1345 imul_long_direct(&res_lo
, &res_hi
, (s32
) * destreg
, (s32
) * srcreg
);
1354 *destreg
= (u32
) res_lo
;
1357 u16
*destreg
, *srcreg
;
1360 destreg
= DECODE_RM_WORD_REGISTER(rh
);
1362 srcreg
= DECODE_RM_WORD_REGISTER(rl
);
1363 res
= (s16
) * destreg
* (s16
) * srcreg
;
1372 *destreg
= (u16
) res
;
1376 DECODE_CLEAR_SEGOVR();
1380 /****************************************************************************
1382 Handles opcode 0x0f,0xb2
1383 ****************************************************************************/
1385 x86emuOp2_lss_R_IMM(u8
X86EMU_UNUSED(op2
))
1392 DECODE_PRINTF("LSS\t");
1393 FETCH_DECODE_MODRM(mod
, rh
, rl
);
1396 dstreg
= DECODE_RM_WORD_REGISTER(rh
);
1398 srcoffset
= decode_rm00_address(rl
);
1399 DECODE_PRINTF("\n");
1401 *dstreg
= fetch_data_word(srcoffset
);
1402 M
.x86
.R_SS
= fetch_data_word(srcoffset
+ 2);
1405 dstreg
= DECODE_RM_WORD_REGISTER(rh
);
1407 srcoffset
= decode_rm01_address(rl
);
1408 DECODE_PRINTF("\n");
1410 *dstreg
= fetch_data_word(srcoffset
);
1411 M
.x86
.R_SS
= fetch_data_word(srcoffset
+ 2);
1414 dstreg
= DECODE_RM_WORD_REGISTER(rh
);
1416 srcoffset
= decode_rm10_address(rl
);
1417 DECODE_PRINTF("\n");
1419 *dstreg
= fetch_data_word(srcoffset
);
1420 M
.x86
.R_SS
= fetch_data_word(srcoffset
+ 2);
1422 case 3: /* register to register */
1426 DECODE_CLEAR_SEGOVR();
1430 /****************************************************************************
1432 Handles opcode 0x0f,0xb3
1433 ****************************************************************************/
1435 x86emuOp2_btr_R(u8
X86EMU_UNUSED(op2
))
1442 DECODE_PRINTF("BTR\t");
1443 FETCH_DECODE_MODRM(mod
, rh
, rl
);
1446 if (M
.x86
.mode
& SYSMODE_PREFIX_DATA
) {
1450 srcoffset
= decode_rm00_address(rl
);
1452 shiftreg
= DECODE_RM_LONG_REGISTER(rh
);
1454 bit
= *shiftreg
& 0x1F;
1455 disp
= (s16
) * shiftreg
>> 5;
1456 srcval
= fetch_data_long(srcoffset
+ disp
);
1457 mask
= (0x1 << bit
);
1458 CONDITIONAL_SET_FLAG(srcval
& mask
, F_CF
);
1459 store_data_long(srcoffset
+ disp
, srcval
& ~mask
);
1465 srcoffset
= decode_rm00_address(rl
);
1467 shiftreg
= DECODE_RM_WORD_REGISTER(rh
);
1469 bit
= *shiftreg
& 0xF;
1470 disp
= (s16
) * shiftreg
>> 4;
1471 srcval
= fetch_data_word(srcoffset
+ disp
);
1472 mask
= (u16
) (0x1 << bit
);
1473 CONDITIONAL_SET_FLAG(srcval
& mask
, F_CF
);
1474 store_data_word(srcoffset
+ disp
, (u16
) (srcval
& ~mask
));
1478 if (M
.x86
.mode
& SYSMODE_PREFIX_DATA
) {
1482 srcoffset
= decode_rm01_address(rl
);
1484 shiftreg
= DECODE_RM_LONG_REGISTER(rh
);
1486 bit
= *shiftreg
& 0x1F;
1487 disp
= (s16
) * shiftreg
>> 5;
1488 srcval
= fetch_data_long(srcoffset
+ disp
);
1489 mask
= (0x1 << bit
);
1490 CONDITIONAL_SET_FLAG(srcval
& mask
, F_CF
);
1491 store_data_long(srcoffset
+ disp
, srcval
& ~mask
);
1497 srcoffset
= decode_rm01_address(rl
);
1499 shiftreg
= DECODE_RM_WORD_REGISTER(rh
);
1501 bit
= *shiftreg
& 0xF;
1502 disp
= (s16
) * shiftreg
>> 4;
1503 srcval
= fetch_data_word(srcoffset
+ disp
);
1504 mask
= (u16
) (0x1 << bit
);
1505 CONDITIONAL_SET_FLAG(srcval
& mask
, F_CF
);
1506 store_data_word(srcoffset
+ disp
, (u16
) (srcval
& ~mask
));
1510 if (M
.x86
.mode
& SYSMODE_PREFIX_DATA
) {
1514 srcoffset
= decode_rm10_address(rl
);
1516 shiftreg
= DECODE_RM_LONG_REGISTER(rh
);
1518 bit
= *shiftreg
& 0x1F;
1519 disp
= (s16
) * shiftreg
>> 5;
1520 srcval
= fetch_data_long(srcoffset
+ disp
);
1521 mask
= (0x1 << bit
);
1522 CONDITIONAL_SET_FLAG(srcval
& mask
, F_CF
);
1523 store_data_long(srcoffset
+ disp
, srcval
& ~mask
);
1529 srcoffset
= decode_rm10_address(rl
);
1531 shiftreg
= DECODE_RM_WORD_REGISTER(rh
);
1533 bit
= *shiftreg
& 0xF;
1534 disp
= (s16
) * shiftreg
>> 4;
1535 srcval
= fetch_data_word(srcoffset
+ disp
);
1536 mask
= (u16
) (0x1 << bit
);
1537 CONDITIONAL_SET_FLAG(srcval
& mask
, F_CF
);
1538 store_data_word(srcoffset
+ disp
, (u16
) (srcval
& ~mask
));
1541 case 3: /* register to register */
1542 if (M
.x86
.mode
& SYSMODE_PREFIX_DATA
) {
1543 u32
*srcreg
, *shiftreg
;
1546 srcreg
= DECODE_RM_LONG_REGISTER(rl
);
1548 shiftreg
= DECODE_RM_LONG_REGISTER(rh
);
1550 bit
= *shiftreg
& 0x1F;
1551 mask
= (0x1 << bit
);
1552 CONDITIONAL_SET_FLAG(*srcreg
& mask
, F_CF
);
1556 u16
*srcreg
, *shiftreg
;
1559 srcreg
= DECODE_RM_WORD_REGISTER(rl
);
1561 shiftreg
= DECODE_RM_WORD_REGISTER(rh
);
1563 bit
= *shiftreg
& 0xF;
1564 mask
= (u16
) (0x1 << bit
);
1565 CONDITIONAL_SET_FLAG(*srcreg
& mask
, F_CF
);
1570 DECODE_CLEAR_SEGOVR();
1574 /****************************************************************************
1576 Handles opcode 0x0f,0xb4
1577 ****************************************************************************/
1579 x86emuOp2_lfs_R_IMM(u8
X86EMU_UNUSED(op2
))
1586 DECODE_PRINTF("LFS\t");
1587 FETCH_DECODE_MODRM(mod
, rh
, rl
);
1590 dstreg
= DECODE_RM_WORD_REGISTER(rh
);
1592 srcoffset
= decode_rm00_address(rl
);
1593 DECODE_PRINTF("\n");
1595 *dstreg
= fetch_data_word(srcoffset
);
1596 M
.x86
.R_FS
= fetch_data_word(srcoffset
+ 2);
1599 dstreg
= DECODE_RM_WORD_REGISTER(rh
);
1601 srcoffset
= decode_rm01_address(rl
);
1602 DECODE_PRINTF("\n");
1604 *dstreg
= fetch_data_word(srcoffset
);
1605 M
.x86
.R_FS
= fetch_data_word(srcoffset
+ 2);
1608 dstreg
= DECODE_RM_WORD_REGISTER(rh
);
1610 srcoffset
= decode_rm10_address(rl
);
1611 DECODE_PRINTF("\n");
1613 *dstreg
= fetch_data_word(srcoffset
);
1614 M
.x86
.R_FS
= fetch_data_word(srcoffset
+ 2);
1616 case 3: /* register to register */
1620 DECODE_CLEAR_SEGOVR();
1624 /****************************************************************************
1626 Handles opcode 0x0f,0xb5
1627 ****************************************************************************/
1629 x86emuOp2_lgs_R_IMM(u8
X86EMU_UNUSED(op2
))
1636 DECODE_PRINTF("LGS\t");
1637 FETCH_DECODE_MODRM(mod
, rh
, rl
);
1640 dstreg
= DECODE_RM_WORD_REGISTER(rh
);
1642 srcoffset
= decode_rm00_address(rl
);
1643 DECODE_PRINTF("\n");
1645 *dstreg
= fetch_data_word(srcoffset
);
1646 M
.x86
.R_GS
= fetch_data_word(srcoffset
+ 2);
1649 dstreg
= DECODE_RM_WORD_REGISTER(rh
);
1651 srcoffset
= decode_rm01_address(rl
);
1652 DECODE_PRINTF("\n");
1654 *dstreg
= fetch_data_word(srcoffset
);
1655 M
.x86
.R_GS
= fetch_data_word(srcoffset
+ 2);
1658 dstreg
= DECODE_RM_WORD_REGISTER(rh
);
1660 srcoffset
= decode_rm10_address(rl
);
1661 DECODE_PRINTF("\n");
1663 *dstreg
= fetch_data_word(srcoffset
);
1664 M
.x86
.R_GS
= fetch_data_word(srcoffset
+ 2);
1666 case 3: /* register to register */
1670 DECODE_CLEAR_SEGOVR();
1674 /****************************************************************************
1676 Handles opcode 0x0f,0xb6
1677 ****************************************************************************/
1679 x86emuOp2_movzx_byte_R_RM(u8
X86EMU_UNUSED(op2
))
1685 DECODE_PRINTF("MOVZX\t");
1686 FETCH_DECODE_MODRM(mod
, rh
, rl
);
1689 if (M
.x86
.mode
& SYSMODE_PREFIX_DATA
) {
1693 destreg
= DECODE_RM_LONG_REGISTER(rh
);
1695 srcoffset
= decode_rm00_address(rl
);
1696 srcval
= fetch_data_byte(srcoffset
);
1697 DECODE_PRINTF("\n");
1705 destreg
= DECODE_RM_WORD_REGISTER(rh
);
1707 srcoffset
= decode_rm00_address(rl
);
1708 srcval
= fetch_data_byte(srcoffset
);
1709 DECODE_PRINTF("\n");
1715 if (M
.x86
.mode
& SYSMODE_PREFIX_DATA
) {
1719 destreg
= DECODE_RM_LONG_REGISTER(rh
);
1721 srcoffset
= decode_rm01_address(rl
);
1722 srcval
= fetch_data_byte(srcoffset
);
1723 DECODE_PRINTF("\n");
1731 destreg
= DECODE_RM_WORD_REGISTER(rh
);
1733 srcoffset
= decode_rm01_address(rl
);
1734 srcval
= fetch_data_byte(srcoffset
);
1735 DECODE_PRINTF("\n");
1741 if (M
.x86
.mode
& SYSMODE_PREFIX_DATA
) {
1745 destreg
= DECODE_RM_LONG_REGISTER(rh
);
1747 srcoffset
= decode_rm10_address(rl
);
1748 srcval
= fetch_data_byte(srcoffset
);
1749 DECODE_PRINTF("\n");
1757 destreg
= DECODE_RM_WORD_REGISTER(rh
);
1759 srcoffset
= decode_rm10_address(rl
);
1760 srcval
= fetch_data_byte(srcoffset
);
1761 DECODE_PRINTF("\n");
1766 case 3: /* register to register */
1767 if (M
.x86
.mode
& SYSMODE_PREFIX_DATA
) {
1771 destreg
= DECODE_RM_LONG_REGISTER(rh
);
1773 srcreg
= DECODE_RM_BYTE_REGISTER(rl
);
1774 DECODE_PRINTF("\n");
1782 destreg
= DECODE_RM_WORD_REGISTER(rh
);
1784 srcreg
= DECODE_RM_BYTE_REGISTER(rl
);
1785 DECODE_PRINTF("\n");
1791 DECODE_CLEAR_SEGOVR();
1795 /****************************************************************************
1797 Handles opcode 0x0f,0xb7
1798 ****************************************************************************/
1800 x86emuOp2_movzx_word_R_RM(u8
X86EMU_UNUSED(op2
))
1809 DECODE_PRINTF("MOVZX\t");
1810 FETCH_DECODE_MODRM(mod
, rh
, rl
);
1813 destreg
= DECODE_RM_LONG_REGISTER(rh
);
1815 srcoffset
= decode_rm00_address(rl
);
1816 srcval
= fetch_data_word(srcoffset
);
1817 DECODE_PRINTF("\n");
1822 destreg
= DECODE_RM_LONG_REGISTER(rh
);
1824 srcoffset
= decode_rm01_address(rl
);
1825 srcval
= fetch_data_word(srcoffset
);
1826 DECODE_PRINTF("\n");
1831 destreg
= DECODE_RM_LONG_REGISTER(rh
);
1833 srcoffset
= decode_rm10_address(rl
);
1834 srcval
= fetch_data_word(srcoffset
);
1835 DECODE_PRINTF("\n");
1839 case 3: /* register to register */
1840 destreg
= DECODE_RM_LONG_REGISTER(rh
);
1842 srcreg
= DECODE_RM_WORD_REGISTER(rl
);
1843 DECODE_PRINTF("\n");
1848 DECODE_CLEAR_SEGOVR();
1852 /****************************************************************************
1854 Handles opcode 0x0f,0xba
1855 ****************************************************************************/
1857 x86emuOp2_btX_I(u8
X86EMU_UNUSED(op2
))
1864 FETCH_DECODE_MODRM(mod
, rh
, rl
);
1867 DECODE_PRINTF("BT\t");
1870 DECODE_PRINTF("BTS\t");
1873 DECODE_PRINTF("BTR\t");
1876 DECODE_PRINTF("BTC\t");
1879 DECODE_PRINTF("ILLEGAL EXTENDED X86 OPCODE\n");
1881 printk("%04x:%04x: %02X%02X ILLEGAL EXTENDED X86 OPCODE EXTENSION!\n",
1882 M
.x86
.R_CS
, M
.x86
.R_IP
- 3, op2
, (mod
<< 6) | (rh
<< 3) | rl
);
1887 if (M
.x86
.mode
& SYSMODE_PREFIX_DATA
) {
1891 srcoffset
= decode_rm00_address(rl
);
1893 shift
= fetch_byte_imm();
1896 srcval
= fetch_data_long(srcoffset
);
1897 mask
= (0x1 << bit
);
1898 CONDITIONAL_SET_FLAG(srcval
& mask
, F_CF
);
1901 store_data_long(srcoffset
, srcval
| mask
);
1904 store_data_long(srcoffset
, srcval
& ~mask
);
1907 store_data_long(srcoffset
, srcval
^ mask
);
1917 srcoffset
= decode_rm00_address(rl
);
1919 shift
= fetch_byte_imm();
1922 srcval
= fetch_data_word(srcoffset
);
1923 mask
= (0x1 << bit
);
1924 CONDITIONAL_SET_FLAG(srcval
& mask
, F_CF
);
1927 store_data_word(srcoffset
, srcval
| mask
);
1930 store_data_word(srcoffset
, srcval
& ~mask
);
1933 store_data_word(srcoffset
, srcval
^ mask
);
1941 if (M
.x86
.mode
& SYSMODE_PREFIX_DATA
) {
1945 srcoffset
= decode_rm01_address(rl
);
1947 shift
= fetch_byte_imm();
1950 srcval
= fetch_data_long(srcoffset
);
1951 mask
= (0x1 << bit
);
1952 CONDITIONAL_SET_FLAG(srcval
& mask
, F_CF
);
1955 store_data_long(srcoffset
, srcval
| mask
);
1958 store_data_long(srcoffset
, srcval
& ~mask
);
1961 store_data_long(srcoffset
, srcval
^ mask
);
1971 srcoffset
= decode_rm01_address(rl
);
1973 shift
= fetch_byte_imm();
1976 srcval
= fetch_data_word(srcoffset
);
1977 mask
= (0x1 << bit
);
1978 CONDITIONAL_SET_FLAG(srcval
& mask
, F_CF
);
1981 store_data_word(srcoffset
, srcval
| mask
);
1984 store_data_word(srcoffset
, srcval
& ~mask
);
1987 store_data_word(srcoffset
, srcval
^ mask
);
1995 if (M
.x86
.mode
& SYSMODE_PREFIX_DATA
) {
1999 srcoffset
= decode_rm10_address(rl
);
2001 shift
= fetch_byte_imm();
2004 srcval
= fetch_data_long(srcoffset
);
2005 mask
= (0x1 << bit
);
2006 CONDITIONAL_SET_FLAG(srcval
& mask
, F_CF
);
2009 store_data_long(srcoffset
, srcval
| mask
);
2012 store_data_long(srcoffset
, srcval
& ~mask
);
2015 store_data_long(srcoffset
, srcval
^ mask
);
2025 srcoffset
= decode_rm10_address(rl
);
2027 shift
= fetch_byte_imm();
2030 srcval
= fetch_data_word(srcoffset
);
2031 mask
= (0x1 << bit
);
2032 CONDITIONAL_SET_FLAG(srcval
& mask
, F_CF
);
2035 store_data_word(srcoffset
, srcval
| mask
);
2038 store_data_word(srcoffset
, srcval
& ~mask
);
2041 store_data_word(srcoffset
, srcval
^ mask
);
2048 case 3: /* register to register */
2049 if (M
.x86
.mode
& SYSMODE_PREFIX_DATA
) {
2054 srcreg
= DECODE_RM_LONG_REGISTER(rl
);
2056 shift
= fetch_byte_imm();
2059 mask
= (0x1 << bit
);
2060 CONDITIONAL_SET_FLAG(*srcreg
& mask
, F_CF
);
2080 srcreg
= DECODE_RM_WORD_REGISTER(rl
);
2082 shift
= fetch_byte_imm();
2085 mask
= (0x1 << bit
);
2086 CONDITIONAL_SET_FLAG(*srcreg
& mask
, F_CF
);
2103 DECODE_CLEAR_SEGOVR();
2107 /****************************************************************************
2109 Handles opcode 0x0f,0xbb
2110 ****************************************************************************/
2112 x86emuOp2_btc_R(u8
X86EMU_UNUSED(op2
))
2119 DECODE_PRINTF("BTC\t");
2120 FETCH_DECODE_MODRM(mod
, rh
, rl
);
2123 if (M
.x86
.mode
& SYSMODE_PREFIX_DATA
) {
2127 srcoffset
= decode_rm00_address(rl
);
2129 shiftreg
= DECODE_RM_LONG_REGISTER(rh
);
2131 bit
= *shiftreg
& 0x1F;
2132 disp
= (s16
) * shiftreg
>> 5;
2133 srcval
= fetch_data_long(srcoffset
+ disp
);
2134 mask
= (0x1 << bit
);
2135 CONDITIONAL_SET_FLAG(srcval
& mask
, F_CF
);
2136 store_data_long(srcoffset
+ disp
, srcval
^ mask
);
2142 srcoffset
= decode_rm00_address(rl
);
2144 shiftreg
= DECODE_RM_WORD_REGISTER(rh
);
2146 bit
= *shiftreg
& 0xF;
2147 disp
= (s16
) * shiftreg
>> 4;
2148 srcval
= fetch_data_word(srcoffset
+ disp
);
2149 mask
= (u16
) (0x1 << bit
);
2150 CONDITIONAL_SET_FLAG(srcval
& mask
, F_CF
);
2151 store_data_word(srcoffset
+ disp
, (u16
) (srcval
^ mask
));
2155 if (M
.x86
.mode
& SYSMODE_PREFIX_DATA
) {
2159 srcoffset
= decode_rm01_address(rl
);
2161 shiftreg
= DECODE_RM_LONG_REGISTER(rh
);
2163 bit
= *shiftreg
& 0x1F;
2164 disp
= (s16
) * shiftreg
>> 5;
2165 srcval
= fetch_data_long(srcoffset
+ disp
);
2166 mask
= (0x1 << bit
);
2167 CONDITIONAL_SET_FLAG(srcval
& mask
, F_CF
);
2168 store_data_long(srcoffset
+ disp
, srcval
^ mask
);
2174 srcoffset
= decode_rm01_address(rl
);
2176 shiftreg
= DECODE_RM_WORD_REGISTER(rh
);
2178 bit
= *shiftreg
& 0xF;
2179 disp
= (s16
) * shiftreg
>> 4;
2180 srcval
= fetch_data_word(srcoffset
+ disp
);
2181 mask
= (u16
) (0x1 << bit
);
2182 CONDITIONAL_SET_FLAG(srcval
& mask
, F_CF
);
2183 store_data_word(srcoffset
+ disp
, (u16
) (srcval
^ mask
));
2187 if (M
.x86
.mode
& SYSMODE_PREFIX_DATA
) {
2191 srcoffset
= decode_rm10_address(rl
);
2193 shiftreg
= DECODE_RM_LONG_REGISTER(rh
);
2195 bit
= *shiftreg
& 0x1F;
2196 disp
= (s16
) * shiftreg
>> 5;
2197 srcval
= fetch_data_long(srcoffset
+ disp
);
2198 mask
= (0x1 << bit
);
2199 CONDITIONAL_SET_FLAG(srcval
& mask
, F_CF
);
2200 store_data_long(srcoffset
+ disp
, srcval
^ mask
);
2206 srcoffset
= decode_rm10_address(rl
);
2208 shiftreg
= DECODE_RM_WORD_REGISTER(rh
);
2210 bit
= *shiftreg
& 0xF;
2211 disp
= (s16
) * shiftreg
>> 4;
2212 srcval
= fetch_data_word(srcoffset
+ disp
);
2213 mask
= (u16
) (0x1 << bit
);
2214 CONDITIONAL_SET_FLAG(srcval
& mask
, F_CF
);
2215 store_data_word(srcoffset
+ disp
, (u16
) (srcval
^ mask
));
2218 case 3: /* register to register */
2219 if (M
.x86
.mode
& SYSMODE_PREFIX_DATA
) {
2220 u32
*srcreg
, *shiftreg
;
2223 srcreg
= DECODE_RM_LONG_REGISTER(rl
);
2225 shiftreg
= DECODE_RM_LONG_REGISTER(rh
);
2227 bit
= *shiftreg
& 0x1F;
2228 mask
= (0x1 << bit
);
2229 CONDITIONAL_SET_FLAG(*srcreg
& mask
, F_CF
);
2233 u16
*srcreg
, *shiftreg
;
2236 srcreg
= DECODE_RM_WORD_REGISTER(rl
);
2238 shiftreg
= DECODE_RM_WORD_REGISTER(rh
);
2240 bit
= *shiftreg
& 0xF;
2241 mask
= (u16
) (0x1 << bit
);
2242 CONDITIONAL_SET_FLAG(*srcreg
& mask
, F_CF
);
2247 DECODE_CLEAR_SEGOVR();
2251 /****************************************************************************
2253 Handles opcode 0x0f,0xbc
2254 ****************************************************************************/
2256 x86emuOp2_bsf(u8
X86EMU_UNUSED(op2
))
2262 DECODE_PRINTF("BSF\t");
2263 FETCH_DECODE_MODRM(mod
, rh
, rl
);
2266 if (M
.x86
.mode
& SYSMODE_PREFIX_DATA
) {
2267 u32 srcval
, *dstreg
;
2269 srcoffset
= decode_rm00_address(rl
);
2271 dstreg
= DECODE_RM_LONG_REGISTER(rh
);
2273 srcval
= fetch_data_long(srcoffset
);
2274 CONDITIONAL_SET_FLAG(srcval
== 0, F_ZF
);
2275 for (*dstreg
= 0; *dstreg
< 32; (*dstreg
)++)
2276 if ((srcval
>> *dstreg
) & 1)
2280 u16 srcval
, *dstreg
;
2282 srcoffset
= decode_rm00_address(rl
);
2284 dstreg
= DECODE_RM_WORD_REGISTER(rh
);
2286 srcval
= fetch_data_word(srcoffset
);
2287 CONDITIONAL_SET_FLAG(srcval
== 0, F_ZF
);
2288 for (*dstreg
= 0; *dstreg
< 16; (*dstreg
)++)
2289 if ((srcval
>> *dstreg
) & 1)
2294 if (M
.x86
.mode
& SYSMODE_PREFIX_DATA
) {
2295 u32 srcval
, *dstreg
;
2297 srcoffset
= decode_rm01_address(rl
);
2299 dstreg
= DECODE_RM_LONG_REGISTER(rh
);
2301 srcval
= fetch_data_long(srcoffset
);
2302 CONDITIONAL_SET_FLAG(srcval
== 0, F_ZF
);
2303 for (*dstreg
= 0; *dstreg
< 32; (*dstreg
)++)
2304 if ((srcval
>> *dstreg
) & 1)
2308 u16 srcval
, *dstreg
;
2310 srcoffset
= decode_rm01_address(rl
);
2312 dstreg
= DECODE_RM_WORD_REGISTER(rh
);
2314 srcval
= fetch_data_word(srcoffset
);
2315 CONDITIONAL_SET_FLAG(srcval
== 0, F_ZF
);
2316 for (*dstreg
= 0; *dstreg
< 16; (*dstreg
)++)
2317 if ((srcval
>> *dstreg
) & 1)
2322 if (M
.x86
.mode
& SYSMODE_PREFIX_DATA
) {
2323 u32 srcval
, *dstreg
;
2325 srcoffset
= decode_rm10_address(rl
);
2327 dstreg
= DECODE_RM_LONG_REGISTER(rh
);
2329 srcval
= fetch_data_long(srcoffset
);
2330 CONDITIONAL_SET_FLAG(srcval
== 0, F_ZF
);
2331 for (*dstreg
= 0; *dstreg
< 32; (*dstreg
)++)
2332 if ((srcval
>> *dstreg
) & 1)
2336 u16 srcval
, *dstreg
;
2338 srcoffset
= decode_rm10_address(rl
);
2340 dstreg
= DECODE_RM_WORD_REGISTER(rh
);
2342 srcval
= fetch_data_word(srcoffset
);
2343 CONDITIONAL_SET_FLAG(srcval
== 0, F_ZF
);
2344 for (*dstreg
= 0; *dstreg
< 16; (*dstreg
)++)
2345 if ((srcval
>> *dstreg
) & 1)
2349 case 3: /* register to register */
2350 if (M
.x86
.mode
& SYSMODE_PREFIX_DATA
) {
2351 u32 srcval
, *dstreg
;
2353 srcval
= *DECODE_RM_LONG_REGISTER(rl
);
2355 dstreg
= DECODE_RM_LONG_REGISTER(rh
);
2357 CONDITIONAL_SET_FLAG(srcval
== 0, F_ZF
);
2358 for (*dstreg
= 0; *dstreg
< 32; (*dstreg
)++)
2359 if ((srcval
>> *dstreg
) & 1)
2363 u16 srcval
, *dstreg
;
2365 srcval
= *DECODE_RM_WORD_REGISTER(rl
);
2367 dstreg
= DECODE_RM_WORD_REGISTER(rh
);
2369 CONDITIONAL_SET_FLAG(srcval
== 0, F_ZF
);
2370 for (*dstreg
= 0; *dstreg
< 16; (*dstreg
)++)
2371 if ((srcval
>> *dstreg
) & 1)
2376 DECODE_CLEAR_SEGOVR();
2380 /****************************************************************************
2382 Handles opcode 0x0f,0xbd
2383 ****************************************************************************/
2385 x86emuOp2_bsr(u8
X86EMU_UNUSED(op2
))
2391 DECODE_PRINTF("BSR\t");
2392 FETCH_DECODE_MODRM(mod
, rh
, rl
);
2395 if (M
.x86
.mode
& SYSMODE_PREFIX_DATA
) {
2396 u32 srcval
, *dstreg
;
2398 srcoffset
= decode_rm00_address(rl
);
2400 dstreg
= DECODE_RM_LONG_REGISTER(rh
);
2402 srcval
= fetch_data_long(srcoffset
);
2403 CONDITIONAL_SET_FLAG(srcval
== 0, F_ZF
);
2404 for (*dstreg
= 31; *dstreg
> 0; (*dstreg
)--)
2405 if ((srcval
>> *dstreg
) & 1)
2409 u16 srcval
, *dstreg
;
2411 srcoffset
= decode_rm00_address(rl
);
2413 dstreg
= DECODE_RM_WORD_REGISTER(rh
);
2415 srcval
= fetch_data_word(srcoffset
);
2416 CONDITIONAL_SET_FLAG(srcval
== 0, F_ZF
);
2417 for (*dstreg
= 15; *dstreg
> 0; (*dstreg
)--)
2418 if ((srcval
>> *dstreg
) & 1)
2423 if (M
.x86
.mode
& SYSMODE_PREFIX_DATA
) {
2424 u32 srcval
, *dstreg
;
2426 srcoffset
= decode_rm01_address(rl
);
2428 dstreg
= DECODE_RM_LONG_REGISTER(rh
);
2430 srcval
= fetch_data_long(srcoffset
);
2431 CONDITIONAL_SET_FLAG(srcval
== 0, F_ZF
);
2432 for (*dstreg
= 31; *dstreg
> 0; (*dstreg
)--)
2433 if ((srcval
>> *dstreg
) & 1)
2437 u16 srcval
, *dstreg
;
2439 srcoffset
= decode_rm01_address(rl
);
2441 dstreg
= DECODE_RM_WORD_REGISTER(rh
);
2443 srcval
= fetch_data_word(srcoffset
);
2444 CONDITIONAL_SET_FLAG(srcval
== 0, F_ZF
);
2445 for (*dstreg
= 15; *dstreg
> 0; (*dstreg
)--)
2446 if ((srcval
>> *dstreg
) & 1)
2451 if (M
.x86
.mode
& SYSMODE_PREFIX_DATA
) {
2452 u32 srcval
, *dstreg
;
2454 srcoffset
= decode_rm10_address(rl
);
2456 dstreg
= DECODE_RM_LONG_REGISTER(rh
);
2458 srcval
= fetch_data_long(srcoffset
);
2459 CONDITIONAL_SET_FLAG(srcval
== 0, F_ZF
);
2460 for (*dstreg
= 31; *dstreg
> 0; (*dstreg
)--)
2461 if ((srcval
>> *dstreg
) & 1)
2465 u16 srcval
, *dstreg
;
2467 srcoffset
= decode_rm10_address(rl
);
2469 dstreg
= DECODE_RM_WORD_REGISTER(rh
);
2471 srcval
= fetch_data_word(srcoffset
);
2472 CONDITIONAL_SET_FLAG(srcval
== 0, F_ZF
);
2473 for (*dstreg
= 15; *dstreg
> 0; (*dstreg
)--)
2474 if ((srcval
>> *dstreg
) & 1)
2478 case 3: /* register to register */
2479 if (M
.x86
.mode
& SYSMODE_PREFIX_DATA
) {
2480 u32 srcval
, *dstreg
;
2482 srcval
= *DECODE_RM_LONG_REGISTER(rl
);
2484 dstreg
= DECODE_RM_LONG_REGISTER(rh
);
2486 CONDITIONAL_SET_FLAG(srcval
== 0, F_ZF
);
2487 for (*dstreg
= 31; *dstreg
> 0; (*dstreg
)--)
2488 if ((srcval
>> *dstreg
) & 1)
2492 u16 srcval
, *dstreg
;
2494 srcval
= *DECODE_RM_WORD_REGISTER(rl
);
2496 dstreg
= DECODE_RM_WORD_REGISTER(rh
);
2498 CONDITIONAL_SET_FLAG(srcval
== 0, F_ZF
);
2499 for (*dstreg
= 15; *dstreg
> 0; (*dstreg
)--)
2500 if ((srcval
>> *dstreg
) & 1)
2505 DECODE_CLEAR_SEGOVR();
2509 /****************************************************************************
2511 Handles opcode 0x0f,0xbe
2512 ****************************************************************************/
2514 x86emuOp2_movsx_byte_R_RM(u8
X86EMU_UNUSED(op2
))
2520 DECODE_PRINTF("MOVSX\t");
2521 FETCH_DECODE_MODRM(mod
, rh
, rl
);
2524 if (M
.x86
.mode
& SYSMODE_PREFIX_DATA
) {
2528 destreg
= DECODE_RM_LONG_REGISTER(rh
);
2530 srcoffset
= decode_rm00_address(rl
);
2531 srcval
= (s32
) ((s8
) fetch_data_byte(srcoffset
));
2532 DECODE_PRINTF("\n");
2540 destreg
= DECODE_RM_WORD_REGISTER(rh
);
2542 srcoffset
= decode_rm00_address(rl
);
2543 srcval
= (s16
) ((s8
) fetch_data_byte(srcoffset
));
2544 DECODE_PRINTF("\n");
2550 if (M
.x86
.mode
& SYSMODE_PREFIX_DATA
) {
2554 destreg
= DECODE_RM_LONG_REGISTER(rh
);
2556 srcoffset
= decode_rm01_address(rl
);
2557 srcval
= (s32
) ((s8
) fetch_data_byte(srcoffset
));
2558 DECODE_PRINTF("\n");
2566 destreg
= DECODE_RM_WORD_REGISTER(rh
);
2568 srcoffset
= decode_rm01_address(rl
);
2569 srcval
= (s16
) ((s8
) fetch_data_byte(srcoffset
));
2570 DECODE_PRINTF("\n");
2576 if (M
.x86
.mode
& SYSMODE_PREFIX_DATA
) {
2580 destreg
= DECODE_RM_LONG_REGISTER(rh
);
2582 srcoffset
= decode_rm10_address(rl
);
2583 srcval
= (s32
) ((s8
) fetch_data_byte(srcoffset
));
2584 DECODE_PRINTF("\n");
2592 destreg
= DECODE_RM_WORD_REGISTER(rh
);
2594 srcoffset
= decode_rm10_address(rl
);
2595 srcval
= (s16
) ((s8
) fetch_data_byte(srcoffset
));
2596 DECODE_PRINTF("\n");
2601 case 3: /* register to register */
2602 if (M
.x86
.mode
& SYSMODE_PREFIX_DATA
) {
2606 destreg
= DECODE_RM_LONG_REGISTER(rh
);
2608 srcreg
= DECODE_RM_BYTE_REGISTER(rl
);
2609 DECODE_PRINTF("\n");
2611 *destreg
= (s32
) ((s8
) * srcreg
);
2617 destreg
= DECODE_RM_WORD_REGISTER(rh
);
2619 srcreg
= DECODE_RM_BYTE_REGISTER(rl
);
2620 DECODE_PRINTF("\n");
2622 *destreg
= (s16
) ((s8
) * srcreg
);
2626 DECODE_CLEAR_SEGOVR();
2630 /****************************************************************************
2632 Handles opcode 0x0f,0xbf
2633 ****************************************************************************/
2635 x86emuOp2_movsx_word_R_RM(u8
X86EMU_UNUSED(op2
))
2644 DECODE_PRINTF("MOVSX\t");
2645 FETCH_DECODE_MODRM(mod
, rh
, rl
);
2648 destreg
= DECODE_RM_LONG_REGISTER(rh
);
2650 srcoffset
= decode_rm00_address(rl
);
2651 srcval
= (s32
) ((s16
) fetch_data_word(srcoffset
));
2652 DECODE_PRINTF("\n");
2657 destreg
= DECODE_RM_LONG_REGISTER(rh
);
2659 srcoffset
= decode_rm01_address(rl
);
2660 srcval
= (s32
) ((s16
) fetch_data_word(srcoffset
));
2661 DECODE_PRINTF("\n");
2666 destreg
= DECODE_RM_LONG_REGISTER(rh
);
2668 srcoffset
= decode_rm10_address(rl
);
2669 srcval
= (s32
) ((s16
) fetch_data_word(srcoffset
));
2670 DECODE_PRINTF("\n");
2674 case 3: /* register to register */
2675 destreg
= DECODE_RM_LONG_REGISTER(rh
);
2677 srcreg
= DECODE_RM_WORD_REGISTER(rl
);
2678 DECODE_PRINTF("\n");
2680 *destreg
= (s32
) ((s16
) * srcreg
);
2683 DECODE_CLEAR_SEGOVR();
2687 /* Handles opcodes 0xc8-0xcf */
2689 x86emuOp2_bswap(u8
X86EMU_UNUSED(op2
))
2692 DECODE_PRINTF("BSWAP\n");
2697 M
.x86
.R_EAX
= bswap_32(M
.x86
.R_EAX
);
2700 M
.x86
.R_ECX
= bswap_32(M
.x86
.R_ECX
);
2703 M
.x86
.R_EDX
= bswap_32(M
.x86
.R_EDX
);
2706 M
.x86
.R_EBX
= bswap_32(M
.x86
.R_EBX
);
2709 M
.x86
.R_ESP
= bswap_32(M
.x86
.R_ESP
);
2712 M
.x86
.R_EBP
= bswap_32(M
.x86
.R_EBP
);
2715 M
.x86
.R_ESI
= bswap_32(M
.x86
.R_ESI
);
2718 M
.x86
.R_EDI
= bswap_32(M
.x86
.R_EDI
);
2725 DECODE_CLEAR_SEGOVR();
2729 /***************************************************************************
2730 * Double byte operation code table:
2731 **************************************************************************/
2732 void (*x86emu_optab2
[256]) (u8
) = {
2733 /* 0x00 */ x86emuOp2_illegal_op
,
2734 /* Group F (ring 0 PM) */
2735 /* 0x01 */ x86emuOp2_illegal_op
,
2736 /* Group G (ring 0 PM) */
2737 /* 0x02 */ x86emuOp2_illegal_op
,
2738 /* lar (ring 0 PM) */
2739 /* 0x03 */ x86emuOp2_illegal_op
,
2740 /* lsl (ring 0 PM) */
2741 /* 0x04 */ x86emuOp2_illegal_op
,
2742 /* 0x05 */ x86emuOp2_illegal_op
,
2743 /* loadall (undocumented) */
2744 /* 0x06 */ x86emuOp2_illegal_op
,
2745 /* clts (ring 0 PM) */
2746 /* 0x07 */ x86emuOp2_illegal_op
,
2747 /* loadall (undocumented) */
2748 /* 0x08 */ x86emuOp2_illegal_op
,
2749 /* invd (ring 0 PM) */
2750 /* 0x09 */ x86emuOp2_illegal_op
,
2751 /* wbinvd (ring 0 PM) */
2752 /* 0x0a */ x86emuOp2_illegal_op
,
2753 /* 0x0b */ x86emuOp2_illegal_op
,
2754 /* 0x0c */ x86emuOp2_illegal_op
,
2755 /* 0x0d */ x86emuOp2_illegal_op
,
2756 /* 0x0e */ x86emuOp2_illegal_op
,
2757 /* 0x0f */ x86emuOp2_illegal_op
,
2758 /* 0x10 */ x86emuOp2_illegal_op
,
2759 /* 0x11 */ x86emuOp2_illegal_op
,
2760 /* 0x12 */ x86emuOp2_illegal_op
,
2761 /* 0x13 */ x86emuOp2_illegal_op
,
2762 /* 0x14 */ x86emuOp2_illegal_op
,
2763 /* 0x15 */ x86emuOp2_illegal_op
,
2764 /* 0x16 */ x86emuOp2_illegal_op
,
2765 /* 0x17 */ x86emuOp2_illegal_op
,
2766 /* 0x18 */ x86emuOp2_illegal_op
,
2767 /* 0x19 */ x86emuOp2_illegal_op
,
2768 /* 0x1a */ x86emuOp2_illegal_op
,
2769 /* 0x1b */ x86emuOp2_illegal_op
,
2770 /* 0x1c */ x86emuOp2_illegal_op
,
2771 /* 0x1d */ x86emuOp2_illegal_op
,
2772 /* 0x1e */ x86emuOp2_illegal_op
,
2773 /* 0x1f */ x86emuOp2_illegal_op
,
2774 /* 0x20 */ x86emuOp2_illegal_op
,
2775 /* mov reg32,creg (ring 0 PM) */
2776 /* 0x21 */ x86emuOp2_illegal_op
,
2777 /* mov reg32,dreg (ring 0 PM) */
2778 /* 0x22 */ x86emuOp2_illegal_op
,
2779 /* mov creg,reg32 (ring 0 PM) */
2780 /* 0x23 */ x86emuOp2_illegal_op
,
2781 /* mov dreg,reg32 (ring 0 PM) */
2782 /* 0x24 */ x86emuOp2_illegal_op
,
2783 /* mov reg32,treg (ring 0 PM) */
2784 /* 0x25 */ x86emuOp2_illegal_op
,
2785 /* 0x26 */ x86emuOp2_illegal_op
,
2786 /* mov treg,reg32 (ring 0 PM) */
2787 /* 0x27 */ x86emuOp2_illegal_op
,
2788 /* 0x28 */ x86emuOp2_illegal_op
,
2789 /* 0x29 */ x86emuOp2_illegal_op
,
2790 /* 0x2a */ x86emuOp2_illegal_op
,
2791 /* 0x2b */ x86emuOp2_illegal_op
,
2792 /* 0x2c */ x86emuOp2_illegal_op
,
2793 /* 0x2d */ x86emuOp2_illegal_op
,
2794 /* 0x2e */ x86emuOp2_illegal_op
,
2795 /* 0x2f */ x86emuOp2_illegal_op
,
2796 /* 0x30 */ x86emuOp2_illegal_op
,
2797 /* 0x31 */ x86emuOp2_rdtsc
,
2798 /* 0x32 */ x86emuOp2_illegal_op
,
2799 /* 0x33 */ x86emuOp2_illegal_op
,
2800 /* 0x34 */ x86emuOp2_illegal_op
,
2801 /* 0x35 */ x86emuOp2_illegal_op
,
2802 /* 0x36 */ x86emuOp2_illegal_op
,
2803 /* 0x37 */ x86emuOp2_illegal_op
,
2804 /* 0x38 */ x86emuOp2_illegal_op
,
2805 /* 0x39 */ x86emuOp2_illegal_op
,
2806 /* 0x3a */ x86emuOp2_illegal_op
,
2807 /* 0x3b */ x86emuOp2_illegal_op
,
2808 /* 0x3c */ x86emuOp2_illegal_op
,
2809 /* 0x3d */ x86emuOp2_illegal_op
,
2810 /* 0x3e */ x86emuOp2_illegal_op
,
2811 /* 0x3f */ x86emuOp2_illegal_op
,
2812 /* 0x40 */ x86emuOp2_illegal_op
,
2813 /* 0x41 */ x86emuOp2_illegal_op
,
2814 /* 0x42 */ x86emuOp2_illegal_op
,
2815 /* 0x43 */ x86emuOp2_illegal_op
,
2816 /* 0x44 */ x86emuOp2_illegal_op
,
2817 /* 0x45 */ x86emuOp2_illegal_op
,
2818 /* 0x46 */ x86emuOp2_illegal_op
,
2819 /* 0x47 */ x86emuOp2_illegal_op
,
2820 /* 0x48 */ x86emuOp2_illegal_op
,
2821 /* 0x49 */ x86emuOp2_illegal_op
,
2822 /* 0x4a */ x86emuOp2_illegal_op
,
2823 /* 0x4b */ x86emuOp2_illegal_op
,
2824 /* 0x4c */ x86emuOp2_illegal_op
,
2825 /* 0x4d */ x86emuOp2_illegal_op
,
2826 /* 0x4e */ x86emuOp2_illegal_op
,
2827 /* 0x4f */ x86emuOp2_illegal_op
,
2828 /* 0x50 */ x86emuOp2_illegal_op
,
2829 /* 0x51 */ x86emuOp2_illegal_op
,
2830 /* 0x52 */ x86emuOp2_illegal_op
,
2831 /* 0x53 */ x86emuOp2_illegal_op
,
2832 /* 0x54 */ x86emuOp2_illegal_op
,
2833 /* 0x55 */ x86emuOp2_illegal_op
,
2834 /* 0x56 */ x86emuOp2_illegal_op
,
2835 /* 0x57 */ x86emuOp2_illegal_op
,
2836 /* 0x58 */ x86emuOp2_illegal_op
,
2837 /* 0x59 */ x86emuOp2_illegal_op
,
2838 /* 0x5a */ x86emuOp2_illegal_op
,
2839 /* 0x5b */ x86emuOp2_illegal_op
,
2840 /* 0x5c */ x86emuOp2_illegal_op
,
2841 /* 0x5d */ x86emuOp2_illegal_op
,
2842 /* 0x5e */ x86emuOp2_illegal_op
,
2843 /* 0x5f */ x86emuOp2_illegal_op
,
2844 /* 0x60 */ x86emuOp2_illegal_op
,
2845 /* 0x61 */ x86emuOp2_illegal_op
,
2846 /* 0x62 */ x86emuOp2_illegal_op
,
2847 /* 0x63 */ x86emuOp2_illegal_op
,
2848 /* 0x64 */ x86emuOp2_illegal_op
,
2849 /* 0x65 */ x86emuOp2_illegal_op
,
2850 /* 0x66 */ x86emuOp2_illegal_op
,
2851 /* 0x67 */ x86emuOp2_illegal_op
,
2852 /* 0x68 */ x86emuOp2_illegal_op
,
2853 /* 0x69 */ x86emuOp2_illegal_op
,
2854 /* 0x6a */ x86emuOp2_illegal_op
,
2855 /* 0x6b */ x86emuOp2_illegal_op
,
2856 /* 0x6c */ x86emuOp2_illegal_op
,
2857 /* 0x6d */ x86emuOp2_illegal_op
,
2858 /* 0x6e */ x86emuOp2_illegal_op
,
2859 /* 0x6f */ x86emuOp2_illegal_op
,
2860 /* 0x70 */ x86emuOp2_illegal_op
,
2861 /* 0x71 */ x86emuOp2_illegal_op
,
2862 /* 0x72 */ x86emuOp2_illegal_op
,
2863 /* 0x73 */ x86emuOp2_illegal_op
,
2864 /* 0x74 */ x86emuOp2_illegal_op
,
2865 /* 0x75 */ x86emuOp2_illegal_op
,
2866 /* 0x76 */ x86emuOp2_illegal_op
,
2867 /* 0x77 */ x86emuOp2_illegal_op
,
2868 /* 0x78 */ x86emuOp2_illegal_op
,
2869 /* 0x79 */ x86emuOp2_illegal_op
,
2870 /* 0x7a */ x86emuOp2_illegal_op
,
2871 /* 0x7b */ x86emuOp2_illegal_op
,
2872 /* 0x7c */ x86emuOp2_illegal_op
,
2873 /* 0x7d */ x86emuOp2_illegal_op
,
2874 /* 0x7e */ x86emuOp2_illegal_op
,
2875 /* 0x7f */ x86emuOp2_illegal_op
,
2876 /* 0x80 */ x86emuOp2_long_jump
,
2877 /* 0x81 */ x86emuOp2_long_jump
,
2878 /* 0x82 */ x86emuOp2_long_jump
,
2879 /* 0x83 */ x86emuOp2_long_jump
,
2880 /* 0x84 */ x86emuOp2_long_jump
,
2881 /* 0x85 */ x86emuOp2_long_jump
,
2882 /* 0x86 */ x86emuOp2_long_jump
,
2883 /* 0x87 */ x86emuOp2_long_jump
,
2884 /* 0x88 */ x86emuOp2_long_jump
,
2885 /* 0x89 */ x86emuOp2_long_jump
,
2886 /* 0x8a */ x86emuOp2_long_jump
,
2887 /* 0x8b */ x86emuOp2_long_jump
,
2888 /* 0x8c */ x86emuOp2_long_jump
,
2889 /* 0x8d */ x86emuOp2_long_jump
,
2890 /* 0x8e */ x86emuOp2_long_jump
,
2891 /* 0x8f */ x86emuOp2_long_jump
,
2892 /* 0x90 */ x86emuOp2_set_byte
,
2893 /* 0x91 */ x86emuOp2_set_byte
,
2894 /* 0x92 */ x86emuOp2_set_byte
,
2895 /* 0x93 */ x86emuOp2_set_byte
,
2896 /* 0x94 */ x86emuOp2_set_byte
,
2897 /* 0x95 */ x86emuOp2_set_byte
,
2898 /* 0x96 */ x86emuOp2_set_byte
,
2899 /* 0x97 */ x86emuOp2_set_byte
,
2900 /* 0x98 */ x86emuOp2_set_byte
,
2901 /* 0x99 */ x86emuOp2_set_byte
,
2902 /* 0x9a */ x86emuOp2_set_byte
,
2903 /* 0x9b */ x86emuOp2_set_byte
,
2904 /* 0x9c */ x86emuOp2_set_byte
,
2905 /* 0x9d */ x86emuOp2_set_byte
,
2906 /* 0x9e */ x86emuOp2_set_byte
,
2907 /* 0x9f */ x86emuOp2_set_byte
,
2908 /* 0xa0 */ x86emuOp2_push_FS
,
2909 /* 0xa1 */ x86emuOp2_pop_FS
,
2910 /* 0xa2 */ x86emuOp2_cpuid
,
2911 /* 0xa3 */ x86emuOp2_bt_R
,
2912 /* 0xa4 */ x86emuOp2_shld_IMM
,
2913 /* 0xa5 */ x86emuOp2_shld_CL
,
2914 /* 0xa6 */ x86emuOp2_illegal_op
,
2915 /* 0xa7 */ x86emuOp2_illegal_op
,
2916 /* 0xa8 */ x86emuOp2_push_GS
,
2917 /* 0xa9 */ x86emuOp2_pop_GS
,
2918 /* 0xaa */ x86emuOp2_illegal_op
,
2919 /* 0xab */ x86emuOp2_bts_R
,
2920 /* 0xac */ x86emuOp2_shrd_IMM
,
2921 /* 0xad */ x86emuOp2_shrd_CL
,
2922 /* 0xae */ x86emuOp2_illegal_op
,
2923 /* 0xaf */ x86emuOp2_imul_R_RM
,
2924 /* 0xb0 */ x86emuOp2_illegal_op
,
2926 /* 0xb1 */ x86emuOp2_illegal_op
,
2928 /* 0xb2 */ x86emuOp2_lss_R_IMM
,
2929 /* 0xb3 */ x86emuOp2_btr_R
,
2930 /* 0xb4 */ x86emuOp2_lfs_R_IMM
,
2931 /* 0xb5 */ x86emuOp2_lgs_R_IMM
,
2932 /* 0xb6 */ x86emuOp2_movzx_byte_R_RM
,
2933 /* 0xb7 */ x86emuOp2_movzx_word_R_RM
,
2934 /* 0xb8 */ x86emuOp2_illegal_op
,
2935 /* 0xb9 */ x86emuOp2_illegal_op
,
2936 /* 0xba */ x86emuOp2_btX_I
,
2937 /* 0xbb */ x86emuOp2_btc_R
,
2938 /* 0xbc */ x86emuOp2_bsf
,
2939 /* 0xbd */ x86emuOp2_bsr
,
2940 /* 0xbe */ x86emuOp2_movsx_byte_R_RM
,
2941 /* 0xbf */ x86emuOp2_movsx_word_R_RM
,
2942 /* 0xc0 */ x86emuOp2_illegal_op
,
2944 /* 0xc1 */ x86emuOp2_illegal_op
,
2946 /* 0xc2 */ x86emuOp2_illegal_op
,
2947 /* 0xc3 */ x86emuOp2_illegal_op
,
2948 /* 0xc4 */ x86emuOp2_illegal_op
,
2949 /* 0xc5 */ x86emuOp2_illegal_op
,
2950 /* 0xc6 */ x86emuOp2_illegal_op
,
2951 /* 0xc7 */ x86emuOp2_illegal_op
,
2952 /* 0xc8 */ x86emuOp2_bswap
,
2953 /* 0xc9 */ x86emuOp2_bswap
,
2954 /* 0xca */ x86emuOp2_bswap
,
2955 /* 0xcb */ x86emuOp2_bswap
,
2956 /* 0xcc */ x86emuOp2_bswap
,
2957 /* 0xcd */ x86emuOp2_bswap
,
2958 /* 0xce */ x86emuOp2_bswap
,
2959 /* 0xcf */ x86emuOp2_bswap
,
2960 /* 0xd0 */ x86emuOp2_illegal_op
,
2961 /* 0xd1 */ x86emuOp2_illegal_op
,
2962 /* 0xd2 */ x86emuOp2_illegal_op
,
2963 /* 0xd3 */ x86emuOp2_illegal_op
,
2964 /* 0xd4 */ x86emuOp2_illegal_op
,
2965 /* 0xd5 */ x86emuOp2_illegal_op
,
2966 /* 0xd6 */ x86emuOp2_illegal_op
,
2967 /* 0xd7 */ x86emuOp2_illegal_op
,
2968 /* 0xd8 */ x86emuOp2_illegal_op
,
2969 /* 0xd9 */ x86emuOp2_illegal_op
,
2970 /* 0xda */ x86emuOp2_illegal_op
,
2971 /* 0xdb */ x86emuOp2_illegal_op
,
2972 /* 0xdc */ x86emuOp2_illegal_op
,
2973 /* 0xdd */ x86emuOp2_illegal_op
,
2974 /* 0xde */ x86emuOp2_illegal_op
,
2975 /* 0xdf */ x86emuOp2_illegal_op
,
2976 /* 0xe0 */ x86emuOp2_illegal_op
,
2977 /* 0xe1 */ x86emuOp2_illegal_op
,
2978 /* 0xe2 */ x86emuOp2_illegal_op
,
2979 /* 0xe3 */ x86emuOp2_illegal_op
,
2980 /* 0xe4 */ x86emuOp2_illegal_op
,
2981 /* 0xe5 */ x86emuOp2_illegal_op
,
2982 /* 0xe6 */ x86emuOp2_illegal_op
,
2983 /* 0xe7 */ x86emuOp2_illegal_op
,
2984 /* 0xe8 */ x86emuOp2_illegal_op
,
2985 /* 0xe9 */ x86emuOp2_illegal_op
,
2986 /* 0xea */ x86emuOp2_illegal_op
,
2987 /* 0xeb */ x86emuOp2_illegal_op
,
2988 /* 0xec */ x86emuOp2_illegal_op
,
2989 /* 0xed */ x86emuOp2_illegal_op
,
2990 /* 0xee */ x86emuOp2_illegal_op
,
2991 /* 0xef */ x86emuOp2_illegal_op
,
2992 /* 0xf0 */ x86emuOp2_illegal_op
,
2993 /* 0xf1 */ x86emuOp2_illegal_op
,
2994 /* 0xf2 */ x86emuOp2_illegal_op
,
2995 /* 0xf3 */ x86emuOp2_illegal_op
,
2996 /* 0xf4 */ x86emuOp2_illegal_op
,
2997 /* 0xf5 */ x86emuOp2_illegal_op
,
2998 /* 0xf6 */ x86emuOp2_illegal_op
,
2999 /* 0xf7 */ x86emuOp2_illegal_op
,
3000 /* 0xf8 */ x86emuOp2_illegal_op
,
3001 /* 0xf9 */ x86emuOp2_illegal_op
,
3002 /* 0xfa */ x86emuOp2_illegal_op
,
3003 /* 0xfb */ x86emuOp2_illegal_op
,
3004 /* 0xfc */ x86emuOp2_illegal_op
,
3005 /* 0xfd */ x86emuOp2_illegal_op
,
3006 /* 0xfe */ x86emuOp2_illegal_op
,
3007 /* 0xff */ x86emuOp2_illegal_op
,