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 ****************************************************************************/
40 /* $XFree86: xc/extras/x86emu/src/x86emu/ops2.c,v 1.4 2000/11/16 19:44:50 eich Exp $ */
42 #include "x86emu/x86emui.h"
43 #include "x86emu/ops_protos.h"
45 /*----------------------------- Implementation ----------------------------*/
47 /****************************************************************************
49 op1 - Instruction op code
52 Handles illegal opcodes.
53 ****************************************************************************/
54 void x86emuOp2_illegal_op(
58 DECODE_PRINTF("ILLEGAL EXTENDED X86 OPCODE\n");
60 printk("%04x:%04x: %02X ILLEGAL EXTENDED X86 OPCODE!\n",
61 M
.x86
.R_CS
, M
.x86
.R_IP
-2,op2
);
66 #define xorl(a,b) ((a) && !(b)) || (!(a) && (b))
68 /****************************************************************************
70 Handles opcode 0x0f,0x80-0x8F
71 ****************************************************************************/
72 void x86emuOp2_long_jump(u8 op2
)
78 /* conditional jump to word offset. */
83 cond
= ACCESS_FLAG(F_OF
);
87 cond
= !ACCESS_FLAG(F_OF
);
91 cond
= ACCESS_FLAG(F_CF
);
95 cond
= !ACCESS_FLAG(F_CF
);
99 cond
= ACCESS_FLAG(F_ZF
);
103 cond
= !ACCESS_FLAG(F_ZF
);
107 cond
= ACCESS_FLAG(F_CF
) || ACCESS_FLAG(F_ZF
);
111 cond
= !(ACCESS_FLAG(F_CF
) || ACCESS_FLAG(F_ZF
));
115 cond
= ACCESS_FLAG(F_SF
);
119 cond
= !ACCESS_FLAG(F_SF
);
123 cond
= ACCESS_FLAG(F_PF
);
127 cond
= !ACCESS_FLAG(F_PF
);
131 cond
= xorl(ACCESS_FLAG(F_SF
), ACCESS_FLAG(F_OF
));
135 cond
= xorl(ACCESS_FLAG(F_SF
), ACCESS_FLAG(F_OF
));
139 cond
= (xorl(ACCESS_FLAG(F_SF
), ACCESS_FLAG(F_OF
)) ||
144 cond
= !(xorl(ACCESS_FLAG(F_SF
), ACCESS_FLAG(F_OF
)) ||
149 target
= (s16
) fetch_word_imm();
150 target
+= (s16
) M
.x86
.R_IP
;
151 DECODE_PRINTF2("%04x\n", target
);
154 M
.x86
.R_IP
= (u16
)target
;
155 DECODE_CLEAR_SEGOVR();
159 /****************************************************************************
161 Handles opcode 0x0f,0x90-0x9F
162 ****************************************************************************/
163 void x86emuOp2_set_byte(u8 op2
)
175 cond
= ACCESS_FLAG(F_OF
);
179 cond
= !ACCESS_FLAG(F_OF
);
183 cond
= ACCESS_FLAG(F_CF
);
187 cond
= !ACCESS_FLAG(F_CF
);
191 cond
= ACCESS_FLAG(F_ZF
);
195 cond
= !ACCESS_FLAG(F_ZF
);
199 cond
= ACCESS_FLAG(F_CF
) || ACCESS_FLAG(F_ZF
);
203 cond
= !(ACCESS_FLAG(F_CF
) || ACCESS_FLAG(F_ZF
));
207 cond
= ACCESS_FLAG(F_SF
);
211 cond
= !ACCESS_FLAG(F_SF
);
215 cond
= ACCESS_FLAG(F_PF
);
219 cond
= !ACCESS_FLAG(F_PF
);
223 cond
= xorl(ACCESS_FLAG(F_SF
), ACCESS_FLAG(F_OF
));
227 cond
= xorl(ACCESS_FLAG(F_SF
), ACCESS_FLAG(F_OF
));
231 cond
= (xorl(ACCESS_FLAG(F_SF
), ACCESS_FLAG(F_OF
)) ||
236 cond
= !(xorl(ACCESS_FLAG(F_SF
), ACCESS_FLAG(F_OF
)) ||
241 FETCH_DECODE_MODRM(mod
, rh
, rl
);
244 destoffset
= decode_rm00_address(rl
);
246 store_data_byte(destoffset
, cond
? 0x01 : 0x00);
249 destoffset
= decode_rm01_address(rl
);
251 store_data_byte(destoffset
, cond
? 0x01 : 0x00);
254 destoffset
= decode_rm10_address(rl
);
256 store_data_byte(destoffset
, cond
? 0x01 : 0x00);
258 case 3: /* register to register */
259 destreg
= DECODE_RM_BYTE_REGISTER(rl
);
261 *destreg
= cond
? 0x01 : 0x00;
264 DECODE_CLEAR_SEGOVR();
268 /****************************************************************************
270 Handles opcode 0x0f,0xa0
271 ****************************************************************************/
272 void x86emuOp2_push_FS(u8
X86EMU_UNUSED(op2
))
275 DECODE_PRINTF("PUSH\tFS\n");
277 push_word(M
.x86
.R_FS
);
278 DECODE_CLEAR_SEGOVR();
282 /****************************************************************************
284 Handles opcode 0x0f,0xa1
285 ****************************************************************************/
286 void x86emuOp2_pop_FS(u8
X86EMU_UNUSED(op2
))
289 DECODE_PRINTF("POP\tFS\n");
291 M
.x86
.R_FS
= pop_word();
292 DECODE_CLEAR_SEGOVR();
296 /****************************************************************************
298 Handles opcode 0x0f,0xa3
299 ****************************************************************************/
300 void x86emuOp2_bt_R(u8
X86EMU_UNUSED(op2
))
307 DECODE_PRINTF("BT\t");
308 FETCH_DECODE_MODRM(mod
, rh
, rl
);
311 if (M
.x86
.mode
& SYSMODE_PREFIX_DATA
) {
315 srcoffset
= decode_rm00_address(rl
);
317 shiftreg
= DECODE_RM_LONG_REGISTER(rh
);
319 bit
= *shiftreg
& 0x1F;
320 disp
= (s16
)*shiftreg
>> 5;
321 srcval
= fetch_data_long(srcoffset
+disp
);
322 CONDITIONAL_SET_FLAG(srcval
& (0x1 << bit
),F_CF
);
327 srcoffset
= decode_rm00_address(rl
);
329 shiftreg
= DECODE_RM_WORD_REGISTER(rh
);
331 bit
= *shiftreg
& 0xF;
332 disp
= (s16
)*shiftreg
>> 4;
333 srcval
= fetch_data_word(srcoffset
+disp
);
334 CONDITIONAL_SET_FLAG(srcval
& (0x1 << bit
),F_CF
);
338 if (M
.x86
.mode
& SYSMODE_PREFIX_DATA
) {
342 srcoffset
= decode_rm01_address(rl
);
344 shiftreg
= DECODE_RM_LONG_REGISTER(rh
);
346 bit
= *shiftreg
& 0x1F;
347 disp
= (s16
)*shiftreg
>> 5;
348 srcval
= fetch_data_long(srcoffset
+disp
);
349 CONDITIONAL_SET_FLAG(srcval
& (0x1 << bit
),F_CF
);
354 srcoffset
= decode_rm01_address(rl
);
356 shiftreg
= DECODE_RM_WORD_REGISTER(rh
);
358 bit
= *shiftreg
& 0xF;
359 disp
= (s16
)*shiftreg
>> 4;
360 srcval
= fetch_data_word(srcoffset
+disp
);
361 CONDITIONAL_SET_FLAG(srcval
& (0x1 << bit
),F_CF
);
365 if (M
.x86
.mode
& SYSMODE_PREFIX_DATA
) {
369 srcoffset
= decode_rm10_address(rl
);
371 shiftreg
= DECODE_RM_LONG_REGISTER(rh
);
373 bit
= *shiftreg
& 0x1F;
374 disp
= (s16
)*shiftreg
>> 5;
375 srcval
= fetch_data_long(srcoffset
+disp
);
376 CONDITIONAL_SET_FLAG(srcval
& (0x1 << bit
),F_CF
);
381 srcoffset
= decode_rm10_address(rl
);
383 shiftreg
= DECODE_RM_WORD_REGISTER(rh
);
385 bit
= *shiftreg
& 0xF;
386 disp
= (s16
)*shiftreg
>> 4;
387 srcval
= fetch_data_word(srcoffset
+disp
);
388 CONDITIONAL_SET_FLAG(srcval
& (0x1 << bit
),F_CF
);
391 case 3: /* register to register */
392 if (M
.x86
.mode
& SYSMODE_PREFIX_DATA
) {
393 u32
*srcreg
,*shiftreg
;
395 srcreg
= DECODE_RM_LONG_REGISTER(rl
);
397 shiftreg
= DECODE_RM_LONG_REGISTER(rh
);
399 bit
= *shiftreg
& 0x1F;
400 CONDITIONAL_SET_FLAG(*srcreg
& (0x1 << bit
),F_CF
);
402 u16
*srcreg
,*shiftreg
;
404 srcreg
= DECODE_RM_WORD_REGISTER(rl
);
406 shiftreg
= DECODE_RM_WORD_REGISTER(rh
);
408 bit
= *shiftreg
& 0xF;
409 CONDITIONAL_SET_FLAG(*srcreg
& (0x1 << bit
),F_CF
);
413 DECODE_CLEAR_SEGOVR();
417 /****************************************************************************
419 Handles opcode 0x0f,0xa4
420 ****************************************************************************/
421 void x86emuOp2_shld_IMM(u8
X86EMU_UNUSED(op2
))
428 DECODE_PRINTF("SHLD\t");
429 FETCH_DECODE_MODRM(mod
, rh
, rl
);
432 if (M
.x86
.mode
& SYSMODE_PREFIX_DATA
) {
436 destoffset
= decode_rm00_address(rl
);
438 shiftreg
= DECODE_RM_LONG_REGISTER(rh
);
440 shift
= fetch_byte_imm();
441 DECODE_PRINTF2("%d\n", shift
);
443 destval
= fetch_data_long(destoffset
);
444 destval
= shld_long(destval
,*shiftreg
,shift
);
445 store_data_long(destoffset
, destval
);
450 destoffset
= decode_rm00_address(rl
);
452 shiftreg
= DECODE_RM_WORD_REGISTER(rh
);
454 shift
= fetch_byte_imm();
455 DECODE_PRINTF2("%d\n", shift
);
457 destval
= fetch_data_word(destoffset
);
458 destval
= shld_word(destval
,*shiftreg
,shift
);
459 store_data_word(destoffset
, destval
);
463 if (M
.x86
.mode
& SYSMODE_PREFIX_DATA
) {
467 destoffset
= decode_rm01_address(rl
);
469 shiftreg
= DECODE_RM_LONG_REGISTER(rh
);
471 shift
= fetch_byte_imm();
472 DECODE_PRINTF2("%d\n", shift
);
474 destval
= fetch_data_long(destoffset
);
475 destval
= shld_long(destval
,*shiftreg
,shift
);
476 store_data_long(destoffset
, destval
);
481 destoffset
= decode_rm01_address(rl
);
483 shiftreg
= DECODE_RM_WORD_REGISTER(rh
);
485 shift
= fetch_byte_imm();
486 DECODE_PRINTF2("%d\n", shift
);
488 destval
= fetch_data_word(destoffset
);
489 destval
= shld_word(destval
,*shiftreg
,shift
);
490 store_data_word(destoffset
, destval
);
494 if (M
.x86
.mode
& SYSMODE_PREFIX_DATA
) {
498 destoffset
= decode_rm10_address(rl
);
500 shiftreg
= DECODE_RM_LONG_REGISTER(rh
);
502 shift
= fetch_byte_imm();
503 DECODE_PRINTF2("%d\n", shift
);
505 destval
= fetch_data_long(destoffset
);
506 destval
= shld_long(destval
,*shiftreg
,shift
);
507 store_data_long(destoffset
, destval
);
512 destoffset
= decode_rm10_address(rl
);
514 shiftreg
= DECODE_RM_WORD_REGISTER(rh
);
516 shift
= fetch_byte_imm();
517 DECODE_PRINTF2("%d\n", shift
);
519 destval
= fetch_data_word(destoffset
);
520 destval
= shld_word(destval
,*shiftreg
,shift
);
521 store_data_word(destoffset
, destval
);
524 case 3: /* register to register */
525 if (M
.x86
.mode
& SYSMODE_PREFIX_DATA
) {
526 u32
*destreg
,*shiftreg
;
528 destreg
= DECODE_RM_LONG_REGISTER(rl
);
530 shiftreg
= DECODE_RM_LONG_REGISTER(rh
);
532 shift
= fetch_byte_imm();
533 DECODE_PRINTF2("%d\n", shift
);
535 *destreg
= shld_long(*destreg
,*shiftreg
,shift
);
537 u16
*destreg
,*shiftreg
;
539 destreg
= DECODE_RM_WORD_REGISTER(rl
);
541 shiftreg
= DECODE_RM_WORD_REGISTER(rh
);
543 shift
= fetch_byte_imm();
544 DECODE_PRINTF2("%d\n", shift
);
546 *destreg
= shld_word(*destreg
,*shiftreg
,shift
);
550 DECODE_CLEAR_SEGOVR();
554 /****************************************************************************
556 Handles opcode 0x0f,0xa5
557 ****************************************************************************/
558 void x86emuOp2_shld_CL(u8
X86EMU_UNUSED(op2
))
564 DECODE_PRINTF("SHLD\t");
565 FETCH_DECODE_MODRM(mod
, rh
, rl
);
568 if (M
.x86
.mode
& SYSMODE_PREFIX_DATA
) {
572 destoffset
= decode_rm00_address(rl
);
574 shiftreg
= DECODE_RM_LONG_REGISTER(rh
);
575 DECODE_PRINTF(",CL\n");
577 destval
= fetch_data_long(destoffset
);
578 destval
= shld_long(destval
,*shiftreg
,M
.x86
.R_CL
);
579 store_data_long(destoffset
, destval
);
584 destoffset
= decode_rm00_address(rl
);
586 shiftreg
= DECODE_RM_WORD_REGISTER(rh
);
587 DECODE_PRINTF(",CL\n");
589 destval
= fetch_data_word(destoffset
);
590 destval
= shld_word(destval
,*shiftreg
,M
.x86
.R_CL
);
591 store_data_word(destoffset
, destval
);
595 if (M
.x86
.mode
& SYSMODE_PREFIX_DATA
) {
599 destoffset
= decode_rm01_address(rl
);
601 shiftreg
= DECODE_RM_LONG_REGISTER(rh
);
602 DECODE_PRINTF(",CL\n");
604 destval
= fetch_data_long(destoffset
);
605 destval
= shld_long(destval
,*shiftreg
,M
.x86
.R_CL
);
606 store_data_long(destoffset
, destval
);
611 destoffset
= decode_rm01_address(rl
);
613 shiftreg
= DECODE_RM_WORD_REGISTER(rh
);
614 DECODE_PRINTF(",CL\n");
616 destval
= fetch_data_word(destoffset
);
617 destval
= shld_word(destval
,*shiftreg
,M
.x86
.R_CL
);
618 store_data_word(destoffset
, destval
);
622 if (M
.x86
.mode
& SYSMODE_PREFIX_DATA
) {
626 destoffset
= decode_rm10_address(rl
);
628 shiftreg
= DECODE_RM_LONG_REGISTER(rh
);
629 DECODE_PRINTF(",CL\n");
631 destval
= fetch_data_long(destoffset
);
632 destval
= shld_long(destval
,*shiftreg
,M
.x86
.R_CL
);
633 store_data_long(destoffset
, destval
);
638 destoffset
= decode_rm10_address(rl
);
640 shiftreg
= DECODE_RM_WORD_REGISTER(rh
);
641 DECODE_PRINTF(",CL\n");
643 destval
= fetch_data_word(destoffset
);
644 destval
= shld_word(destval
,*shiftreg
,M
.x86
.R_CL
);
645 store_data_word(destoffset
, destval
);
648 case 3: /* register to register */
649 if (M
.x86
.mode
& SYSMODE_PREFIX_DATA
) {
650 u32
*destreg
,*shiftreg
;
652 destreg
= DECODE_RM_LONG_REGISTER(rl
);
654 shiftreg
= DECODE_RM_LONG_REGISTER(rh
);
655 DECODE_PRINTF(",CL\n");
657 *destreg
= shld_long(*destreg
,*shiftreg
,M
.x86
.R_CL
);
659 u16
*destreg
,*shiftreg
;
661 destreg
= DECODE_RM_WORD_REGISTER(rl
);
663 shiftreg
= DECODE_RM_WORD_REGISTER(rh
);
664 DECODE_PRINTF(",CL\n");
666 *destreg
= shld_word(*destreg
,*shiftreg
,M
.x86
.R_CL
);
670 DECODE_CLEAR_SEGOVR();
674 /****************************************************************************
676 Handles opcode 0x0f,0xa8
677 ****************************************************************************/
678 void x86emuOp2_push_GS(u8
X86EMU_UNUSED(op2
))
681 DECODE_PRINTF("PUSH\tGS\n");
683 push_word(M
.x86
.R_GS
);
684 DECODE_CLEAR_SEGOVR();
688 /****************************************************************************
690 Handles opcode 0x0f,0xa9
691 ****************************************************************************/
692 void x86emuOp2_pop_GS(u8
X86EMU_UNUSED(op2
))
695 DECODE_PRINTF("POP\tGS\n");
697 M
.x86
.R_GS
= pop_word();
698 DECODE_CLEAR_SEGOVR();
702 /****************************************************************************
704 Handles opcode 0x0f,0xaa
705 ****************************************************************************/
706 void x86emuOp2_bts_R(u8
X86EMU_UNUSED(op2
))
713 DECODE_PRINTF("BTS\t");
714 FETCH_DECODE_MODRM(mod
, rh
, rl
);
717 if (M
.x86
.mode
& SYSMODE_PREFIX_DATA
) {
721 srcoffset
= decode_rm00_address(rl
);
723 shiftreg
= DECODE_RM_LONG_REGISTER(rh
);
725 bit
= *shiftreg
& 0x1F;
726 disp
= (s16
)*shiftreg
>> 5;
727 srcval
= fetch_data_long(srcoffset
+disp
);
729 CONDITIONAL_SET_FLAG(srcval
& mask
,F_CF
);
730 store_data_long(srcoffset
+disp
, srcval
| mask
);
735 srcoffset
= decode_rm00_address(rl
);
737 shiftreg
= DECODE_RM_WORD_REGISTER(rh
);
739 bit
= *shiftreg
& 0xF;
740 disp
= (s16
)*shiftreg
>> 4;
741 srcval
= fetch_data_word(srcoffset
+disp
);
742 mask
= (u16
)(0x1 << bit
);
743 CONDITIONAL_SET_FLAG(srcval
& mask
,F_CF
);
744 store_data_word(srcoffset
+disp
, srcval
| mask
);
748 if (M
.x86
.mode
& SYSMODE_PREFIX_DATA
) {
752 srcoffset
= decode_rm01_address(rl
);
754 shiftreg
= DECODE_RM_LONG_REGISTER(rh
);
756 bit
= *shiftreg
& 0x1F;
757 disp
= (s16
)*shiftreg
>> 5;
758 srcval
= fetch_data_long(srcoffset
+disp
);
760 CONDITIONAL_SET_FLAG(srcval
& mask
,F_CF
);
761 store_data_long(srcoffset
+disp
, srcval
| mask
);
766 srcoffset
= decode_rm01_address(rl
);
768 shiftreg
= DECODE_RM_WORD_REGISTER(rh
);
770 bit
= *shiftreg
& 0xF;
771 disp
= (s16
)*shiftreg
>> 4;
772 srcval
= fetch_data_word(srcoffset
+disp
);
773 mask
= (u16
)(0x1 << bit
);
774 CONDITIONAL_SET_FLAG(srcval
& mask
,F_CF
);
775 store_data_word(srcoffset
+disp
, srcval
| mask
);
779 if (M
.x86
.mode
& SYSMODE_PREFIX_DATA
) {
783 srcoffset
= decode_rm10_address(rl
);
785 shiftreg
= DECODE_RM_LONG_REGISTER(rh
);
787 bit
= *shiftreg
& 0x1F;
788 disp
= (s16
)*shiftreg
>> 5;
789 srcval
= fetch_data_long(srcoffset
+disp
);
791 CONDITIONAL_SET_FLAG(srcval
& mask
,F_CF
);
792 store_data_long(srcoffset
+disp
, srcval
| mask
);
797 srcoffset
= decode_rm10_address(rl
);
799 shiftreg
= DECODE_RM_WORD_REGISTER(rh
);
801 bit
= *shiftreg
& 0xF;
802 disp
= (s16
)*shiftreg
>> 4;
803 srcval
= fetch_data_word(srcoffset
+disp
);
804 mask
= (u16
)(0x1 << bit
);
805 CONDITIONAL_SET_FLAG(srcval
& mask
,F_CF
);
806 store_data_word(srcoffset
+disp
, srcval
| mask
);
809 case 3: /* register to register */
810 if (M
.x86
.mode
& SYSMODE_PREFIX_DATA
) {
811 u32
*srcreg
,*shiftreg
;
814 srcreg
= DECODE_RM_LONG_REGISTER(rl
);
816 shiftreg
= DECODE_RM_LONG_REGISTER(rh
);
818 bit
= *shiftreg
& 0x1F;
820 CONDITIONAL_SET_FLAG(*srcreg
& mask
,F_CF
);
823 u16
*srcreg
,*shiftreg
;
826 srcreg
= DECODE_RM_WORD_REGISTER(rl
);
828 shiftreg
= DECODE_RM_WORD_REGISTER(rh
);
830 bit
= *shiftreg
& 0xF;
831 mask
= (u16
)(0x1 << bit
);
832 CONDITIONAL_SET_FLAG(*srcreg
& mask
,F_CF
);
837 DECODE_CLEAR_SEGOVR();
841 /****************************************************************************
843 Handles opcode 0x0f,0xac
844 ****************************************************************************/
845 void x86emuOp2_shrd_IMM(u8
X86EMU_UNUSED(op2
))
852 DECODE_PRINTF("SHLD\t");
853 FETCH_DECODE_MODRM(mod
, rh
, rl
);
856 if (M
.x86
.mode
& SYSMODE_PREFIX_DATA
) {
860 destoffset
= decode_rm00_address(rl
);
862 shiftreg
= DECODE_RM_LONG_REGISTER(rh
);
864 shift
= fetch_byte_imm();
865 DECODE_PRINTF2("%d\n", shift
);
867 destval
= fetch_data_long(destoffset
);
868 destval
= shrd_long(destval
,*shiftreg
,shift
);
869 store_data_long(destoffset
, destval
);
874 destoffset
= decode_rm00_address(rl
);
876 shiftreg
= DECODE_RM_WORD_REGISTER(rh
);
878 shift
= fetch_byte_imm();
879 DECODE_PRINTF2("%d\n", shift
);
881 destval
= fetch_data_word(destoffset
);
882 destval
= shrd_word(destval
,*shiftreg
,shift
);
883 store_data_word(destoffset
, destval
);
887 if (M
.x86
.mode
& SYSMODE_PREFIX_DATA
) {
891 destoffset
= decode_rm01_address(rl
);
893 shiftreg
= DECODE_RM_LONG_REGISTER(rh
);
895 shift
= fetch_byte_imm();
896 DECODE_PRINTF2("%d\n", shift
);
898 destval
= fetch_data_long(destoffset
);
899 destval
= shrd_long(destval
,*shiftreg
,shift
);
900 store_data_long(destoffset
, destval
);
905 destoffset
= decode_rm01_address(rl
);
907 shiftreg
= DECODE_RM_WORD_REGISTER(rh
);
909 shift
= fetch_byte_imm();
910 DECODE_PRINTF2("%d\n", shift
);
912 destval
= fetch_data_word(destoffset
);
913 destval
= shrd_word(destval
,*shiftreg
,shift
);
914 store_data_word(destoffset
, destval
);
918 if (M
.x86
.mode
& SYSMODE_PREFIX_DATA
) {
922 destoffset
= decode_rm10_address(rl
);
924 shiftreg
= DECODE_RM_LONG_REGISTER(rh
);
926 shift
= fetch_byte_imm();
927 DECODE_PRINTF2("%d\n", shift
);
929 destval
= fetch_data_long(destoffset
);
930 destval
= shrd_long(destval
,*shiftreg
,shift
);
931 store_data_long(destoffset
, destval
);
936 destoffset
= decode_rm10_address(rl
);
938 shiftreg
= DECODE_RM_WORD_REGISTER(rh
);
940 shift
= fetch_byte_imm();
941 DECODE_PRINTF2("%d\n", shift
);
943 destval
= fetch_data_word(destoffset
);
944 destval
= shrd_word(destval
,*shiftreg
,shift
);
945 store_data_word(destoffset
, destval
);
948 case 3: /* register to register */
949 if (M
.x86
.mode
& SYSMODE_PREFIX_DATA
) {
950 u32
*destreg
,*shiftreg
;
952 destreg
= DECODE_RM_LONG_REGISTER(rl
);
954 shiftreg
= DECODE_RM_LONG_REGISTER(rh
);
956 shift
= fetch_byte_imm();
957 DECODE_PRINTF2("%d\n", shift
);
959 *destreg
= shrd_long(*destreg
,*shiftreg
,shift
);
961 u16
*destreg
,*shiftreg
;
963 destreg
= DECODE_RM_WORD_REGISTER(rl
);
965 shiftreg
= DECODE_RM_WORD_REGISTER(rh
);
967 shift
= fetch_byte_imm();
968 DECODE_PRINTF2("%d\n", shift
);
970 *destreg
= shrd_word(*destreg
,*shiftreg
,shift
);
974 DECODE_CLEAR_SEGOVR();
978 /****************************************************************************
980 Handles opcode 0x0f,0xad
981 ****************************************************************************/
982 void x86emuOp2_shrd_CL(u8
X86EMU_UNUSED(op2
))
988 DECODE_PRINTF("SHLD\t");
989 FETCH_DECODE_MODRM(mod
, rh
, rl
);
992 if (M
.x86
.mode
& SYSMODE_PREFIX_DATA
) {
996 destoffset
= decode_rm00_address(rl
);
998 shiftreg
= DECODE_RM_LONG_REGISTER(rh
);
999 DECODE_PRINTF(",CL\n");
1001 destval
= fetch_data_long(destoffset
);
1002 destval
= shrd_long(destval
,*shiftreg
,M
.x86
.R_CL
);
1003 store_data_long(destoffset
, destval
);
1008 destoffset
= decode_rm00_address(rl
);
1010 shiftreg
= DECODE_RM_WORD_REGISTER(rh
);
1011 DECODE_PRINTF(",CL\n");
1013 destval
= fetch_data_word(destoffset
);
1014 destval
= shrd_word(destval
,*shiftreg
,M
.x86
.R_CL
);
1015 store_data_word(destoffset
, destval
);
1019 if (M
.x86
.mode
& SYSMODE_PREFIX_DATA
) {
1023 destoffset
= decode_rm01_address(rl
);
1025 shiftreg
= DECODE_RM_LONG_REGISTER(rh
);
1026 DECODE_PRINTF(",CL\n");
1028 destval
= fetch_data_long(destoffset
);
1029 destval
= shrd_long(destval
,*shiftreg
,M
.x86
.R_CL
);
1030 store_data_long(destoffset
, destval
);
1035 destoffset
= decode_rm01_address(rl
);
1037 shiftreg
= DECODE_RM_WORD_REGISTER(rh
);
1038 DECODE_PRINTF(",CL\n");
1040 destval
= fetch_data_word(destoffset
);
1041 destval
= shrd_word(destval
,*shiftreg
,M
.x86
.R_CL
);
1042 store_data_word(destoffset
, destval
);
1046 if (M
.x86
.mode
& SYSMODE_PREFIX_DATA
) {
1050 destoffset
= decode_rm10_address(rl
);
1052 shiftreg
= DECODE_RM_LONG_REGISTER(rh
);
1053 DECODE_PRINTF(",CL\n");
1055 destval
= fetch_data_long(destoffset
);
1056 destval
= shrd_long(destval
,*shiftreg
,M
.x86
.R_CL
);
1057 store_data_long(destoffset
, destval
);
1062 destoffset
= decode_rm10_address(rl
);
1064 shiftreg
= DECODE_RM_WORD_REGISTER(rh
);
1065 DECODE_PRINTF(",CL\n");
1067 destval
= fetch_data_word(destoffset
);
1068 destval
= shrd_word(destval
,*shiftreg
,M
.x86
.R_CL
);
1069 store_data_word(destoffset
, destval
);
1072 case 3: /* register to register */
1073 if (M
.x86
.mode
& SYSMODE_PREFIX_DATA
) {
1074 u32
*destreg
,*shiftreg
;
1076 destreg
= DECODE_RM_LONG_REGISTER(rl
);
1078 shiftreg
= DECODE_RM_LONG_REGISTER(rh
);
1079 DECODE_PRINTF(",CL\n");
1081 *destreg
= shrd_long(*destreg
,*shiftreg
,M
.x86
.R_CL
);
1083 u16
*destreg
,*shiftreg
;
1085 destreg
= DECODE_RM_WORD_REGISTER(rl
);
1087 shiftreg
= DECODE_RM_WORD_REGISTER(rh
);
1088 DECODE_PRINTF(",CL\n");
1090 *destreg
= shrd_word(*destreg
,*shiftreg
,M
.x86
.R_CL
);
1094 DECODE_CLEAR_SEGOVR();
1098 /****************************************************************************
1100 Handles opcode 0x0f,0xaf
1101 ****************************************************************************/
1102 void x86emuOp2_imul_R_RM(u8
X86EMU_UNUSED(op2
))
1108 DECODE_PRINTF("IMUL\t");
1109 FETCH_DECODE_MODRM(mod
, rh
, rl
);
1112 if (M
.x86
.mode
& SYSMODE_PREFIX_DATA
) {
1117 destreg
= DECODE_RM_LONG_REGISTER(rh
);
1119 srcoffset
= decode_rm00_address(rl
);
1120 srcval
= fetch_data_long(srcoffset
);
1122 imul_long_direct(&res_lo
,&res_hi
,(s32
)*destreg
,(s32
)srcval
);
1130 *destreg
= (u32
)res_lo
;
1136 destreg
= DECODE_RM_WORD_REGISTER(rh
);
1138 srcoffset
= decode_rm00_address(rl
);
1139 srcval
= fetch_data_word(srcoffset
);
1141 res
= (s16
)*destreg
* (s16
)srcval
;
1149 *destreg
= (u16
)res
;
1153 if (M
.x86
.mode
& SYSMODE_PREFIX_DATA
) {
1158 destreg
= DECODE_RM_LONG_REGISTER(rh
);
1160 srcoffset
= decode_rm01_address(rl
);
1161 srcval
= fetch_data_long(srcoffset
);
1163 imul_long_direct(&res_lo
,&res_hi
,(s32
)*destreg
,(s32
)srcval
);
1171 *destreg
= (u32
)res_lo
;
1177 destreg
= DECODE_RM_WORD_REGISTER(rh
);
1179 srcoffset
= decode_rm01_address(rl
);
1180 srcval
= fetch_data_word(srcoffset
);
1182 res
= (s16
)*destreg
* (s16
)srcval
;
1190 *destreg
= (u16
)res
;
1194 if (M
.x86
.mode
& SYSMODE_PREFIX_DATA
) {
1199 destreg
= DECODE_RM_LONG_REGISTER(rh
);
1201 srcoffset
= decode_rm10_address(rl
);
1202 srcval
= fetch_data_long(srcoffset
);
1204 imul_long_direct(&res_lo
,&res_hi
,(s32
)*destreg
,(s32
)srcval
);
1212 *destreg
= (u32
)res_lo
;
1218 destreg
= DECODE_RM_WORD_REGISTER(rh
);
1220 srcoffset
= decode_rm10_address(rl
);
1221 srcval
= fetch_data_word(srcoffset
);
1223 res
= (s16
)*destreg
* (s16
)srcval
;
1231 *destreg
= (u16
)res
;
1234 case 3: /* register to register */
1235 if (M
.x86
.mode
& SYSMODE_PREFIX_DATA
) {
1236 u32
*destreg
,*srcreg
;
1239 destreg
= DECODE_RM_LONG_REGISTER(rh
);
1241 srcreg
= DECODE_RM_LONG_REGISTER(rl
);
1243 imul_long_direct(&res_lo
,&res_hi
,(s32
)*destreg
,(s32
)*srcreg
);
1251 *destreg
= (u32
)res_lo
;
1253 u16
*destreg
,*srcreg
;
1256 destreg
= DECODE_RM_WORD_REGISTER(rh
);
1258 srcreg
= DECODE_RM_WORD_REGISTER(rl
);
1259 res
= (s16
)*destreg
* (s16
)*srcreg
;
1267 *destreg
= (u16
)res
;
1271 DECODE_CLEAR_SEGOVR();
1275 /****************************************************************************
1277 Handles opcode 0x0f,0xb2
1278 ****************************************************************************/
1279 void x86emuOp2_lss_R_IMM(u8
X86EMU_UNUSED(op2
))
1286 DECODE_PRINTF("LSS\t");
1287 FETCH_DECODE_MODRM(mod
, rh
, rl
);
1290 dstreg
= DECODE_RM_WORD_REGISTER(rh
);
1292 srcoffset
= decode_rm00_address(rl
);
1293 DECODE_PRINTF("\n");
1295 *dstreg
= fetch_data_word(srcoffset
);
1296 M
.x86
.R_SS
= fetch_data_word(srcoffset
+ 2);
1299 dstreg
= DECODE_RM_WORD_REGISTER(rh
);
1301 srcoffset
= decode_rm01_address(rl
);
1302 DECODE_PRINTF("\n");
1304 *dstreg
= fetch_data_word(srcoffset
);
1305 M
.x86
.R_SS
= fetch_data_word(srcoffset
+ 2);
1308 dstreg
= DECODE_RM_WORD_REGISTER(rh
);
1310 srcoffset
= decode_rm10_address(rl
);
1311 DECODE_PRINTF("\n");
1313 *dstreg
= fetch_data_word(srcoffset
);
1314 M
.x86
.R_SS
= fetch_data_word(srcoffset
+ 2);
1316 case 3: /* register to register */
1320 DECODE_CLEAR_SEGOVR();
1324 /****************************************************************************
1326 Handles opcode 0x0f,0xb3
1327 ****************************************************************************/
1328 void x86emuOp2_btr_R(u8
X86EMU_UNUSED(op2
))
1335 DECODE_PRINTF("BTR\t");
1336 FETCH_DECODE_MODRM(mod
, rh
, rl
);
1339 if (M
.x86
.mode
& SYSMODE_PREFIX_DATA
) {
1343 srcoffset
= decode_rm00_address(rl
);
1345 shiftreg
= DECODE_RM_LONG_REGISTER(rh
);
1347 bit
= *shiftreg
& 0x1F;
1348 disp
= (s16
)*shiftreg
>> 5;
1349 srcval
= fetch_data_long(srcoffset
+disp
);
1350 mask
= (0x1 << bit
);
1351 CONDITIONAL_SET_FLAG(srcval
& mask
,F_CF
);
1352 store_data_long(srcoffset
+disp
, srcval
& ~mask
);
1357 srcoffset
= decode_rm00_address(rl
);
1359 shiftreg
= DECODE_RM_WORD_REGISTER(rh
);
1361 bit
= *shiftreg
& 0xF;
1362 disp
= (s16
)*shiftreg
>> 4;
1363 srcval
= fetch_data_word(srcoffset
+disp
);
1364 mask
= (u16
)(0x1 << bit
);
1365 CONDITIONAL_SET_FLAG(srcval
& mask
,F_CF
);
1366 store_data_word(srcoffset
+disp
, (u16
)(srcval
& ~mask
));
1370 if (M
.x86
.mode
& SYSMODE_PREFIX_DATA
) {
1374 srcoffset
= decode_rm01_address(rl
);
1376 shiftreg
= DECODE_RM_LONG_REGISTER(rh
);
1378 bit
= *shiftreg
& 0x1F;
1379 disp
= (s16
)*shiftreg
>> 5;
1380 srcval
= fetch_data_long(srcoffset
+disp
);
1381 mask
= (0x1 << bit
);
1382 CONDITIONAL_SET_FLAG(srcval
& mask
,F_CF
);
1383 store_data_long(srcoffset
+disp
, srcval
& ~mask
);
1388 srcoffset
= decode_rm01_address(rl
);
1390 shiftreg
= DECODE_RM_WORD_REGISTER(rh
);
1392 bit
= *shiftreg
& 0xF;
1393 disp
= (s16
)*shiftreg
>> 4;
1394 srcval
= fetch_data_word(srcoffset
+disp
);
1395 mask
= (u16
)(0x1 << bit
);
1396 CONDITIONAL_SET_FLAG(srcval
& mask
,F_CF
);
1397 store_data_word(srcoffset
+disp
, (u16
)(srcval
& ~mask
));
1401 if (M
.x86
.mode
& SYSMODE_PREFIX_DATA
) {
1405 srcoffset
= decode_rm10_address(rl
);
1407 shiftreg
= DECODE_RM_LONG_REGISTER(rh
);
1409 bit
= *shiftreg
& 0x1F;
1410 disp
= (s16
)*shiftreg
>> 5;
1411 srcval
= fetch_data_long(srcoffset
+disp
);
1412 mask
= (0x1 << bit
);
1413 CONDITIONAL_SET_FLAG(srcval
& mask
,F_CF
);
1414 store_data_long(srcoffset
+disp
, srcval
& ~mask
);
1419 srcoffset
= decode_rm10_address(rl
);
1421 shiftreg
= DECODE_RM_WORD_REGISTER(rh
);
1423 bit
= *shiftreg
& 0xF;
1424 disp
= (s16
)*shiftreg
>> 4;
1425 srcval
= fetch_data_word(srcoffset
+disp
);
1426 mask
= (u16
)(0x1 << bit
);
1427 CONDITIONAL_SET_FLAG(srcval
& mask
,F_CF
);
1428 store_data_word(srcoffset
+disp
, (u16
)(srcval
& ~mask
));
1431 case 3: /* register to register */
1432 if (M
.x86
.mode
& SYSMODE_PREFIX_DATA
) {
1433 u32
*srcreg
,*shiftreg
;
1436 srcreg
= DECODE_RM_LONG_REGISTER(rl
);
1438 shiftreg
= DECODE_RM_LONG_REGISTER(rh
);
1440 bit
= *shiftreg
& 0x1F;
1441 mask
= (0x1 << bit
);
1442 CONDITIONAL_SET_FLAG(*srcreg
& mask
,F_CF
);
1445 u16
*srcreg
,*shiftreg
;
1448 srcreg
= DECODE_RM_WORD_REGISTER(rl
);
1450 shiftreg
= DECODE_RM_WORD_REGISTER(rh
);
1452 bit
= *shiftreg
& 0xF;
1453 mask
= (u16
)(0x1 << bit
);
1454 CONDITIONAL_SET_FLAG(*srcreg
& mask
,F_CF
);
1459 DECODE_CLEAR_SEGOVR();
1463 /****************************************************************************
1465 Handles opcode 0x0f,0xb4
1466 ****************************************************************************/
1467 void x86emuOp2_lfs_R_IMM(u8
X86EMU_UNUSED(op2
))
1474 DECODE_PRINTF("LFS\t");
1475 FETCH_DECODE_MODRM(mod
, rh
, rl
);
1478 dstreg
= DECODE_RM_WORD_REGISTER(rh
);
1480 srcoffset
= decode_rm00_address(rl
);
1481 DECODE_PRINTF("\n");
1483 *dstreg
= fetch_data_word(srcoffset
);
1484 M
.x86
.R_FS
= fetch_data_word(srcoffset
+ 2);
1487 dstreg
= DECODE_RM_WORD_REGISTER(rh
);
1489 srcoffset
= decode_rm01_address(rl
);
1490 DECODE_PRINTF("\n");
1492 *dstreg
= fetch_data_word(srcoffset
);
1493 M
.x86
.R_FS
= fetch_data_word(srcoffset
+ 2);
1496 dstreg
= DECODE_RM_WORD_REGISTER(rh
);
1498 srcoffset
= decode_rm10_address(rl
);
1499 DECODE_PRINTF("\n");
1501 *dstreg
= fetch_data_word(srcoffset
);
1502 M
.x86
.R_FS
= fetch_data_word(srcoffset
+ 2);
1504 case 3: /* register to register */
1508 DECODE_CLEAR_SEGOVR();
1512 /****************************************************************************
1514 Handles opcode 0x0f,0xb5
1515 ****************************************************************************/
1516 void x86emuOp2_lgs_R_IMM(u8
X86EMU_UNUSED(op2
))
1523 DECODE_PRINTF("LGS\t");
1524 FETCH_DECODE_MODRM(mod
, rh
, rl
);
1527 dstreg
= DECODE_RM_WORD_REGISTER(rh
);
1529 srcoffset
= decode_rm00_address(rl
);
1530 DECODE_PRINTF("\n");
1532 *dstreg
= fetch_data_word(srcoffset
);
1533 M
.x86
.R_GS
= fetch_data_word(srcoffset
+ 2);
1536 dstreg
= DECODE_RM_WORD_REGISTER(rh
);
1538 srcoffset
= decode_rm01_address(rl
);
1539 DECODE_PRINTF("\n");
1541 *dstreg
= fetch_data_word(srcoffset
);
1542 M
.x86
.R_GS
= fetch_data_word(srcoffset
+ 2);
1545 dstreg
= DECODE_RM_WORD_REGISTER(rh
);
1547 srcoffset
= decode_rm10_address(rl
);
1548 DECODE_PRINTF("\n");
1550 *dstreg
= fetch_data_word(srcoffset
);
1551 M
.x86
.R_GS
= fetch_data_word(srcoffset
+ 2);
1553 case 3: /* register to register */
1557 DECODE_CLEAR_SEGOVR();
1561 /****************************************************************************
1563 Handles opcode 0x0f,0xb6
1564 ****************************************************************************/
1565 void x86emuOp2_movzx_byte_R_RM(u8
X86EMU_UNUSED(op2
))
1571 DECODE_PRINTF("MOVZX\t");
1572 FETCH_DECODE_MODRM(mod
, rh
, rl
);
1575 if (M
.x86
.mode
& SYSMODE_PREFIX_DATA
) {
1579 destreg
= DECODE_RM_LONG_REGISTER(rh
);
1581 srcoffset
= decode_rm00_address(rl
);
1582 srcval
= fetch_data_byte(srcoffset
);
1583 DECODE_PRINTF("\n");
1590 destreg
= DECODE_RM_WORD_REGISTER(rh
);
1592 srcoffset
= decode_rm00_address(rl
);
1593 srcval
= fetch_data_byte(srcoffset
);
1594 DECODE_PRINTF("\n");
1600 if (M
.x86
.mode
& SYSMODE_PREFIX_DATA
) {
1604 destreg
= DECODE_RM_LONG_REGISTER(rh
);
1606 srcoffset
= decode_rm01_address(rl
);
1607 srcval
= fetch_data_byte(srcoffset
);
1608 DECODE_PRINTF("\n");
1615 destreg
= DECODE_RM_WORD_REGISTER(rh
);
1617 srcoffset
= decode_rm01_address(rl
);
1618 srcval
= fetch_data_byte(srcoffset
);
1619 DECODE_PRINTF("\n");
1625 if (M
.x86
.mode
& SYSMODE_PREFIX_DATA
) {
1629 destreg
= DECODE_RM_LONG_REGISTER(rh
);
1631 srcoffset
= decode_rm10_address(rl
);
1632 srcval
= fetch_data_byte(srcoffset
);
1633 DECODE_PRINTF("\n");
1640 destreg
= DECODE_RM_WORD_REGISTER(rh
);
1642 srcoffset
= decode_rm10_address(rl
);
1643 srcval
= fetch_data_byte(srcoffset
);
1644 DECODE_PRINTF("\n");
1649 case 3: /* register to register */
1650 if (M
.x86
.mode
& SYSMODE_PREFIX_DATA
) {
1654 destreg
= DECODE_RM_LONG_REGISTER(rh
);
1656 srcreg
= DECODE_RM_BYTE_REGISTER(rl
);
1657 DECODE_PRINTF("\n");
1664 destreg
= DECODE_RM_WORD_REGISTER(rh
);
1666 srcreg
= DECODE_RM_BYTE_REGISTER(rl
);
1667 DECODE_PRINTF("\n");
1673 DECODE_CLEAR_SEGOVR();
1677 /****************************************************************************
1679 Handles opcode 0x0f,0xb7
1680 ****************************************************************************/
1681 void x86emuOp2_movzx_word_R_RM(u8
X86EMU_UNUSED(op2
))
1690 DECODE_PRINTF("MOVZX\t");
1691 FETCH_DECODE_MODRM(mod
, rh
, rl
);
1694 destreg
= DECODE_RM_LONG_REGISTER(rh
);
1696 srcoffset
= decode_rm00_address(rl
);
1697 srcval
= fetch_data_word(srcoffset
);
1698 DECODE_PRINTF("\n");
1703 destreg
= DECODE_RM_LONG_REGISTER(rh
);
1705 srcoffset
= decode_rm01_address(rl
);
1706 srcval
= fetch_data_word(srcoffset
);
1707 DECODE_PRINTF("\n");
1712 destreg
= DECODE_RM_LONG_REGISTER(rh
);
1714 srcoffset
= decode_rm10_address(rl
);
1715 srcval
= fetch_data_word(srcoffset
);
1716 DECODE_PRINTF("\n");
1720 case 3: /* register to register */
1721 destreg
= DECODE_RM_LONG_REGISTER(rh
);
1723 srcreg
= DECODE_RM_WORD_REGISTER(rl
);
1724 DECODE_PRINTF("\n");
1729 DECODE_CLEAR_SEGOVR();
1733 /****************************************************************************
1735 Handles opcode 0x0f,0xba
1736 ****************************************************************************/
1737 void x86emuOp2_btX_I(u8
X86EMU_UNUSED(op2
))
1744 FETCH_DECODE_MODRM(mod
, rh
, rl
);
1747 DECODE_PRINTF("BT\t");
1750 DECODE_PRINTF("BTS\t");
1753 DECODE_PRINTF("BTR\t");
1756 DECODE_PRINTF("BTC\t");
1759 DECODE_PRINTF("ILLEGAL EXTENDED X86 OPCODE\n");
1761 printk("%04x:%04x: %02X%02X ILLEGAL EXTENDED X86 OPCODE EXTENSION!\n",
1762 M
.x86
.R_CS
, M
.x86
.R_IP
-3,op2
, (mod
<<6)|(rh
<<3)|rl
);
1767 if (M
.x86
.mode
& SYSMODE_PREFIX_DATA
) {
1771 srcoffset
= decode_rm00_address(rl
);
1773 shift
= fetch_byte_imm();
1776 srcval
= fetch_data_long(srcoffset
);
1777 mask
= (0x1 << bit
);
1778 CONDITIONAL_SET_FLAG(srcval
& mask
,F_CF
);
1781 store_data_long(srcoffset
, srcval
| mask
);
1784 store_data_long(srcoffset
, srcval
& ~mask
);
1787 store_data_long(srcoffset
, srcval
^ mask
);
1796 srcoffset
= decode_rm00_address(rl
);
1798 shift
= fetch_byte_imm();
1801 srcval
= fetch_data_word(srcoffset
);
1802 mask
= (0x1 << bit
);
1803 CONDITIONAL_SET_FLAG(srcval
& mask
,F_CF
);
1806 store_data_word(srcoffset
, srcval
| mask
);
1809 store_data_word(srcoffset
, srcval
& ~mask
);
1812 store_data_word(srcoffset
, srcval
^ mask
);
1820 if (M
.x86
.mode
& SYSMODE_PREFIX_DATA
) {
1824 srcoffset
= decode_rm01_address(rl
);
1826 shift
= fetch_byte_imm();
1829 srcval
= fetch_data_long(srcoffset
);
1830 mask
= (0x1 << bit
);
1831 CONDITIONAL_SET_FLAG(srcval
& mask
,F_CF
);
1834 store_data_long(srcoffset
, srcval
| mask
);
1837 store_data_long(srcoffset
, srcval
& ~mask
);
1840 store_data_long(srcoffset
, srcval
^ mask
);
1849 srcoffset
= decode_rm01_address(rl
);
1851 shift
= fetch_byte_imm();
1854 srcval
= fetch_data_word(srcoffset
);
1855 mask
= (0x1 << bit
);
1856 CONDITIONAL_SET_FLAG(srcval
& mask
,F_CF
);
1859 store_data_word(srcoffset
, srcval
| mask
);
1862 store_data_word(srcoffset
, srcval
& ~mask
);
1865 store_data_word(srcoffset
, srcval
^ mask
);
1873 if (M
.x86
.mode
& SYSMODE_PREFIX_DATA
) {
1877 srcoffset
= decode_rm10_address(rl
);
1879 shift
= fetch_byte_imm();
1882 srcval
= fetch_data_long(srcoffset
);
1883 mask
= (0x1 << bit
);
1884 CONDITIONAL_SET_FLAG(srcval
& mask
,F_CF
);
1887 store_data_long(srcoffset
, srcval
| mask
);
1890 store_data_long(srcoffset
, srcval
& ~mask
);
1893 store_data_long(srcoffset
, srcval
^ mask
);
1902 srcoffset
= decode_rm10_address(rl
);
1904 shift
= fetch_byte_imm();
1907 srcval
= fetch_data_word(srcoffset
);
1908 mask
= (0x1 << bit
);
1909 CONDITIONAL_SET_FLAG(srcval
& mask
,F_CF
);
1912 store_data_word(srcoffset
, srcval
| mask
);
1915 store_data_word(srcoffset
, srcval
& ~mask
);
1918 store_data_word(srcoffset
, srcval
^ mask
);
1925 case 3: /* register to register */
1926 if (M
.x86
.mode
& SYSMODE_PREFIX_DATA
) {
1931 srcreg
= DECODE_RM_LONG_REGISTER(rl
);
1933 shift
= fetch_byte_imm();
1936 mask
= (0x1 << bit
);
1937 CONDITIONAL_SET_FLAG(*srcreg
& mask
,F_CF
);
1956 srcreg
= DECODE_RM_WORD_REGISTER(rl
);
1958 shift
= fetch_byte_imm();
1961 mask
= (0x1 << bit
);
1962 CONDITIONAL_SET_FLAG(*srcreg
& mask
,F_CF
);
1979 DECODE_CLEAR_SEGOVR();
1983 /****************************************************************************
1985 Handles opcode 0x0f,0xbb
1986 ****************************************************************************/
1987 void x86emuOp2_btc_R(u8
X86EMU_UNUSED(op2
))
1994 DECODE_PRINTF("BTC\t");
1995 FETCH_DECODE_MODRM(mod
, rh
, rl
);
1998 if (M
.x86
.mode
& SYSMODE_PREFIX_DATA
) {
2002 srcoffset
= decode_rm00_address(rl
);
2004 shiftreg
= DECODE_RM_LONG_REGISTER(rh
);
2006 bit
= *shiftreg
& 0x1F;
2007 disp
= (s16
)*shiftreg
>> 5;
2008 srcval
= fetch_data_long(srcoffset
+disp
);
2009 mask
= (0x1 << bit
);
2010 CONDITIONAL_SET_FLAG(srcval
& mask
,F_CF
);
2011 store_data_long(srcoffset
+disp
, srcval
^ mask
);
2016 srcoffset
= decode_rm00_address(rl
);
2018 shiftreg
= DECODE_RM_WORD_REGISTER(rh
);
2020 bit
= *shiftreg
& 0xF;
2021 disp
= (s16
)*shiftreg
>> 4;
2022 srcval
= fetch_data_word(srcoffset
+disp
);
2023 mask
= (u16
)(0x1 << bit
);
2024 CONDITIONAL_SET_FLAG(srcval
& mask
,F_CF
);
2025 store_data_word(srcoffset
+disp
, (u16
)(srcval
^ mask
));
2029 if (M
.x86
.mode
& SYSMODE_PREFIX_DATA
) {
2033 srcoffset
= decode_rm01_address(rl
);
2035 shiftreg
= DECODE_RM_LONG_REGISTER(rh
);
2037 bit
= *shiftreg
& 0x1F;
2038 disp
= (s16
)*shiftreg
>> 5;
2039 srcval
= fetch_data_long(srcoffset
+disp
);
2040 mask
= (0x1 << bit
);
2041 CONDITIONAL_SET_FLAG(srcval
& mask
,F_CF
);
2042 store_data_long(srcoffset
+disp
, srcval
^ mask
);
2047 srcoffset
= decode_rm01_address(rl
);
2049 shiftreg
= DECODE_RM_WORD_REGISTER(rh
);
2051 bit
= *shiftreg
& 0xF;
2052 disp
= (s16
)*shiftreg
>> 4;
2053 srcval
= fetch_data_word(srcoffset
+disp
);
2054 mask
= (u16
)(0x1 << bit
);
2055 CONDITIONAL_SET_FLAG(srcval
& mask
,F_CF
);
2056 store_data_word(srcoffset
+disp
, (u16
)(srcval
^ mask
));
2060 if (M
.x86
.mode
& SYSMODE_PREFIX_DATA
) {
2064 srcoffset
= decode_rm10_address(rl
);
2066 shiftreg
= DECODE_RM_LONG_REGISTER(rh
);
2068 bit
= *shiftreg
& 0x1F;
2069 disp
= (s16
)*shiftreg
>> 5;
2070 srcval
= fetch_data_long(srcoffset
+disp
);
2071 mask
= (0x1 << bit
);
2072 CONDITIONAL_SET_FLAG(srcval
& mask
,F_CF
);
2073 store_data_long(srcoffset
+disp
, srcval
^ mask
);
2078 srcoffset
= decode_rm10_address(rl
);
2080 shiftreg
= DECODE_RM_WORD_REGISTER(rh
);
2082 bit
= *shiftreg
& 0xF;
2083 disp
= (s16
)*shiftreg
>> 4;
2084 srcval
= fetch_data_word(srcoffset
+disp
);
2085 mask
= (u16
)(0x1 << bit
);
2086 CONDITIONAL_SET_FLAG(srcval
& mask
,F_CF
);
2087 store_data_word(srcoffset
+disp
, (u16
)(srcval
^ mask
));
2090 case 3: /* register to register */
2091 if (M
.x86
.mode
& SYSMODE_PREFIX_DATA
) {
2092 u32
*srcreg
,*shiftreg
;
2095 srcreg
= DECODE_RM_LONG_REGISTER(rl
);
2097 shiftreg
= DECODE_RM_LONG_REGISTER(rh
);
2099 bit
= *shiftreg
& 0x1F;
2100 mask
= (0x1 << bit
);
2101 CONDITIONAL_SET_FLAG(*srcreg
& mask
,F_CF
);
2104 u16
*srcreg
,*shiftreg
;
2107 srcreg
= DECODE_RM_WORD_REGISTER(rl
);
2109 shiftreg
= DECODE_RM_WORD_REGISTER(rh
);
2111 bit
= *shiftreg
& 0xF;
2112 mask
= (u16
)(0x1 << bit
);
2113 CONDITIONAL_SET_FLAG(*srcreg
& mask
,F_CF
);
2118 DECODE_CLEAR_SEGOVR();
2122 /****************************************************************************
2124 Handles opcode 0x0f,0xbc
2125 ****************************************************************************/
2126 void x86emuOp2_bsf(u8
X86EMU_UNUSED(op2
))
2132 DECODE_PRINTF("BSF\n");
2133 FETCH_DECODE_MODRM(mod
, rh
, rl
);
2136 if (M
.x86
.mode
& SYSMODE_PREFIX_DATA
) {
2137 u32 srcval
, *dstreg
;
2139 srcoffset
= decode_rm00_address(rl
);
2141 dstreg
= DECODE_RM_LONG_REGISTER(rh
);
2143 srcval
= fetch_data_long(srcoffset
);
2144 CONDITIONAL_SET_FLAG(srcval
== 0, F_ZF
);
2145 for(*dstreg
= 0; *dstreg
< 32; (*dstreg
)++)
2146 if ((srcval
>> *dstreg
) & 1) break;
2148 u16 srcval
, *dstreg
;
2150 srcoffset
= decode_rm00_address(rl
);
2152 dstreg
= DECODE_RM_WORD_REGISTER(rh
);
2154 srcval
= fetch_data_word(srcoffset
);
2155 CONDITIONAL_SET_FLAG(srcval
== 0, F_ZF
);
2156 for(*dstreg
= 0; *dstreg
< 16; (*dstreg
)++)
2157 if ((srcval
>> *dstreg
) & 1) break;
2161 if (M
.x86
.mode
& SYSMODE_PREFIX_DATA
) {
2162 u32 srcval
, *dstreg
;
2164 srcoffset
= decode_rm01_address(rl
);
2166 dstreg
= DECODE_RM_LONG_REGISTER(rh
);
2168 srcval
= fetch_data_long(srcoffset
);
2169 CONDITIONAL_SET_FLAG(srcval
== 0, F_ZF
);
2170 for(*dstreg
= 0; *dstreg
< 32; (*dstreg
)++)
2171 if ((srcval
>> *dstreg
) & 1) break;
2173 u16 srcval
, *dstreg
;
2175 srcoffset
= decode_rm01_address(rl
);
2177 dstreg
= DECODE_RM_WORD_REGISTER(rh
);
2179 srcval
= fetch_data_word(srcoffset
);
2180 CONDITIONAL_SET_FLAG(srcval
== 0, F_ZF
);
2181 for(*dstreg
= 0; *dstreg
< 16; (*dstreg
)++)
2182 if ((srcval
>> *dstreg
) & 1) break;
2186 if (M
.x86
.mode
& SYSMODE_PREFIX_DATA
) {
2187 u32 srcval
, *dstreg
;
2189 srcoffset
= decode_rm10_address(rl
);
2191 dstreg
= DECODE_RM_LONG_REGISTER(rh
);
2193 srcval
= fetch_data_long(srcoffset
);
2194 CONDITIONAL_SET_FLAG(srcval
== 0, F_ZF
);
2195 for(*dstreg
= 0; *dstreg
< 32; (*dstreg
)++)
2196 if ((srcval
>> *dstreg
) & 1) break;
2198 u16 srcval
, *dstreg
;
2200 srcoffset
= decode_rm10_address(rl
);
2202 dstreg
= DECODE_RM_WORD_REGISTER(rh
);
2204 srcval
= fetch_data_word(srcoffset
);
2205 CONDITIONAL_SET_FLAG(srcval
== 0, F_ZF
);
2206 for(*dstreg
= 0; *dstreg
< 16; (*dstreg
)++)
2207 if ((srcval
>> *dstreg
) & 1) break;
2210 case 3: /* register to register */
2211 if (M
.x86
.mode
& SYSMODE_PREFIX_DATA
) {
2212 u32
*srcreg
, *dstreg
;
2214 srcreg
= DECODE_RM_LONG_REGISTER(rl
);
2216 dstreg
= DECODE_RM_LONG_REGISTER(rh
);
2218 CONDITIONAL_SET_FLAG(*srcreg
== 0, F_ZF
);
2219 for(*dstreg
= 0; *dstreg
< 32; (*dstreg
)++)
2220 if ((*srcreg
>> *dstreg
) & 1) break;
2222 u16
*srcreg
, *dstreg
;
2224 srcreg
= DECODE_RM_WORD_REGISTER(rl
);
2226 dstreg
= DECODE_RM_WORD_REGISTER(rh
);
2228 CONDITIONAL_SET_FLAG(*srcreg
== 0, F_ZF
);
2229 for(*dstreg
= 0; *dstreg
< 16; (*dstreg
)++)
2230 if ((*srcreg
>> *dstreg
) & 1) break;
2234 DECODE_CLEAR_SEGOVR();
2238 /****************************************************************************
2240 Handles opcode 0x0f,0xbd
2241 ****************************************************************************/
2242 void x86emuOp2_bsr(u8
X86EMU_UNUSED(op2
))
2248 DECODE_PRINTF("BSF\n");
2249 FETCH_DECODE_MODRM(mod
, rh
, rl
);
2252 if (M
.x86
.mode
& SYSMODE_PREFIX_DATA
) {
2253 u32 srcval
, *dstreg
;
2255 srcoffset
= decode_rm00_address(rl
);
2257 dstreg
= DECODE_RM_LONG_REGISTER(rh
);
2259 srcval
= fetch_data_long(srcoffset
);
2260 CONDITIONAL_SET_FLAG(srcval
== 0, F_ZF
);
2261 for(*dstreg
= 31; *dstreg
> 0; (*dstreg
)--)
2262 if ((srcval
>> *dstreg
) & 1) break;
2264 u16 srcval
, *dstreg
;
2266 srcoffset
= decode_rm00_address(rl
);
2268 dstreg
= DECODE_RM_WORD_REGISTER(rh
);
2270 srcval
= fetch_data_word(srcoffset
);
2271 CONDITIONAL_SET_FLAG(srcval
== 0, F_ZF
);
2272 for(*dstreg
= 15; *dstreg
> 0; (*dstreg
)--)
2273 if ((srcval
>> *dstreg
) & 1) break;
2277 if (M
.x86
.mode
& SYSMODE_PREFIX_DATA
) {
2278 u32 srcval
, *dstreg
;
2280 srcoffset
= decode_rm01_address(rl
);
2282 dstreg
= DECODE_RM_LONG_REGISTER(rh
);
2284 srcval
= fetch_data_long(srcoffset
);
2285 CONDITIONAL_SET_FLAG(srcval
== 0, F_ZF
);
2286 for(*dstreg
= 31; *dstreg
> 0; (*dstreg
)--)
2287 if ((srcval
>> *dstreg
) & 1) break;
2289 u16 srcval
, *dstreg
;
2291 srcoffset
= decode_rm01_address(rl
);
2293 dstreg
= DECODE_RM_WORD_REGISTER(rh
);
2295 srcval
= fetch_data_word(srcoffset
);
2296 CONDITIONAL_SET_FLAG(srcval
== 0, F_ZF
);
2297 for(*dstreg
= 15; *dstreg
> 0; (*dstreg
)--)
2298 if ((srcval
>> *dstreg
) & 1) break;
2302 if (M
.x86
.mode
& SYSMODE_PREFIX_DATA
) {
2303 u32 srcval
, *dstreg
;
2305 srcoffset
= decode_rm10_address(rl
);
2307 dstreg
= DECODE_RM_LONG_REGISTER(rh
);
2309 srcval
= fetch_data_long(srcoffset
);
2310 CONDITIONAL_SET_FLAG(srcval
== 0, F_ZF
);
2311 for(*dstreg
= 31; *dstreg
> 0; (*dstreg
)--)
2312 if ((srcval
>> *dstreg
) & 1) break;
2314 u16 srcval
, *dstreg
;
2316 srcoffset
= decode_rm10_address(rl
);
2318 dstreg
= DECODE_RM_WORD_REGISTER(rh
);
2320 srcval
= fetch_data_word(srcoffset
);
2321 CONDITIONAL_SET_FLAG(srcval
== 0, F_ZF
);
2322 for(*dstreg
= 15; *dstreg
> 0; (*dstreg
)--)
2323 if ((srcval
>> *dstreg
) & 1) break;
2326 case 3: /* register to register */
2327 if (M
.x86
.mode
& SYSMODE_PREFIX_DATA
) {
2328 u32
*srcreg
, *dstreg
;
2330 srcreg
= DECODE_RM_LONG_REGISTER(rl
);
2332 dstreg
= DECODE_RM_LONG_REGISTER(rh
);
2334 CONDITIONAL_SET_FLAG(*srcreg
== 0, F_ZF
);
2335 for(*dstreg
= 31; *dstreg
> 0; (*dstreg
)--)
2336 if ((*srcreg
>> *dstreg
) & 1) break;
2338 u16
*srcreg
, *dstreg
;
2340 srcreg
= DECODE_RM_WORD_REGISTER(rl
);
2342 dstreg
= DECODE_RM_WORD_REGISTER(rh
);
2344 CONDITIONAL_SET_FLAG(*srcreg
== 0, F_ZF
);
2345 for(*dstreg
= 15; *dstreg
> 0; (*dstreg
)--)
2346 if ((*srcreg
>> *dstreg
) & 1) break;
2350 DECODE_CLEAR_SEGOVR();
2354 /****************************************************************************
2356 Handles opcode 0x0f,0xbe
2357 ****************************************************************************/
2358 void x86emuOp2_movsx_byte_R_RM(u8
X86EMU_UNUSED(op2
))
2364 DECODE_PRINTF("MOVSX\t");
2365 FETCH_DECODE_MODRM(mod
, rh
, rl
);
2368 if (M
.x86
.mode
& SYSMODE_PREFIX_DATA
) {
2372 destreg
= DECODE_RM_LONG_REGISTER(rh
);
2374 srcoffset
= decode_rm00_address(rl
);
2375 srcval
= (s32
)((s8
)fetch_data_byte(srcoffset
));
2376 DECODE_PRINTF("\n");
2383 destreg
= DECODE_RM_WORD_REGISTER(rh
);
2385 srcoffset
= decode_rm00_address(rl
);
2386 srcval
= (s16
)((s8
)fetch_data_byte(srcoffset
));
2387 DECODE_PRINTF("\n");
2393 if (M
.x86
.mode
& SYSMODE_PREFIX_DATA
) {
2397 destreg
= DECODE_RM_LONG_REGISTER(rh
);
2399 srcoffset
= decode_rm01_address(rl
);
2400 srcval
= (s32
)((s8
)fetch_data_byte(srcoffset
));
2401 DECODE_PRINTF("\n");
2408 destreg
= DECODE_RM_WORD_REGISTER(rh
);
2410 srcoffset
= decode_rm01_address(rl
);
2411 srcval
= (s16
)((s8
)fetch_data_byte(srcoffset
));
2412 DECODE_PRINTF("\n");
2418 if (M
.x86
.mode
& SYSMODE_PREFIX_DATA
) {
2422 destreg
= DECODE_RM_LONG_REGISTER(rh
);
2424 srcoffset
= decode_rm10_address(rl
);
2425 srcval
= (s32
)((s8
)fetch_data_byte(srcoffset
));
2426 DECODE_PRINTF("\n");
2433 destreg
= DECODE_RM_WORD_REGISTER(rh
);
2435 srcoffset
= decode_rm10_address(rl
);
2436 srcval
= (s16
)((s8
)fetch_data_byte(srcoffset
));
2437 DECODE_PRINTF("\n");
2442 case 3: /* register to register */
2443 if (M
.x86
.mode
& SYSMODE_PREFIX_DATA
) {
2447 destreg
= DECODE_RM_LONG_REGISTER(rh
);
2449 srcreg
= DECODE_RM_BYTE_REGISTER(rl
);
2450 DECODE_PRINTF("\n");
2452 *destreg
= (s32
)((s8
)*srcreg
);
2457 destreg
= DECODE_RM_WORD_REGISTER(rh
);
2459 srcreg
= DECODE_RM_BYTE_REGISTER(rl
);
2460 DECODE_PRINTF("\n");
2462 *destreg
= (s16
)((s8
)*srcreg
);
2466 DECODE_CLEAR_SEGOVR();
2470 /****************************************************************************
2472 Handles opcode 0x0f,0xbf
2473 ****************************************************************************/
2474 void x86emuOp2_movsx_word_R_RM(u8
X86EMU_UNUSED(op2
))
2483 DECODE_PRINTF("MOVSX\t");
2484 FETCH_DECODE_MODRM(mod
, rh
, rl
);
2487 destreg
= DECODE_RM_LONG_REGISTER(rh
);
2489 srcoffset
= decode_rm00_address(rl
);
2490 srcval
= (s32
)((s16
)fetch_data_word(srcoffset
));
2491 DECODE_PRINTF("\n");
2496 destreg
= DECODE_RM_LONG_REGISTER(rh
);
2498 srcoffset
= decode_rm01_address(rl
);
2499 srcval
= (s32
)((s16
)fetch_data_word(srcoffset
));
2500 DECODE_PRINTF("\n");
2505 destreg
= DECODE_RM_LONG_REGISTER(rh
);
2507 srcoffset
= decode_rm10_address(rl
);
2508 srcval
= (s32
)((s16
)fetch_data_word(srcoffset
));
2509 DECODE_PRINTF("\n");
2513 case 3: /* register to register */
2514 destreg
= DECODE_RM_LONG_REGISTER(rh
);
2516 srcreg
= DECODE_RM_WORD_REGISTER(rl
);
2517 DECODE_PRINTF("\n");
2519 *destreg
= (s32
)((s16
)*srcreg
);
2522 DECODE_CLEAR_SEGOVR();
2526 /***************************************************************************
2527 * Double byte operation code table:
2528 **************************************************************************/
2529 void (*x86emu_optab2
[256])(u8
) =
2531 /* 0x00 */ x86emuOp2_illegal_op
, /* Group F (ring 0 PM) */
2532 /* 0x01 */ x86emuOp2_illegal_op
, /* Group G (ring 0 PM) */
2533 /* 0x02 */ x86emuOp2_illegal_op
, /* lar (ring 0 PM) */
2534 /* 0x03 */ x86emuOp2_illegal_op
, /* lsl (ring 0 PM) */
2535 /* 0x04 */ x86emuOp2_illegal_op
,
2536 /* 0x05 */ x86emuOp2_illegal_op
, /* loadall (undocumented) */
2537 /* 0x06 */ x86emuOp2_illegal_op
, /* clts (ring 0 PM) */
2538 /* 0x07 */ x86emuOp2_illegal_op
, /* loadall (undocumented) */
2539 /* 0x08 */ x86emuOp2_illegal_op
, /* invd (ring 0 PM) */
2540 /* 0x09 */ x86emuOp2_illegal_op
, /* wbinvd (ring 0 PM) */
2541 /* 0x0a */ x86emuOp2_illegal_op
,
2542 /* 0x0b */ x86emuOp2_illegal_op
,
2543 /* 0x0c */ x86emuOp2_illegal_op
,
2544 /* 0x0d */ x86emuOp2_illegal_op
,
2545 /* 0x0e */ x86emuOp2_illegal_op
,
2546 /* 0x0f */ x86emuOp2_illegal_op
,
2548 /* 0x10 */ x86emuOp2_illegal_op
,
2549 /* 0x11 */ x86emuOp2_illegal_op
,
2550 /* 0x12 */ x86emuOp2_illegal_op
,
2551 /* 0x13 */ x86emuOp2_illegal_op
,
2552 /* 0x14 */ x86emuOp2_illegal_op
,
2553 /* 0x15 */ x86emuOp2_illegal_op
,
2554 /* 0x16 */ x86emuOp2_illegal_op
,
2555 /* 0x17 */ x86emuOp2_illegal_op
,
2556 /* 0x18 */ x86emuOp2_illegal_op
,
2557 /* 0x19 */ x86emuOp2_illegal_op
,
2558 /* 0x1a */ x86emuOp2_illegal_op
,
2559 /* 0x1b */ x86emuOp2_illegal_op
,
2560 /* 0x1c */ x86emuOp2_illegal_op
,
2561 /* 0x1d */ x86emuOp2_illegal_op
,
2562 /* 0x1e */ x86emuOp2_illegal_op
,
2563 /* 0x1f */ x86emuOp2_illegal_op
,
2565 /* 0x20 */ x86emuOp2_illegal_op
, /* mov reg32,creg (ring 0 PM) */
2566 /* 0x21 */ x86emuOp2_illegal_op
, /* mov reg32,dreg (ring 0 PM) */
2567 /* 0x22 */ x86emuOp2_illegal_op
, /* mov creg,reg32 (ring 0 PM) */
2568 /* 0x23 */ x86emuOp2_illegal_op
, /* mov dreg,reg32 (ring 0 PM) */
2569 /* 0x24 */ x86emuOp2_illegal_op
, /* mov reg32,treg (ring 0 PM) */
2570 /* 0x25 */ x86emuOp2_illegal_op
,
2571 /* 0x26 */ x86emuOp2_illegal_op
, /* mov treg,reg32 (ring 0 PM) */
2572 /* 0x27 */ x86emuOp2_illegal_op
,
2573 /* 0x28 */ x86emuOp2_illegal_op
,
2574 /* 0x29 */ x86emuOp2_illegal_op
,
2575 /* 0x2a */ x86emuOp2_illegal_op
,
2576 /* 0x2b */ x86emuOp2_illegal_op
,
2577 /* 0x2c */ x86emuOp2_illegal_op
,
2578 /* 0x2d */ x86emuOp2_illegal_op
,
2579 /* 0x2e */ x86emuOp2_illegal_op
,
2580 /* 0x2f */ x86emuOp2_illegal_op
,
2582 /* 0x30 */ x86emuOp2_illegal_op
,
2583 /* 0x31 */ x86emuOp2_illegal_op
,
2584 /* 0x32 */ x86emuOp2_illegal_op
,
2585 /* 0x33 */ x86emuOp2_illegal_op
,
2586 /* 0x34 */ x86emuOp2_illegal_op
,
2587 /* 0x35 */ x86emuOp2_illegal_op
,
2588 /* 0x36 */ x86emuOp2_illegal_op
,
2589 /* 0x37 */ x86emuOp2_illegal_op
,
2590 /* 0x38 */ x86emuOp2_illegal_op
,
2591 /* 0x39 */ x86emuOp2_illegal_op
,
2592 /* 0x3a */ x86emuOp2_illegal_op
,
2593 /* 0x3b */ x86emuOp2_illegal_op
,
2594 /* 0x3c */ x86emuOp2_illegal_op
,
2595 /* 0x3d */ x86emuOp2_illegal_op
,
2596 /* 0x3e */ x86emuOp2_illegal_op
,
2597 /* 0x3f */ x86emuOp2_illegal_op
,
2599 /* 0x40 */ x86emuOp2_illegal_op
,
2600 /* 0x41 */ x86emuOp2_illegal_op
,
2601 /* 0x42 */ x86emuOp2_illegal_op
,
2602 /* 0x43 */ x86emuOp2_illegal_op
,
2603 /* 0x44 */ x86emuOp2_illegal_op
,
2604 /* 0x45 */ x86emuOp2_illegal_op
,
2605 /* 0x46 */ x86emuOp2_illegal_op
,
2606 /* 0x47 */ x86emuOp2_illegal_op
,
2607 /* 0x48 */ x86emuOp2_illegal_op
,
2608 /* 0x49 */ x86emuOp2_illegal_op
,
2609 /* 0x4a */ x86emuOp2_illegal_op
,
2610 /* 0x4b */ x86emuOp2_illegal_op
,
2611 /* 0x4c */ x86emuOp2_illegal_op
,
2612 /* 0x4d */ x86emuOp2_illegal_op
,
2613 /* 0x4e */ x86emuOp2_illegal_op
,
2614 /* 0x4f */ x86emuOp2_illegal_op
,
2616 /* 0x50 */ x86emuOp2_illegal_op
,
2617 /* 0x51 */ x86emuOp2_illegal_op
,
2618 /* 0x52 */ x86emuOp2_illegal_op
,
2619 /* 0x53 */ x86emuOp2_illegal_op
,
2620 /* 0x54 */ x86emuOp2_illegal_op
,
2621 /* 0x55 */ x86emuOp2_illegal_op
,
2622 /* 0x56 */ x86emuOp2_illegal_op
,
2623 /* 0x57 */ x86emuOp2_illegal_op
,
2624 /* 0x58 */ x86emuOp2_illegal_op
,
2625 /* 0x59 */ x86emuOp2_illegal_op
,
2626 /* 0x5a */ x86emuOp2_illegal_op
,
2627 /* 0x5b */ x86emuOp2_illegal_op
,
2628 /* 0x5c */ x86emuOp2_illegal_op
,
2629 /* 0x5d */ x86emuOp2_illegal_op
,
2630 /* 0x5e */ x86emuOp2_illegal_op
,
2631 /* 0x5f */ x86emuOp2_illegal_op
,
2633 /* 0x60 */ x86emuOp2_illegal_op
,
2634 /* 0x61 */ x86emuOp2_illegal_op
,
2635 /* 0x62 */ x86emuOp2_illegal_op
,
2636 /* 0x63 */ x86emuOp2_illegal_op
,
2637 /* 0x64 */ x86emuOp2_illegal_op
,
2638 /* 0x65 */ x86emuOp2_illegal_op
,
2639 /* 0x66 */ x86emuOp2_illegal_op
,
2640 /* 0x67 */ x86emuOp2_illegal_op
,
2641 /* 0x68 */ x86emuOp2_illegal_op
,
2642 /* 0x69 */ x86emuOp2_illegal_op
,
2643 /* 0x6a */ x86emuOp2_illegal_op
,
2644 /* 0x6b */ x86emuOp2_illegal_op
,
2645 /* 0x6c */ x86emuOp2_illegal_op
,
2646 /* 0x6d */ x86emuOp2_illegal_op
,
2647 /* 0x6e */ x86emuOp2_illegal_op
,
2648 /* 0x6f */ x86emuOp2_illegal_op
,
2650 /* 0x70 */ x86emuOp2_illegal_op
,
2651 /* 0x71 */ x86emuOp2_illegal_op
,
2652 /* 0x72 */ x86emuOp2_illegal_op
,
2653 /* 0x73 */ x86emuOp2_illegal_op
,
2654 /* 0x74 */ x86emuOp2_illegal_op
,
2655 /* 0x75 */ x86emuOp2_illegal_op
,
2656 /* 0x76 */ x86emuOp2_illegal_op
,
2657 /* 0x77 */ x86emuOp2_illegal_op
,
2658 /* 0x78 */ x86emuOp2_illegal_op
,
2659 /* 0x79 */ x86emuOp2_illegal_op
,
2660 /* 0x7a */ x86emuOp2_illegal_op
,
2661 /* 0x7b */ x86emuOp2_illegal_op
,
2662 /* 0x7c */ x86emuOp2_illegal_op
,
2663 /* 0x7d */ x86emuOp2_illegal_op
,
2664 /* 0x7e */ x86emuOp2_illegal_op
,
2665 /* 0x7f */ x86emuOp2_illegal_op
,
2667 /* 0x80 */ x86emuOp2_long_jump
,
2668 /* 0x81 */ x86emuOp2_long_jump
,
2669 /* 0x82 */ x86emuOp2_long_jump
,
2670 /* 0x83 */ x86emuOp2_long_jump
,
2671 /* 0x84 */ x86emuOp2_long_jump
,
2672 /* 0x85 */ x86emuOp2_long_jump
,
2673 /* 0x86 */ x86emuOp2_long_jump
,
2674 /* 0x87 */ x86emuOp2_long_jump
,
2675 /* 0x88 */ x86emuOp2_long_jump
,
2676 /* 0x89 */ x86emuOp2_long_jump
,
2677 /* 0x8a */ x86emuOp2_long_jump
,
2678 /* 0x8b */ x86emuOp2_long_jump
,
2679 /* 0x8c */ x86emuOp2_long_jump
,
2680 /* 0x8d */ x86emuOp2_long_jump
,
2681 /* 0x8e */ x86emuOp2_long_jump
,
2682 /* 0x8f */ x86emuOp2_long_jump
,
2684 /* 0x90 */ x86emuOp2_set_byte
,
2685 /* 0x91 */ x86emuOp2_set_byte
,
2686 /* 0x92 */ x86emuOp2_set_byte
,
2687 /* 0x93 */ x86emuOp2_set_byte
,
2688 /* 0x94 */ x86emuOp2_set_byte
,
2689 /* 0x95 */ x86emuOp2_set_byte
,
2690 /* 0x96 */ x86emuOp2_set_byte
,
2691 /* 0x97 */ x86emuOp2_set_byte
,
2692 /* 0x98 */ x86emuOp2_set_byte
,
2693 /* 0x99 */ x86emuOp2_set_byte
,
2694 /* 0x9a */ x86emuOp2_set_byte
,
2695 /* 0x9b */ x86emuOp2_set_byte
,
2696 /* 0x9c */ x86emuOp2_set_byte
,
2697 /* 0x9d */ x86emuOp2_set_byte
,
2698 /* 0x9e */ x86emuOp2_set_byte
,
2699 /* 0x9f */ x86emuOp2_set_byte
,
2701 /* 0xa0 */ x86emuOp2_push_FS
,
2702 /* 0xa1 */ x86emuOp2_pop_FS
,
2703 /* 0xa2 */ x86emuOp2_illegal_op
,
2704 /* 0xa3 */ x86emuOp2_bt_R
,
2705 /* 0xa4 */ x86emuOp2_shld_IMM
,
2706 /* 0xa5 */ x86emuOp2_shld_CL
,
2707 /* 0xa6 */ x86emuOp2_illegal_op
,
2708 /* 0xa7 */ x86emuOp2_illegal_op
,
2709 /* 0xa8 */ x86emuOp2_push_GS
,
2710 /* 0xa9 */ x86emuOp2_pop_GS
,
2711 /* 0xaa */ x86emuOp2_illegal_op
,
2712 /* 0xab */ x86emuOp2_bt_R
,
2713 /* 0xac */ x86emuOp2_shrd_IMM
,
2714 /* 0xad */ x86emuOp2_shrd_CL
,
2715 /* 0xae */ x86emuOp2_illegal_op
,
2716 /* 0xaf */ x86emuOp2_imul_R_RM
,
2718 /* 0xb0 */ x86emuOp2_illegal_op
, /* TODO: cmpxchg */
2719 /* 0xb1 */ x86emuOp2_illegal_op
, /* TODO: cmpxchg */
2720 /* 0xb2 */ x86emuOp2_lss_R_IMM
,
2721 /* 0xb3 */ x86emuOp2_btr_R
,
2722 /* 0xb4 */ x86emuOp2_lfs_R_IMM
,
2723 /* 0xb5 */ x86emuOp2_lgs_R_IMM
,
2724 /* 0xb6 */ x86emuOp2_movzx_byte_R_RM
,
2725 /* 0xb7 */ x86emuOp2_movzx_word_R_RM
,
2726 /* 0xb8 */ x86emuOp2_illegal_op
,
2727 /* 0xb9 */ x86emuOp2_illegal_op
,
2728 /* 0xba */ x86emuOp2_btX_I
,
2729 /* 0xbb */ x86emuOp2_btc_R
,
2730 /* 0xbc */ x86emuOp2_bsf
,
2731 /* 0xbd */ x86emuOp2_bsr
,
2732 /* 0xbe */ x86emuOp2_movsx_byte_R_RM
,
2733 /* 0xbf */ x86emuOp2_movsx_word_R_RM
,
2735 /* 0xc0 */ x86emuOp2_illegal_op
, /* TODO: xadd */
2736 /* 0xc1 */ x86emuOp2_illegal_op
, /* TODO: xadd */
2737 /* 0xc2 */ x86emuOp2_illegal_op
,
2738 /* 0xc3 */ x86emuOp2_illegal_op
,
2739 /* 0xc4 */ x86emuOp2_illegal_op
,
2740 /* 0xc5 */ x86emuOp2_illegal_op
,
2741 /* 0xc6 */ x86emuOp2_illegal_op
,
2742 /* 0xc7 */ x86emuOp2_illegal_op
,
2743 /* 0xc8 */ x86emuOp2_illegal_op
, /* TODO: bswap */
2744 /* 0xc9 */ x86emuOp2_illegal_op
, /* TODO: bswap */
2745 /* 0xca */ x86emuOp2_illegal_op
, /* TODO: bswap */
2746 /* 0xcb */ x86emuOp2_illegal_op
, /* TODO: bswap */
2747 /* 0xcc */ x86emuOp2_illegal_op
, /* TODO: bswap */
2748 /* 0xcd */ x86emuOp2_illegal_op
, /* TODO: bswap */
2749 /* 0xce */ x86emuOp2_illegal_op
, /* TODO: bswap */
2750 /* 0xcf */ x86emuOp2_illegal_op
, /* TODO: bswap */
2752 /* 0xd0 */ x86emuOp2_illegal_op
,
2753 /* 0xd1 */ x86emuOp2_illegal_op
,
2754 /* 0xd2 */ x86emuOp2_illegal_op
,
2755 /* 0xd3 */ x86emuOp2_illegal_op
,
2756 /* 0xd4 */ x86emuOp2_illegal_op
,
2757 /* 0xd5 */ x86emuOp2_illegal_op
,
2758 /* 0xd6 */ x86emuOp2_illegal_op
,
2759 /* 0xd7 */ x86emuOp2_illegal_op
,
2760 /* 0xd8 */ x86emuOp2_illegal_op
,
2761 /* 0xd9 */ x86emuOp2_illegal_op
,
2762 /* 0xda */ x86emuOp2_illegal_op
,
2763 /* 0xdb */ x86emuOp2_illegal_op
,
2764 /* 0xdc */ x86emuOp2_illegal_op
,
2765 /* 0xdd */ x86emuOp2_illegal_op
,
2766 /* 0xde */ x86emuOp2_illegal_op
,
2767 /* 0xdf */ x86emuOp2_illegal_op
,
2769 /* 0xe0 */ x86emuOp2_illegal_op
,
2770 /* 0xe1 */ x86emuOp2_illegal_op
,
2771 /* 0xe2 */ x86emuOp2_illegal_op
,
2772 /* 0xe3 */ x86emuOp2_illegal_op
,
2773 /* 0xe4 */ x86emuOp2_illegal_op
,
2774 /* 0xe5 */ x86emuOp2_illegal_op
,
2775 /* 0xe6 */ x86emuOp2_illegal_op
,
2776 /* 0xe7 */ x86emuOp2_illegal_op
,
2777 /* 0xe8 */ x86emuOp2_illegal_op
,
2778 /* 0xe9 */ x86emuOp2_illegal_op
,
2779 /* 0xea */ x86emuOp2_illegal_op
,
2780 /* 0xeb */ x86emuOp2_illegal_op
,
2781 /* 0xec */ x86emuOp2_illegal_op
,
2782 /* 0xed */ x86emuOp2_illegal_op
,
2783 /* 0xee */ x86emuOp2_illegal_op
,
2784 /* 0xef */ x86emuOp2_illegal_op
,
2786 /* 0xf0 */ x86emuOp2_illegal_op
,
2787 /* 0xf1 */ x86emuOp2_illegal_op
,
2788 /* 0xf2 */ x86emuOp2_illegal_op
,
2789 /* 0xf3 */ x86emuOp2_illegal_op
,
2790 /* 0xf4 */ x86emuOp2_illegal_op
,
2791 /* 0xf5 */ x86emuOp2_illegal_op
,
2792 /* 0xf6 */ x86emuOp2_illegal_op
,
2793 /* 0xf7 */ x86emuOp2_illegal_op
,
2794 /* 0xf8 */ x86emuOp2_illegal_op
,
2795 /* 0xf9 */ x86emuOp2_illegal_op
,
2796 /* 0xfa */ x86emuOp2_illegal_op
,
2797 /* 0xfb */ x86emuOp2_illegal_op
,
2798 /* 0xfc */ x86emuOp2_illegal_op
,
2799 /* 0xfd */ x86emuOp2_illegal_op
,
2800 /* 0xfe */ x86emuOp2_illegal_op
,
2801 /* 0xff */ x86emuOp2_illegal_op
,