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 processor instructions.
38 * There are approximately 250 subroutines in here, which correspond
39 * to the 256 byte-"opcodes" found on the 8086. The table which
40 * dispatches this is found in the files optab.[ch].
42 * Each opcode proc has a comment preceeding it which gives it's table
43 * address. Several opcodes are missing (undefined) in the table.
45 * Each proc includes information for decoding (DECODE_PRINTF and
46 * DECODE_PRINTF2), debugging (TRACE_REGS, SINGLE_STEP), and misc
47 * functions (START_OF_INSTR, END_OF_INSTR).
49 * Many of the procedures are *VERY* similar in coding. This has
50 * allowed for a very large amount of code to be generated in a fairly
51 * short amount of time (i.e. cut, paste, and modify). The result is
52 * that much of the code below could have been folded into subroutines
53 * for a large reduction in size of this file. The downside would be
54 * that there would be a penalty in execution speed. The file could
55 * also have been *MUCH* larger by inlining certain functions which
56 * were called. This could have resulted even faster execution. The
57 * prime directive I used to decide whether to inline the code or to
58 * modularize it, was basically: 1) no unnecessary subroutine calls,
59 * 2) no routines more than about 200 lines in size, and 3) modularize
60 * any code that I might not get right the first time. The fetch_*
61 * subroutines fall into the latter category. The The decode_* fall
62 * into the second category. The coding of the "switch(mod){ .... }"
63 * in many of the subroutines below falls into the first category.
64 * Especially, the coding of {add,and,or,sub,...}_{byte,word}
65 * subroutines are an especially glaring case of the third guideline.
66 * Since so much of the code is cloned from other modules (compare
67 * opcode #00 to opcode #01), making the basic operations subroutine
68 * calls is especially important; otherwise mistakes in coding an
69 * "add" would represent a nightmare in maintenance.
71 ****************************************************************************/
73 #include "x86emu/x86emui.h"
75 /*----------------------------- Implementation ----------------------------*/
77 /****************************************************************************
79 op1 - Instruction op code
82 Handles illegal opcodes.
83 ****************************************************************************/
85 x86emuOp_illegal_op(u8 op1
)
88 if (M
.x86
.R_SP
!= 0) {
89 DECODE_PRINTF("ILLEGAL X86 OPCODE\n");
91 DB(printk("%04x:%04x: %02X ILLEGAL X86 OPCODE!\n",
92 M
.x86
.R_CS
, M
.x86
.R_IP
- 1, op1
));
96 /* If we get here, it means the stack pointer is back to zero
97 * so we are just returning from an emulator service call
98 * so therte is no need to display an error message. We trap
99 * the emulator with an 0xF1 opcode to finish the service
107 /****************************************************************************
110 ****************************************************************************/
112 x86emuOp_add_byte_RM_R(u8
X86EMU_UNUSED(op1
))
116 u8
*destreg
, *srcreg
;
120 DECODE_PRINTF("ADD\t");
121 FETCH_DECODE_MODRM(mod
, rh
, rl
);
124 destoffset
= decode_rm00_address(rl
);
126 destval
= fetch_data_byte(destoffset
);
127 srcreg
= DECODE_RM_BYTE_REGISTER(rh
);
130 destval
= add_byte(destval
, *srcreg
);
131 store_data_byte(destoffset
, destval
);
134 destoffset
= decode_rm01_address(rl
);
136 destval
= fetch_data_byte(destoffset
);
137 srcreg
= DECODE_RM_BYTE_REGISTER(rh
);
140 destval
= add_byte(destval
, *srcreg
);
141 store_data_byte(destoffset
, destval
);
144 destoffset
= decode_rm10_address(rl
);
146 destval
= fetch_data_byte(destoffset
);
147 srcreg
= DECODE_RM_BYTE_REGISTER(rh
);
150 destval
= add_byte(destval
, *srcreg
);
151 store_data_byte(destoffset
, destval
);
153 case 3: /* register to register */
154 destreg
= DECODE_RM_BYTE_REGISTER(rl
);
156 srcreg
= DECODE_RM_BYTE_REGISTER(rh
);
159 *destreg
= add_byte(*destreg
, *srcreg
);
162 DECODE_CLEAR_SEGOVR();
166 /****************************************************************************
169 ****************************************************************************/
171 x86emuOp_add_word_RM_R(u8
X86EMU_UNUSED(op1
))
177 DECODE_PRINTF("ADD\t");
178 FETCH_DECODE_MODRM(mod
, rh
, rl
);
181 if (M
.x86
.mode
& SYSMODE_PREFIX_DATA
) {
185 destoffset
= decode_rm00_address(rl
);
187 destval
= fetch_data_long(destoffset
);
188 srcreg
= DECODE_RM_LONG_REGISTER(rh
);
191 destval
= add_long(destval
, *srcreg
);
192 store_data_long(destoffset
, destval
);
198 destoffset
= decode_rm00_address(rl
);
200 destval
= fetch_data_word(destoffset
);
201 srcreg
= DECODE_RM_WORD_REGISTER(rh
);
204 destval
= add_word(destval
, *srcreg
);
205 store_data_word(destoffset
, destval
);
209 if (M
.x86
.mode
& SYSMODE_PREFIX_DATA
) {
213 destoffset
= decode_rm01_address(rl
);
215 destval
= fetch_data_long(destoffset
);
216 srcreg
= DECODE_RM_LONG_REGISTER(rh
);
219 destval
= add_long(destval
, *srcreg
);
220 store_data_long(destoffset
, destval
);
226 destoffset
= decode_rm01_address(rl
);
228 destval
= fetch_data_word(destoffset
);
229 srcreg
= DECODE_RM_WORD_REGISTER(rh
);
232 destval
= add_word(destval
, *srcreg
);
233 store_data_word(destoffset
, destval
);
237 if (M
.x86
.mode
& SYSMODE_PREFIX_DATA
) {
241 destoffset
= decode_rm10_address(rl
);
243 destval
= fetch_data_long(destoffset
);
244 srcreg
= DECODE_RM_LONG_REGISTER(rh
);
247 destval
= add_long(destval
, *srcreg
);
248 store_data_long(destoffset
, destval
);
254 destoffset
= decode_rm10_address(rl
);
256 destval
= fetch_data_word(destoffset
);
257 srcreg
= DECODE_RM_WORD_REGISTER(rh
);
260 destval
= add_word(destval
, *srcreg
);
261 store_data_word(destoffset
, destval
);
264 case 3: /* register to register */
265 if (M
.x86
.mode
& SYSMODE_PREFIX_DATA
) {
266 u32
*destreg
, *srcreg
;
268 destreg
= DECODE_RM_LONG_REGISTER(rl
);
270 srcreg
= DECODE_RM_LONG_REGISTER(rh
);
273 *destreg
= add_long(*destreg
, *srcreg
);
276 u16
*destreg
, *srcreg
;
278 destreg
= DECODE_RM_WORD_REGISTER(rl
);
280 srcreg
= DECODE_RM_WORD_REGISTER(rh
);
283 *destreg
= add_word(*destreg
, *srcreg
);
287 DECODE_CLEAR_SEGOVR();
291 /****************************************************************************
294 ****************************************************************************/
296 x86emuOp_add_byte_R_RM(u8
X86EMU_UNUSED(op1
))
299 u8
*destreg
, *srcreg
;
304 DECODE_PRINTF("ADD\t");
305 FETCH_DECODE_MODRM(mod
, rh
, rl
);
308 destreg
= DECODE_RM_BYTE_REGISTER(rh
);
310 srcoffset
= decode_rm00_address(rl
);
311 srcval
= fetch_data_byte(srcoffset
);
314 *destreg
= add_byte(*destreg
, srcval
);
317 destreg
= DECODE_RM_BYTE_REGISTER(rh
);
319 srcoffset
= decode_rm01_address(rl
);
320 srcval
= fetch_data_byte(srcoffset
);
323 *destreg
= add_byte(*destreg
, srcval
);
326 destreg
= DECODE_RM_BYTE_REGISTER(rh
);
328 srcoffset
= decode_rm10_address(rl
);
329 srcval
= fetch_data_byte(srcoffset
);
332 *destreg
= add_byte(*destreg
, srcval
);
334 case 3: /* register to register */
335 destreg
= DECODE_RM_BYTE_REGISTER(rh
);
337 srcreg
= DECODE_RM_BYTE_REGISTER(rl
);
340 *destreg
= add_byte(*destreg
, *srcreg
);
343 DECODE_CLEAR_SEGOVR();
347 /****************************************************************************
350 ****************************************************************************/
352 x86emuOp_add_word_R_RM(u8
X86EMU_UNUSED(op1
))
358 DECODE_PRINTF("ADD\t");
359 FETCH_DECODE_MODRM(mod
, rh
, rl
);
362 if (M
.x86
.mode
& SYSMODE_PREFIX_DATA
) {
366 destreg
= DECODE_RM_LONG_REGISTER(rh
);
368 srcoffset
= decode_rm00_address(rl
);
369 srcval
= fetch_data_long(srcoffset
);
372 *destreg
= add_long(*destreg
, srcval
);
378 destreg
= DECODE_RM_WORD_REGISTER(rh
);
380 srcoffset
= decode_rm00_address(rl
);
381 srcval
= fetch_data_word(srcoffset
);
384 *destreg
= add_word(*destreg
, srcval
);
388 if (M
.x86
.mode
& SYSMODE_PREFIX_DATA
) {
392 destreg
= DECODE_RM_LONG_REGISTER(rh
);
394 srcoffset
= decode_rm01_address(rl
);
395 srcval
= fetch_data_long(srcoffset
);
398 *destreg
= add_long(*destreg
, srcval
);
404 destreg
= DECODE_RM_WORD_REGISTER(rh
);
406 srcoffset
= decode_rm01_address(rl
);
407 srcval
= fetch_data_word(srcoffset
);
410 *destreg
= add_word(*destreg
, srcval
);
414 if (M
.x86
.mode
& SYSMODE_PREFIX_DATA
) {
418 destreg
= DECODE_RM_LONG_REGISTER(rh
);
420 srcoffset
= decode_rm10_address(rl
);
421 srcval
= fetch_data_long(srcoffset
);
424 *destreg
= add_long(*destreg
, srcval
);
430 destreg
= DECODE_RM_WORD_REGISTER(rh
);
432 srcoffset
= decode_rm10_address(rl
);
433 srcval
= fetch_data_word(srcoffset
);
436 *destreg
= add_word(*destreg
, srcval
);
439 case 3: /* register to register */
440 if (M
.x86
.mode
& SYSMODE_PREFIX_DATA
) {
441 u32
*destreg
, *srcreg
;
443 destreg
= DECODE_RM_LONG_REGISTER(rh
);
445 srcreg
= DECODE_RM_LONG_REGISTER(rl
);
448 *destreg
= add_long(*destreg
, *srcreg
);
451 u16
*destreg
, *srcreg
;
453 destreg
= DECODE_RM_WORD_REGISTER(rh
);
455 srcreg
= DECODE_RM_WORD_REGISTER(rl
);
458 *destreg
= add_word(*destreg
, *srcreg
);
462 DECODE_CLEAR_SEGOVR();
466 /****************************************************************************
469 ****************************************************************************/
471 x86emuOp_add_byte_AL_IMM(u8
X86EMU_UNUSED(op1
))
476 DECODE_PRINTF("ADD\tAL,");
477 srcval
= fetch_byte_imm();
478 DECODE_PRINTF2("%x\n", srcval
);
480 M
.x86
.R_AL
= add_byte(M
.x86
.R_AL
, srcval
);
481 DECODE_CLEAR_SEGOVR();
485 /****************************************************************************
488 ****************************************************************************/
490 x86emuOp_add_word_AX_IMM(u8
X86EMU_UNUSED(op1
))
495 if (M
.x86
.mode
& SYSMODE_PREFIX_DATA
) {
496 DECODE_PRINTF("ADD\tEAX,");
497 srcval
= fetch_long_imm();
500 DECODE_PRINTF("ADD\tAX,");
501 srcval
= fetch_word_imm();
503 DECODE_PRINTF2("%x\n", srcval
);
505 if (M
.x86
.mode
& SYSMODE_PREFIX_DATA
) {
506 M
.x86
.R_EAX
= add_long(M
.x86
.R_EAX
, srcval
);
509 M
.x86
.R_AX
= add_word(M
.x86
.R_AX
, (u16
) srcval
);
511 DECODE_CLEAR_SEGOVR();
515 /****************************************************************************
518 ****************************************************************************/
520 x86emuOp_push_ES(u8
X86EMU_UNUSED(op1
))
523 DECODE_PRINTF("PUSH\tES\n");
525 push_word(M
.x86
.R_ES
);
526 DECODE_CLEAR_SEGOVR();
530 /****************************************************************************
533 ****************************************************************************/
535 x86emuOp_pop_ES(u8
X86EMU_UNUSED(op1
))
538 DECODE_PRINTF("POP\tES\n");
540 M
.x86
.R_ES
= pop_word();
541 DECODE_CLEAR_SEGOVR();
545 /****************************************************************************
548 ****************************************************************************/
550 x86emuOp_or_byte_RM_R(u8
X86EMU_UNUSED(op1
))
553 u8
*destreg
, *srcreg
;
558 DECODE_PRINTF("OR\t");
559 FETCH_DECODE_MODRM(mod
, rh
, rl
);
562 destoffset
= decode_rm00_address(rl
);
564 destval
= fetch_data_byte(destoffset
);
565 srcreg
= DECODE_RM_BYTE_REGISTER(rh
);
568 destval
= or_byte(destval
, *srcreg
);
569 store_data_byte(destoffset
, destval
);
572 destoffset
= decode_rm01_address(rl
);
574 destval
= fetch_data_byte(destoffset
);
575 srcreg
= DECODE_RM_BYTE_REGISTER(rh
);
578 destval
= or_byte(destval
, *srcreg
);
579 store_data_byte(destoffset
, destval
);
582 destoffset
= decode_rm10_address(rl
);
584 destval
= fetch_data_byte(destoffset
);
585 srcreg
= DECODE_RM_BYTE_REGISTER(rh
);
588 destval
= or_byte(destval
, *srcreg
);
589 store_data_byte(destoffset
, destval
);
591 case 3: /* register to register */
592 destreg
= DECODE_RM_BYTE_REGISTER(rl
);
594 srcreg
= DECODE_RM_BYTE_REGISTER(rh
);
597 *destreg
= or_byte(*destreg
, *srcreg
);
600 DECODE_CLEAR_SEGOVR();
604 /****************************************************************************
607 ****************************************************************************/
609 x86emuOp_or_word_RM_R(u8
X86EMU_UNUSED(op1
))
615 DECODE_PRINTF("OR\t");
616 FETCH_DECODE_MODRM(mod
, rh
, rl
);
619 if (M
.x86
.mode
& SYSMODE_PREFIX_DATA
) {
623 destoffset
= decode_rm00_address(rl
);
625 destval
= fetch_data_long(destoffset
);
626 srcreg
= DECODE_RM_LONG_REGISTER(rh
);
629 destval
= or_long(destval
, *srcreg
);
630 store_data_long(destoffset
, destval
);
636 destoffset
= decode_rm00_address(rl
);
638 destval
= fetch_data_word(destoffset
);
639 srcreg
= DECODE_RM_WORD_REGISTER(rh
);
642 destval
= or_word(destval
, *srcreg
);
643 store_data_word(destoffset
, destval
);
647 if (M
.x86
.mode
& SYSMODE_PREFIX_DATA
) {
651 destoffset
= decode_rm01_address(rl
);
653 destval
= fetch_data_long(destoffset
);
654 srcreg
= DECODE_RM_LONG_REGISTER(rh
);
657 destval
= or_long(destval
, *srcreg
);
658 store_data_long(destoffset
, destval
);
664 destoffset
= decode_rm01_address(rl
);
666 destval
= fetch_data_word(destoffset
);
667 srcreg
= DECODE_RM_WORD_REGISTER(rh
);
670 destval
= or_word(destval
, *srcreg
);
671 store_data_word(destoffset
, destval
);
675 if (M
.x86
.mode
& SYSMODE_PREFIX_DATA
) {
679 destoffset
= decode_rm10_address(rl
);
681 destval
= fetch_data_long(destoffset
);
682 srcreg
= DECODE_RM_LONG_REGISTER(rh
);
685 destval
= or_long(destval
, *srcreg
);
686 store_data_long(destoffset
, destval
);
692 destoffset
= decode_rm10_address(rl
);
694 destval
= fetch_data_word(destoffset
);
695 srcreg
= DECODE_RM_WORD_REGISTER(rh
);
698 destval
= or_word(destval
, *srcreg
);
699 store_data_word(destoffset
, destval
);
702 case 3: /* register to register */
703 if (M
.x86
.mode
& SYSMODE_PREFIX_DATA
) {
704 u32
*destreg
, *srcreg
;
706 destreg
= DECODE_RM_LONG_REGISTER(rl
);
708 srcreg
= DECODE_RM_LONG_REGISTER(rh
);
711 *destreg
= or_long(*destreg
, *srcreg
);
714 u16
*destreg
, *srcreg
;
716 destreg
= DECODE_RM_WORD_REGISTER(rl
);
718 srcreg
= DECODE_RM_WORD_REGISTER(rh
);
721 *destreg
= or_word(*destreg
, *srcreg
);
725 DECODE_CLEAR_SEGOVR();
729 /****************************************************************************
732 ****************************************************************************/
734 x86emuOp_or_byte_R_RM(u8
X86EMU_UNUSED(op1
))
737 u8
*destreg
, *srcreg
;
742 DECODE_PRINTF("OR\t");
743 FETCH_DECODE_MODRM(mod
, rh
, rl
);
746 destreg
= DECODE_RM_BYTE_REGISTER(rh
);
748 srcoffset
= decode_rm00_address(rl
);
749 srcval
= fetch_data_byte(srcoffset
);
752 *destreg
= or_byte(*destreg
, srcval
);
755 destreg
= DECODE_RM_BYTE_REGISTER(rh
);
757 srcoffset
= decode_rm01_address(rl
);
758 srcval
= fetch_data_byte(srcoffset
);
761 *destreg
= or_byte(*destreg
, srcval
);
764 destreg
= DECODE_RM_BYTE_REGISTER(rh
);
766 srcoffset
= decode_rm10_address(rl
);
767 srcval
= fetch_data_byte(srcoffset
);
770 *destreg
= or_byte(*destreg
, srcval
);
772 case 3: /* register to register */
773 destreg
= DECODE_RM_BYTE_REGISTER(rh
);
775 srcreg
= DECODE_RM_BYTE_REGISTER(rl
);
778 *destreg
= or_byte(*destreg
, *srcreg
);
781 DECODE_CLEAR_SEGOVR();
785 /****************************************************************************
788 ****************************************************************************/
790 x86emuOp_or_word_R_RM(u8
X86EMU_UNUSED(op1
))
796 DECODE_PRINTF("OR\t");
797 FETCH_DECODE_MODRM(mod
, rh
, rl
);
800 if (M
.x86
.mode
& SYSMODE_PREFIX_DATA
) {
804 destreg
= DECODE_RM_LONG_REGISTER(rh
);
806 srcoffset
= decode_rm00_address(rl
);
807 srcval
= fetch_data_long(srcoffset
);
810 *destreg
= or_long(*destreg
, srcval
);
816 destreg
= DECODE_RM_WORD_REGISTER(rh
);
818 srcoffset
= decode_rm00_address(rl
);
819 srcval
= fetch_data_word(srcoffset
);
822 *destreg
= or_word(*destreg
, srcval
);
826 if (M
.x86
.mode
& SYSMODE_PREFIX_DATA
) {
830 destreg
= DECODE_RM_LONG_REGISTER(rh
);
832 srcoffset
= decode_rm01_address(rl
);
833 srcval
= fetch_data_long(srcoffset
);
836 *destreg
= or_long(*destreg
, srcval
);
842 destreg
= DECODE_RM_WORD_REGISTER(rh
);
844 srcoffset
= decode_rm01_address(rl
);
845 srcval
= fetch_data_word(srcoffset
);
848 *destreg
= or_word(*destreg
, srcval
);
852 if (M
.x86
.mode
& SYSMODE_PREFIX_DATA
) {
856 destreg
= DECODE_RM_LONG_REGISTER(rh
);
858 srcoffset
= decode_rm10_address(rl
);
859 srcval
= fetch_data_long(srcoffset
);
862 *destreg
= or_long(*destreg
, srcval
);
868 destreg
= DECODE_RM_WORD_REGISTER(rh
);
870 srcoffset
= decode_rm10_address(rl
);
871 srcval
= fetch_data_word(srcoffset
);
874 *destreg
= or_word(*destreg
, srcval
);
877 case 3: /* register to register */
878 if (M
.x86
.mode
& SYSMODE_PREFIX_DATA
) {
879 u32
*destreg
, *srcreg
;
881 destreg
= DECODE_RM_LONG_REGISTER(rh
);
883 srcreg
= DECODE_RM_LONG_REGISTER(rl
);
886 *destreg
= or_long(*destreg
, *srcreg
);
889 u16
*destreg
, *srcreg
;
891 destreg
= DECODE_RM_WORD_REGISTER(rh
);
893 srcreg
= DECODE_RM_WORD_REGISTER(rl
);
896 *destreg
= or_word(*destreg
, *srcreg
);
900 DECODE_CLEAR_SEGOVR();
904 /****************************************************************************
907 ****************************************************************************/
909 x86emuOp_or_byte_AL_IMM(u8
X86EMU_UNUSED(op1
))
914 DECODE_PRINTF("OR\tAL,");
915 srcval
= fetch_byte_imm();
916 DECODE_PRINTF2("%x\n", srcval
);
918 M
.x86
.R_AL
= or_byte(M
.x86
.R_AL
, srcval
);
919 DECODE_CLEAR_SEGOVR();
923 /****************************************************************************
926 ****************************************************************************/
928 x86emuOp_or_word_AX_IMM(u8
X86EMU_UNUSED(op1
))
933 if (M
.x86
.mode
& SYSMODE_PREFIX_DATA
) {
934 DECODE_PRINTF("OR\tEAX,");
935 srcval
= fetch_long_imm();
938 DECODE_PRINTF("OR\tAX,");
939 srcval
= fetch_word_imm();
941 DECODE_PRINTF2("%x\n", srcval
);
943 if (M
.x86
.mode
& SYSMODE_PREFIX_DATA
) {
944 M
.x86
.R_EAX
= or_long(M
.x86
.R_EAX
, srcval
);
947 M
.x86
.R_AX
= or_word(M
.x86
.R_AX
, (u16
) srcval
);
949 DECODE_CLEAR_SEGOVR();
953 /****************************************************************************
956 ****************************************************************************/
958 x86emuOp_push_CS(u8
X86EMU_UNUSED(op1
))
961 DECODE_PRINTF("PUSH\tCS\n");
963 push_word(M
.x86
.R_CS
);
964 DECODE_CLEAR_SEGOVR();
968 /****************************************************************************
970 Handles opcode 0x0f. Escape for two-byte opcode (286 or better)
971 ****************************************************************************/
973 x86emuOp_two_byte(u8
X86EMU_UNUSED(op1
))
975 u8 op2
= (*sys_rdb
) (((u32
) M
.x86
.R_CS
<< 4) + (M
.x86
.R_IP
++));
977 INC_DECODED_INST_LEN(1);
978 (*x86emu_optab2
[op2
]) (op2
);
981 /****************************************************************************
984 ****************************************************************************/
986 x86emuOp_adc_byte_RM_R(u8
X86EMU_UNUSED(op1
))
989 u8
*destreg
, *srcreg
;
994 DECODE_PRINTF("ADC\t");
995 FETCH_DECODE_MODRM(mod
, rh
, rl
);
998 destoffset
= decode_rm00_address(rl
);
1000 destval
= fetch_data_byte(destoffset
);
1001 srcreg
= DECODE_RM_BYTE_REGISTER(rh
);
1002 DECODE_PRINTF("\n");
1004 destval
= adc_byte(destval
, *srcreg
);
1005 store_data_byte(destoffset
, destval
);
1008 destoffset
= decode_rm01_address(rl
);
1010 destval
= fetch_data_byte(destoffset
);
1011 srcreg
= DECODE_RM_BYTE_REGISTER(rh
);
1012 DECODE_PRINTF("\n");
1014 destval
= adc_byte(destval
, *srcreg
);
1015 store_data_byte(destoffset
, destval
);
1018 destoffset
= decode_rm10_address(rl
);
1020 destval
= fetch_data_byte(destoffset
);
1021 srcreg
= DECODE_RM_BYTE_REGISTER(rh
);
1022 DECODE_PRINTF("\n");
1024 destval
= adc_byte(destval
, *srcreg
);
1025 store_data_byte(destoffset
, destval
);
1027 case 3: /* register to register */
1028 destreg
= DECODE_RM_BYTE_REGISTER(rl
);
1030 srcreg
= DECODE_RM_BYTE_REGISTER(rh
);
1031 DECODE_PRINTF("\n");
1033 *destreg
= adc_byte(*destreg
, *srcreg
);
1036 DECODE_CLEAR_SEGOVR();
1040 /****************************************************************************
1043 ****************************************************************************/
1045 x86emuOp_adc_word_RM_R(u8
X86EMU_UNUSED(op1
))
1051 DECODE_PRINTF("ADC\t");
1052 FETCH_DECODE_MODRM(mod
, rh
, rl
);
1055 if (M
.x86
.mode
& SYSMODE_PREFIX_DATA
) {
1059 destoffset
= decode_rm00_address(rl
);
1061 destval
= fetch_data_long(destoffset
);
1062 srcreg
= DECODE_RM_LONG_REGISTER(rh
);
1063 DECODE_PRINTF("\n");
1065 destval
= adc_long(destval
, *srcreg
);
1066 store_data_long(destoffset
, destval
);
1072 destoffset
= decode_rm00_address(rl
);
1074 destval
= fetch_data_word(destoffset
);
1075 srcreg
= DECODE_RM_WORD_REGISTER(rh
);
1076 DECODE_PRINTF("\n");
1078 destval
= adc_word(destval
, *srcreg
);
1079 store_data_word(destoffset
, destval
);
1083 if (M
.x86
.mode
& SYSMODE_PREFIX_DATA
) {
1087 destoffset
= decode_rm01_address(rl
);
1089 destval
= fetch_data_long(destoffset
);
1090 srcreg
= DECODE_RM_LONG_REGISTER(rh
);
1091 DECODE_PRINTF("\n");
1093 destval
= adc_long(destval
, *srcreg
);
1094 store_data_long(destoffset
, destval
);
1100 destoffset
= decode_rm01_address(rl
);
1102 destval
= fetch_data_word(destoffset
);
1103 srcreg
= DECODE_RM_WORD_REGISTER(rh
);
1104 DECODE_PRINTF("\n");
1106 destval
= adc_word(destval
, *srcreg
);
1107 store_data_word(destoffset
, destval
);
1111 if (M
.x86
.mode
& SYSMODE_PREFIX_DATA
) {
1115 destoffset
= decode_rm10_address(rl
);
1117 destval
= fetch_data_long(destoffset
);
1118 srcreg
= DECODE_RM_LONG_REGISTER(rh
);
1119 DECODE_PRINTF("\n");
1121 destval
= adc_long(destval
, *srcreg
);
1122 store_data_long(destoffset
, destval
);
1128 destoffset
= decode_rm10_address(rl
);
1130 destval
= fetch_data_word(destoffset
);
1131 srcreg
= DECODE_RM_WORD_REGISTER(rh
);
1132 DECODE_PRINTF("\n");
1134 destval
= adc_word(destval
, *srcreg
);
1135 store_data_word(destoffset
, destval
);
1138 case 3: /* register to register */
1139 if (M
.x86
.mode
& SYSMODE_PREFIX_DATA
) {
1140 u32
*destreg
, *srcreg
;
1142 destreg
= DECODE_RM_LONG_REGISTER(rl
);
1144 srcreg
= DECODE_RM_LONG_REGISTER(rh
);
1145 DECODE_PRINTF("\n");
1147 *destreg
= adc_long(*destreg
, *srcreg
);
1150 u16
*destreg
, *srcreg
;
1152 destreg
= DECODE_RM_WORD_REGISTER(rl
);
1154 srcreg
= DECODE_RM_WORD_REGISTER(rh
);
1155 DECODE_PRINTF("\n");
1157 *destreg
= adc_word(*destreg
, *srcreg
);
1161 DECODE_CLEAR_SEGOVR();
1165 /****************************************************************************
1168 ****************************************************************************/
1170 x86emuOp_adc_byte_R_RM(u8
X86EMU_UNUSED(op1
))
1173 u8
*destreg
, *srcreg
;
1178 DECODE_PRINTF("ADC\t");
1179 FETCH_DECODE_MODRM(mod
, rh
, rl
);
1182 destreg
= DECODE_RM_BYTE_REGISTER(rh
);
1184 srcoffset
= decode_rm00_address(rl
);
1185 srcval
= fetch_data_byte(srcoffset
);
1186 DECODE_PRINTF("\n");
1188 *destreg
= adc_byte(*destreg
, srcval
);
1191 destreg
= DECODE_RM_BYTE_REGISTER(rh
);
1193 srcoffset
= decode_rm01_address(rl
);
1194 srcval
= fetch_data_byte(srcoffset
);
1195 DECODE_PRINTF("\n");
1197 *destreg
= adc_byte(*destreg
, srcval
);
1200 destreg
= DECODE_RM_BYTE_REGISTER(rh
);
1202 srcoffset
= decode_rm10_address(rl
);
1203 srcval
= fetch_data_byte(srcoffset
);
1204 DECODE_PRINTF("\n");
1206 *destreg
= adc_byte(*destreg
, srcval
);
1208 case 3: /* register to register */
1209 destreg
= DECODE_RM_BYTE_REGISTER(rh
);
1211 srcreg
= DECODE_RM_BYTE_REGISTER(rl
);
1212 DECODE_PRINTF("\n");
1214 *destreg
= adc_byte(*destreg
, *srcreg
);
1217 DECODE_CLEAR_SEGOVR();
1221 /****************************************************************************
1224 ****************************************************************************/
1226 x86emuOp_adc_word_R_RM(u8
X86EMU_UNUSED(op1
))
1232 DECODE_PRINTF("ADC\t");
1233 FETCH_DECODE_MODRM(mod
, rh
, rl
);
1236 if (M
.x86
.mode
& SYSMODE_PREFIX_DATA
) {
1240 destreg
= DECODE_RM_LONG_REGISTER(rh
);
1242 srcoffset
= decode_rm00_address(rl
);
1243 srcval
= fetch_data_long(srcoffset
);
1244 DECODE_PRINTF("\n");
1246 *destreg
= adc_long(*destreg
, srcval
);
1252 destreg
= DECODE_RM_WORD_REGISTER(rh
);
1254 srcoffset
= decode_rm00_address(rl
);
1255 srcval
= fetch_data_word(srcoffset
);
1256 DECODE_PRINTF("\n");
1258 *destreg
= adc_word(*destreg
, srcval
);
1262 if (M
.x86
.mode
& SYSMODE_PREFIX_DATA
) {
1266 destreg
= DECODE_RM_LONG_REGISTER(rh
);
1268 srcoffset
= decode_rm01_address(rl
);
1269 srcval
= fetch_data_long(srcoffset
);
1270 DECODE_PRINTF("\n");
1272 *destreg
= adc_long(*destreg
, srcval
);
1278 destreg
= DECODE_RM_WORD_REGISTER(rh
);
1280 srcoffset
= decode_rm01_address(rl
);
1281 srcval
= fetch_data_word(srcoffset
);
1282 DECODE_PRINTF("\n");
1284 *destreg
= adc_word(*destreg
, srcval
);
1288 if (M
.x86
.mode
& SYSMODE_PREFIX_DATA
) {
1292 destreg
= DECODE_RM_LONG_REGISTER(rh
);
1294 srcoffset
= decode_rm10_address(rl
);
1295 srcval
= fetch_data_long(srcoffset
);
1296 DECODE_PRINTF("\n");
1298 *destreg
= adc_long(*destreg
, srcval
);
1304 destreg
= DECODE_RM_WORD_REGISTER(rh
);
1306 srcoffset
= decode_rm10_address(rl
);
1307 srcval
= fetch_data_word(srcoffset
);
1308 DECODE_PRINTF("\n");
1310 *destreg
= adc_word(*destreg
, srcval
);
1313 case 3: /* register to register */
1314 if (M
.x86
.mode
& SYSMODE_PREFIX_DATA
) {
1315 u32
*destreg
, *srcreg
;
1317 destreg
= DECODE_RM_LONG_REGISTER(rh
);
1319 srcreg
= DECODE_RM_LONG_REGISTER(rl
);
1320 DECODE_PRINTF("\n");
1322 *destreg
= adc_long(*destreg
, *srcreg
);
1325 u16
*destreg
, *srcreg
;
1327 destreg
= DECODE_RM_WORD_REGISTER(rh
);
1329 srcreg
= DECODE_RM_WORD_REGISTER(rl
);
1330 DECODE_PRINTF("\n");
1332 *destreg
= adc_word(*destreg
, *srcreg
);
1336 DECODE_CLEAR_SEGOVR();
1340 /****************************************************************************
1343 ****************************************************************************/
1345 x86emuOp_adc_byte_AL_IMM(u8
X86EMU_UNUSED(op1
))
1350 DECODE_PRINTF("ADC\tAL,");
1351 srcval
= fetch_byte_imm();
1352 DECODE_PRINTF2("%x\n", srcval
);
1354 M
.x86
.R_AL
= adc_byte(M
.x86
.R_AL
, srcval
);
1355 DECODE_CLEAR_SEGOVR();
1359 /****************************************************************************
1362 ****************************************************************************/
1364 x86emuOp_adc_word_AX_IMM(u8
X86EMU_UNUSED(op1
))
1369 if (M
.x86
.mode
& SYSMODE_PREFIX_DATA
) {
1370 DECODE_PRINTF("ADC\tEAX,");
1371 srcval
= fetch_long_imm();
1374 DECODE_PRINTF("ADC\tAX,");
1375 srcval
= fetch_word_imm();
1377 DECODE_PRINTF2("%x\n", srcval
);
1379 if (M
.x86
.mode
& SYSMODE_PREFIX_DATA
) {
1380 M
.x86
.R_EAX
= adc_long(M
.x86
.R_EAX
, srcval
);
1383 M
.x86
.R_AX
= adc_word(M
.x86
.R_AX
, (u16
) srcval
);
1385 DECODE_CLEAR_SEGOVR();
1389 /****************************************************************************
1392 ****************************************************************************/
1394 x86emuOp_push_SS(u8
X86EMU_UNUSED(op1
))
1397 DECODE_PRINTF("PUSH\tSS\n");
1399 push_word(M
.x86
.R_SS
);
1400 DECODE_CLEAR_SEGOVR();
1404 /****************************************************************************
1407 ****************************************************************************/
1409 x86emuOp_pop_SS(u8
X86EMU_UNUSED(op1
))
1412 DECODE_PRINTF("POP\tSS\n");
1414 M
.x86
.R_SS
= pop_word();
1415 DECODE_CLEAR_SEGOVR();
1419 /****************************************************************************
1422 ****************************************************************************/
1424 x86emuOp_sbb_byte_RM_R(u8
X86EMU_UNUSED(op1
))
1427 u8
*destreg
, *srcreg
;
1432 DECODE_PRINTF("SBB\t");
1433 FETCH_DECODE_MODRM(mod
, rh
, rl
);
1436 destoffset
= decode_rm00_address(rl
);
1438 destval
= fetch_data_byte(destoffset
);
1439 srcreg
= DECODE_RM_BYTE_REGISTER(rh
);
1440 DECODE_PRINTF("\n");
1442 destval
= sbb_byte(destval
, *srcreg
);
1443 store_data_byte(destoffset
, destval
);
1446 destoffset
= decode_rm01_address(rl
);
1448 destval
= fetch_data_byte(destoffset
);
1449 srcreg
= DECODE_RM_BYTE_REGISTER(rh
);
1450 DECODE_PRINTF("\n");
1452 destval
= sbb_byte(destval
, *srcreg
);
1453 store_data_byte(destoffset
, destval
);
1456 destoffset
= decode_rm10_address(rl
);
1458 destval
= fetch_data_byte(destoffset
);
1459 srcreg
= DECODE_RM_BYTE_REGISTER(rh
);
1460 DECODE_PRINTF("\n");
1462 destval
= sbb_byte(destval
, *srcreg
);
1463 store_data_byte(destoffset
, destval
);
1465 case 3: /* register to register */
1466 destreg
= DECODE_RM_BYTE_REGISTER(rl
);
1468 srcreg
= DECODE_RM_BYTE_REGISTER(rh
);
1469 DECODE_PRINTF("\n");
1471 *destreg
= sbb_byte(*destreg
, *srcreg
);
1474 DECODE_CLEAR_SEGOVR();
1478 /****************************************************************************
1481 ****************************************************************************/
1483 x86emuOp_sbb_word_RM_R(u8
X86EMU_UNUSED(op1
))
1489 DECODE_PRINTF("SBB\t");
1490 FETCH_DECODE_MODRM(mod
, rh
, rl
);
1493 if (M
.x86
.mode
& SYSMODE_PREFIX_DATA
) {
1497 destoffset
= decode_rm00_address(rl
);
1499 destval
= fetch_data_long(destoffset
);
1500 srcreg
= DECODE_RM_LONG_REGISTER(rh
);
1501 DECODE_PRINTF("\n");
1503 destval
= sbb_long(destval
, *srcreg
);
1504 store_data_long(destoffset
, destval
);
1510 destoffset
= decode_rm00_address(rl
);
1512 destval
= fetch_data_word(destoffset
);
1513 srcreg
= DECODE_RM_WORD_REGISTER(rh
);
1514 DECODE_PRINTF("\n");
1516 destval
= sbb_word(destval
, *srcreg
);
1517 store_data_word(destoffset
, destval
);
1521 if (M
.x86
.mode
& SYSMODE_PREFIX_DATA
) {
1525 destoffset
= decode_rm01_address(rl
);
1527 destval
= fetch_data_long(destoffset
);
1528 srcreg
= DECODE_RM_LONG_REGISTER(rh
);
1529 DECODE_PRINTF("\n");
1531 destval
= sbb_long(destval
, *srcreg
);
1532 store_data_long(destoffset
, destval
);
1538 destoffset
= decode_rm01_address(rl
);
1540 destval
= fetch_data_word(destoffset
);
1541 srcreg
= DECODE_RM_WORD_REGISTER(rh
);
1542 DECODE_PRINTF("\n");
1544 destval
= sbb_word(destval
, *srcreg
);
1545 store_data_word(destoffset
, destval
);
1549 if (M
.x86
.mode
& SYSMODE_PREFIX_DATA
) {
1553 destoffset
= decode_rm10_address(rl
);
1555 destval
= fetch_data_long(destoffset
);
1556 srcreg
= DECODE_RM_LONG_REGISTER(rh
);
1557 DECODE_PRINTF("\n");
1559 destval
= sbb_long(destval
, *srcreg
);
1560 store_data_long(destoffset
, destval
);
1566 destoffset
= decode_rm10_address(rl
);
1568 destval
= fetch_data_word(destoffset
);
1569 srcreg
= DECODE_RM_WORD_REGISTER(rh
);
1570 DECODE_PRINTF("\n");
1572 destval
= sbb_word(destval
, *srcreg
);
1573 store_data_word(destoffset
, destval
);
1576 case 3: /* register to register */
1577 if (M
.x86
.mode
& SYSMODE_PREFIX_DATA
) {
1578 u32
*destreg
, *srcreg
;
1580 destreg
= DECODE_RM_LONG_REGISTER(rl
);
1582 srcreg
= DECODE_RM_LONG_REGISTER(rh
);
1583 DECODE_PRINTF("\n");
1585 *destreg
= sbb_long(*destreg
, *srcreg
);
1588 u16
*destreg
, *srcreg
;
1590 destreg
= DECODE_RM_WORD_REGISTER(rl
);
1592 srcreg
= DECODE_RM_WORD_REGISTER(rh
);
1593 DECODE_PRINTF("\n");
1595 *destreg
= sbb_word(*destreg
, *srcreg
);
1599 DECODE_CLEAR_SEGOVR();
1603 /****************************************************************************
1606 ****************************************************************************/
1608 x86emuOp_sbb_byte_R_RM(u8
X86EMU_UNUSED(op1
))
1611 u8
*destreg
, *srcreg
;
1616 DECODE_PRINTF("SBB\t");
1617 FETCH_DECODE_MODRM(mod
, rh
, rl
);
1620 destreg
= DECODE_RM_BYTE_REGISTER(rh
);
1622 srcoffset
= decode_rm00_address(rl
);
1623 srcval
= fetch_data_byte(srcoffset
);
1624 DECODE_PRINTF("\n");
1626 *destreg
= sbb_byte(*destreg
, srcval
);
1629 destreg
= DECODE_RM_BYTE_REGISTER(rh
);
1631 srcoffset
= decode_rm01_address(rl
);
1632 srcval
= fetch_data_byte(srcoffset
);
1633 DECODE_PRINTF("\n");
1635 *destreg
= sbb_byte(*destreg
, srcval
);
1638 destreg
= DECODE_RM_BYTE_REGISTER(rh
);
1640 srcoffset
= decode_rm10_address(rl
);
1641 srcval
= fetch_data_byte(srcoffset
);
1642 DECODE_PRINTF("\n");
1644 *destreg
= sbb_byte(*destreg
, srcval
);
1646 case 3: /* register to register */
1647 destreg
= DECODE_RM_BYTE_REGISTER(rh
);
1649 srcreg
= DECODE_RM_BYTE_REGISTER(rl
);
1650 DECODE_PRINTF("\n");
1652 *destreg
= sbb_byte(*destreg
, *srcreg
);
1655 DECODE_CLEAR_SEGOVR();
1659 /****************************************************************************
1662 ****************************************************************************/
1664 x86emuOp_sbb_word_R_RM(u8
X86EMU_UNUSED(op1
))
1670 DECODE_PRINTF("SBB\t");
1671 FETCH_DECODE_MODRM(mod
, rh
, rl
);
1674 if (M
.x86
.mode
& SYSMODE_PREFIX_DATA
) {
1678 destreg
= DECODE_RM_LONG_REGISTER(rh
);
1680 srcoffset
= decode_rm00_address(rl
);
1681 srcval
= fetch_data_long(srcoffset
);
1682 DECODE_PRINTF("\n");
1684 *destreg
= sbb_long(*destreg
, srcval
);
1690 destreg
= DECODE_RM_WORD_REGISTER(rh
);
1692 srcoffset
= decode_rm00_address(rl
);
1693 srcval
= fetch_data_word(srcoffset
);
1694 DECODE_PRINTF("\n");
1696 *destreg
= sbb_word(*destreg
, srcval
);
1700 if (M
.x86
.mode
& SYSMODE_PREFIX_DATA
) {
1704 destreg
= DECODE_RM_LONG_REGISTER(rh
);
1706 srcoffset
= decode_rm01_address(rl
);
1707 srcval
= fetch_data_long(srcoffset
);
1708 DECODE_PRINTF("\n");
1710 *destreg
= sbb_long(*destreg
, srcval
);
1716 destreg
= DECODE_RM_WORD_REGISTER(rh
);
1718 srcoffset
= decode_rm01_address(rl
);
1719 srcval
= fetch_data_word(srcoffset
);
1720 DECODE_PRINTF("\n");
1722 *destreg
= sbb_word(*destreg
, srcval
);
1726 if (M
.x86
.mode
& SYSMODE_PREFIX_DATA
) {
1730 destreg
= DECODE_RM_LONG_REGISTER(rh
);
1732 srcoffset
= decode_rm10_address(rl
);
1733 srcval
= fetch_data_long(srcoffset
);
1734 DECODE_PRINTF("\n");
1736 *destreg
= sbb_long(*destreg
, srcval
);
1742 destreg
= DECODE_RM_WORD_REGISTER(rh
);
1744 srcoffset
= decode_rm10_address(rl
);
1745 srcval
= fetch_data_word(srcoffset
);
1746 DECODE_PRINTF("\n");
1748 *destreg
= sbb_word(*destreg
, srcval
);
1751 case 3: /* register to register */
1752 if (M
.x86
.mode
& SYSMODE_PREFIX_DATA
) {
1753 u32
*destreg
, *srcreg
;
1755 destreg
= DECODE_RM_LONG_REGISTER(rh
);
1757 srcreg
= DECODE_RM_LONG_REGISTER(rl
);
1758 DECODE_PRINTF("\n");
1760 *destreg
= sbb_long(*destreg
, *srcreg
);
1763 u16
*destreg
, *srcreg
;
1765 destreg
= DECODE_RM_WORD_REGISTER(rh
);
1767 srcreg
= DECODE_RM_WORD_REGISTER(rl
);
1768 DECODE_PRINTF("\n");
1770 *destreg
= sbb_word(*destreg
, *srcreg
);
1774 DECODE_CLEAR_SEGOVR();
1778 /****************************************************************************
1781 ****************************************************************************/
1783 x86emuOp_sbb_byte_AL_IMM(u8
X86EMU_UNUSED(op1
))
1788 DECODE_PRINTF("SBB\tAL,");
1789 srcval
= fetch_byte_imm();
1790 DECODE_PRINTF2("%x\n", srcval
);
1792 M
.x86
.R_AL
= sbb_byte(M
.x86
.R_AL
, srcval
);
1793 DECODE_CLEAR_SEGOVR();
1797 /****************************************************************************
1800 ****************************************************************************/
1802 x86emuOp_sbb_word_AX_IMM(u8
X86EMU_UNUSED(op1
))
1807 if (M
.x86
.mode
& SYSMODE_PREFIX_DATA
) {
1808 DECODE_PRINTF("SBB\tEAX,");
1809 srcval
= fetch_long_imm();
1812 DECODE_PRINTF("SBB\tAX,");
1813 srcval
= fetch_word_imm();
1815 DECODE_PRINTF2("%x\n", srcval
);
1817 if (M
.x86
.mode
& SYSMODE_PREFIX_DATA
) {
1818 M
.x86
.R_EAX
= sbb_long(M
.x86
.R_EAX
, srcval
);
1821 M
.x86
.R_AX
= sbb_word(M
.x86
.R_AX
, (u16
) srcval
);
1823 DECODE_CLEAR_SEGOVR();
1827 /****************************************************************************
1830 ****************************************************************************/
1832 x86emuOp_push_DS(u8
X86EMU_UNUSED(op1
))
1835 DECODE_PRINTF("PUSH\tDS\n");
1837 push_word(M
.x86
.R_DS
);
1838 DECODE_CLEAR_SEGOVR();
1842 /****************************************************************************
1845 ****************************************************************************/
1847 x86emuOp_pop_DS(u8
X86EMU_UNUSED(op1
))
1850 DECODE_PRINTF("POP\tDS\n");
1852 M
.x86
.R_DS
= pop_word();
1853 DECODE_CLEAR_SEGOVR();
1857 /****************************************************************************
1860 ****************************************************************************/
1862 x86emuOp_and_byte_RM_R(u8
X86EMU_UNUSED(op1
))
1865 u8
*destreg
, *srcreg
;
1870 DECODE_PRINTF("AND\t");
1871 FETCH_DECODE_MODRM(mod
, rh
, rl
);
1875 destoffset
= decode_rm00_address(rl
);
1877 destval
= fetch_data_byte(destoffset
);
1878 srcreg
= DECODE_RM_BYTE_REGISTER(rh
);
1879 DECODE_PRINTF("\n");
1881 destval
= and_byte(destval
, *srcreg
);
1882 store_data_byte(destoffset
, destval
);
1886 destoffset
= decode_rm01_address(rl
);
1888 destval
= fetch_data_byte(destoffset
);
1889 srcreg
= DECODE_RM_BYTE_REGISTER(rh
);
1890 DECODE_PRINTF("\n");
1892 destval
= and_byte(destval
, *srcreg
);
1893 store_data_byte(destoffset
, destval
);
1897 destoffset
= decode_rm10_address(rl
);
1899 destval
= fetch_data_byte(destoffset
);
1900 srcreg
= DECODE_RM_BYTE_REGISTER(rh
);
1901 DECODE_PRINTF("\n");
1903 destval
= and_byte(destval
, *srcreg
);
1904 store_data_byte(destoffset
, destval
);
1907 case 3: /* register to register */
1908 destreg
= DECODE_RM_BYTE_REGISTER(rl
);
1910 srcreg
= DECODE_RM_BYTE_REGISTER(rh
);
1911 DECODE_PRINTF("\n");
1913 *destreg
= and_byte(*destreg
, *srcreg
);
1916 DECODE_CLEAR_SEGOVR();
1920 /****************************************************************************
1923 ****************************************************************************/
1925 x86emuOp_and_word_RM_R(u8
X86EMU_UNUSED(op1
))
1931 DECODE_PRINTF("AND\t");
1932 FETCH_DECODE_MODRM(mod
, rh
, rl
);
1935 if (M
.x86
.mode
& SYSMODE_PREFIX_DATA
) {
1939 destoffset
= decode_rm00_address(rl
);
1941 destval
= fetch_data_long(destoffset
);
1942 srcreg
= DECODE_RM_LONG_REGISTER(rh
);
1943 DECODE_PRINTF("\n");
1945 destval
= and_long(destval
, *srcreg
);
1946 store_data_long(destoffset
, destval
);
1952 destoffset
= decode_rm00_address(rl
);
1954 destval
= fetch_data_word(destoffset
);
1955 srcreg
= DECODE_RM_WORD_REGISTER(rh
);
1956 DECODE_PRINTF("\n");
1958 destval
= and_word(destval
, *srcreg
);
1959 store_data_word(destoffset
, destval
);
1963 if (M
.x86
.mode
& SYSMODE_PREFIX_DATA
) {
1967 destoffset
= decode_rm01_address(rl
);
1969 destval
= fetch_data_long(destoffset
);
1970 srcreg
= DECODE_RM_LONG_REGISTER(rh
);
1971 DECODE_PRINTF("\n");
1973 destval
= and_long(destval
, *srcreg
);
1974 store_data_long(destoffset
, destval
);
1980 destoffset
= decode_rm01_address(rl
);
1982 destval
= fetch_data_word(destoffset
);
1983 srcreg
= DECODE_RM_WORD_REGISTER(rh
);
1984 DECODE_PRINTF("\n");
1986 destval
= and_word(destval
, *srcreg
);
1987 store_data_word(destoffset
, destval
);
1991 if (M
.x86
.mode
& SYSMODE_PREFIX_DATA
) {
1995 destoffset
= decode_rm10_address(rl
);
1997 destval
= fetch_data_long(destoffset
);
1998 srcreg
= DECODE_RM_LONG_REGISTER(rh
);
1999 DECODE_PRINTF("\n");
2001 destval
= and_long(destval
, *srcreg
);
2002 store_data_long(destoffset
, destval
);
2008 destoffset
= decode_rm10_address(rl
);
2010 destval
= fetch_data_word(destoffset
);
2011 srcreg
= DECODE_RM_WORD_REGISTER(rh
);
2012 DECODE_PRINTF("\n");
2014 destval
= and_word(destval
, *srcreg
);
2015 store_data_word(destoffset
, destval
);
2018 case 3: /* register to register */
2019 if (M
.x86
.mode
& SYSMODE_PREFIX_DATA
) {
2020 u32
*destreg
, *srcreg
;
2022 destreg
= DECODE_RM_LONG_REGISTER(rl
);
2024 srcreg
= DECODE_RM_LONG_REGISTER(rh
);
2025 DECODE_PRINTF("\n");
2027 *destreg
= and_long(*destreg
, *srcreg
);
2030 u16
*destreg
, *srcreg
;
2032 destreg
= DECODE_RM_WORD_REGISTER(rl
);
2034 srcreg
= DECODE_RM_WORD_REGISTER(rh
);
2035 DECODE_PRINTF("\n");
2037 *destreg
= and_word(*destreg
, *srcreg
);
2041 DECODE_CLEAR_SEGOVR();
2045 /****************************************************************************
2048 ****************************************************************************/
2050 x86emuOp_and_byte_R_RM(u8
X86EMU_UNUSED(op1
))
2053 u8
*destreg
, *srcreg
;
2058 DECODE_PRINTF("AND\t");
2059 FETCH_DECODE_MODRM(mod
, rh
, rl
);
2062 destreg
= DECODE_RM_BYTE_REGISTER(rh
);
2064 srcoffset
= decode_rm00_address(rl
);
2065 srcval
= fetch_data_byte(srcoffset
);
2066 DECODE_PRINTF("\n");
2068 *destreg
= and_byte(*destreg
, srcval
);
2071 destreg
= DECODE_RM_BYTE_REGISTER(rh
);
2073 srcoffset
= decode_rm01_address(rl
);
2074 srcval
= fetch_data_byte(srcoffset
);
2075 DECODE_PRINTF("\n");
2077 *destreg
= and_byte(*destreg
, srcval
);
2080 destreg
= DECODE_RM_BYTE_REGISTER(rh
);
2082 srcoffset
= decode_rm10_address(rl
);
2083 srcval
= fetch_data_byte(srcoffset
);
2084 DECODE_PRINTF("\n");
2086 *destreg
= and_byte(*destreg
, srcval
);
2088 case 3: /* register to register */
2089 destreg
= DECODE_RM_BYTE_REGISTER(rh
);
2091 srcreg
= DECODE_RM_BYTE_REGISTER(rl
);
2092 DECODE_PRINTF("\n");
2094 *destreg
= and_byte(*destreg
, *srcreg
);
2097 DECODE_CLEAR_SEGOVR();
2101 /****************************************************************************
2104 ****************************************************************************/
2106 x86emuOp_and_word_R_RM(u8
X86EMU_UNUSED(op1
))
2112 DECODE_PRINTF("AND\t");
2113 FETCH_DECODE_MODRM(mod
, rh
, rl
);
2116 if (M
.x86
.mode
& SYSMODE_PREFIX_DATA
) {
2120 destreg
= DECODE_RM_LONG_REGISTER(rh
);
2122 srcoffset
= decode_rm00_address(rl
);
2123 srcval
= fetch_data_long(srcoffset
);
2124 DECODE_PRINTF("\n");
2126 *destreg
= and_long(*destreg
, srcval
);
2132 destreg
= DECODE_RM_WORD_REGISTER(rh
);
2134 srcoffset
= decode_rm00_address(rl
);
2135 srcval
= fetch_data_word(srcoffset
);
2136 DECODE_PRINTF("\n");
2138 *destreg
= and_word(*destreg
, srcval
);
2142 if (M
.x86
.mode
& SYSMODE_PREFIX_DATA
) {
2146 destreg
= DECODE_RM_LONG_REGISTER(rh
);
2148 srcoffset
= decode_rm01_address(rl
);
2149 srcval
= fetch_data_long(srcoffset
);
2150 DECODE_PRINTF("\n");
2152 *destreg
= and_long(*destreg
, srcval
);
2159 destreg
= DECODE_RM_WORD_REGISTER(rh
);
2161 srcoffset
= decode_rm01_address(rl
);
2162 srcval
= fetch_data_word(srcoffset
);
2163 DECODE_PRINTF("\n");
2165 *destreg
= and_word(*destreg
, srcval
);
2169 if (M
.x86
.mode
& SYSMODE_PREFIX_DATA
) {
2173 destreg
= DECODE_RM_LONG_REGISTER(rh
);
2175 srcoffset
= decode_rm10_address(rl
);
2176 srcval
= fetch_data_long(srcoffset
);
2177 DECODE_PRINTF("\n");
2179 *destreg
= and_long(*destreg
, srcval
);
2185 destreg
= DECODE_RM_WORD_REGISTER(rh
);
2187 srcoffset
= decode_rm10_address(rl
);
2188 srcval
= fetch_data_word(srcoffset
);
2189 DECODE_PRINTF("\n");
2191 *destreg
= and_word(*destreg
, srcval
);
2194 case 3: /* register to register */
2195 if (M
.x86
.mode
& SYSMODE_PREFIX_DATA
) {
2196 u32
*destreg
, *srcreg
;
2198 destreg
= DECODE_RM_LONG_REGISTER(rh
);
2200 srcreg
= DECODE_RM_LONG_REGISTER(rl
);
2201 DECODE_PRINTF("\n");
2203 *destreg
= and_long(*destreg
, *srcreg
);
2206 u16
*destreg
, *srcreg
;
2208 destreg
= DECODE_RM_WORD_REGISTER(rh
);
2210 srcreg
= DECODE_RM_WORD_REGISTER(rl
);
2211 DECODE_PRINTF("\n");
2213 *destreg
= and_word(*destreg
, *srcreg
);
2217 DECODE_CLEAR_SEGOVR();
2221 /****************************************************************************
2224 ****************************************************************************/
2226 x86emuOp_and_byte_AL_IMM(u8
X86EMU_UNUSED(op1
))
2231 DECODE_PRINTF("AND\tAL,");
2232 srcval
= fetch_byte_imm();
2233 DECODE_PRINTF2("%x\n", srcval
);
2235 M
.x86
.R_AL
= and_byte(M
.x86
.R_AL
, srcval
);
2236 DECODE_CLEAR_SEGOVR();
2240 /****************************************************************************
2243 ****************************************************************************/
2245 x86emuOp_and_word_AX_IMM(u8
X86EMU_UNUSED(op1
))
2250 if (M
.x86
.mode
& SYSMODE_PREFIX_DATA
) {
2251 DECODE_PRINTF("AND\tEAX,");
2252 srcval
= fetch_long_imm();
2255 DECODE_PRINTF("AND\tAX,");
2256 srcval
= fetch_word_imm();
2258 DECODE_PRINTF2("%x\n", srcval
);
2260 if (M
.x86
.mode
& SYSMODE_PREFIX_DATA
) {
2261 M
.x86
.R_EAX
= and_long(M
.x86
.R_EAX
, srcval
);
2264 M
.x86
.R_AX
= and_word(M
.x86
.R_AX
, (u16
) srcval
);
2266 DECODE_CLEAR_SEGOVR();
2270 /****************************************************************************
2273 ****************************************************************************/
2275 x86emuOp_segovr_ES(u8
X86EMU_UNUSED(op1
))
2278 DECODE_PRINTF("ES:\n");
2280 M
.x86
.mode
|= SYSMODE_SEGOVR_ES
;
2282 * note the lack of DECODE_CLEAR_SEGOVR(r) since, here is one of 4
2283 * opcode subroutines we do not want to do this.
2288 /****************************************************************************
2291 ****************************************************************************/
2293 x86emuOp_daa(u8
X86EMU_UNUSED(op1
))
2296 DECODE_PRINTF("DAA\n");
2298 M
.x86
.R_AL
= daa_byte(M
.x86
.R_AL
);
2299 DECODE_CLEAR_SEGOVR();
2303 /****************************************************************************
2306 ****************************************************************************/
2308 x86emuOp_sub_byte_RM_R(u8
X86EMU_UNUSED(op1
))
2311 u8
*destreg
, *srcreg
;
2316 DECODE_PRINTF("SUB\t");
2317 FETCH_DECODE_MODRM(mod
, rh
, rl
);
2320 destoffset
= decode_rm00_address(rl
);
2322 destval
= fetch_data_byte(destoffset
);
2323 srcreg
= DECODE_RM_BYTE_REGISTER(rh
);
2324 DECODE_PRINTF("\n");
2326 destval
= sub_byte(destval
, *srcreg
);
2327 store_data_byte(destoffset
, destval
);
2330 destoffset
= decode_rm01_address(rl
);
2332 destval
= fetch_data_byte(destoffset
);
2333 srcreg
= DECODE_RM_BYTE_REGISTER(rh
);
2334 DECODE_PRINTF("\n");
2336 destval
= sub_byte(destval
, *srcreg
);
2337 store_data_byte(destoffset
, destval
);
2340 destoffset
= decode_rm10_address(rl
);
2342 destval
= fetch_data_byte(destoffset
);
2343 srcreg
= DECODE_RM_BYTE_REGISTER(rh
);
2344 DECODE_PRINTF("\n");
2346 destval
= sub_byte(destval
, *srcreg
);
2347 store_data_byte(destoffset
, destval
);
2349 case 3: /* register to register */
2350 destreg
= DECODE_RM_BYTE_REGISTER(rl
);
2352 srcreg
= DECODE_RM_BYTE_REGISTER(rh
);
2353 DECODE_PRINTF("\n");
2355 *destreg
= sub_byte(*destreg
, *srcreg
);
2358 DECODE_CLEAR_SEGOVR();
2362 /****************************************************************************
2365 ****************************************************************************/
2367 x86emuOp_sub_word_RM_R(u8
X86EMU_UNUSED(op1
))
2373 DECODE_PRINTF("SUB\t");
2374 FETCH_DECODE_MODRM(mod
, rh
, rl
);
2377 if (M
.x86
.mode
& SYSMODE_PREFIX_DATA
) {
2381 destoffset
= decode_rm00_address(rl
);
2383 destval
= fetch_data_long(destoffset
);
2384 srcreg
= DECODE_RM_LONG_REGISTER(rh
);
2385 DECODE_PRINTF("\n");
2387 destval
= sub_long(destval
, *srcreg
);
2388 store_data_long(destoffset
, destval
);
2394 destoffset
= decode_rm00_address(rl
);
2396 destval
= fetch_data_word(destoffset
);
2397 srcreg
= DECODE_RM_WORD_REGISTER(rh
);
2398 DECODE_PRINTF("\n");
2400 destval
= sub_word(destval
, *srcreg
);
2401 store_data_word(destoffset
, destval
);
2405 if (M
.x86
.mode
& SYSMODE_PREFIX_DATA
) {
2409 destoffset
= decode_rm01_address(rl
);
2411 destval
= fetch_data_long(destoffset
);
2412 srcreg
= DECODE_RM_LONG_REGISTER(rh
);
2413 DECODE_PRINTF("\n");
2415 destval
= sub_long(destval
, *srcreg
);
2416 store_data_long(destoffset
, destval
);
2422 destoffset
= decode_rm01_address(rl
);
2424 destval
= fetch_data_word(destoffset
);
2425 srcreg
= DECODE_RM_WORD_REGISTER(rh
);
2426 DECODE_PRINTF("\n");
2428 destval
= sub_word(destval
, *srcreg
);
2429 store_data_word(destoffset
, destval
);
2433 if (M
.x86
.mode
& SYSMODE_PREFIX_DATA
) {
2437 destoffset
= decode_rm10_address(rl
);
2439 destval
= fetch_data_long(destoffset
);
2440 srcreg
= DECODE_RM_LONG_REGISTER(rh
);
2441 DECODE_PRINTF("\n");
2443 destval
= sub_long(destval
, *srcreg
);
2444 store_data_long(destoffset
, destval
);
2450 destoffset
= decode_rm10_address(rl
);
2452 destval
= fetch_data_word(destoffset
);
2453 srcreg
= DECODE_RM_WORD_REGISTER(rh
);
2454 DECODE_PRINTF("\n");
2456 destval
= sub_word(destval
, *srcreg
);
2457 store_data_word(destoffset
, destval
);
2460 case 3: /* register to register */
2461 if (M
.x86
.mode
& SYSMODE_PREFIX_DATA
) {
2462 u32
*destreg
, *srcreg
;
2464 destreg
= DECODE_RM_LONG_REGISTER(rl
);
2466 srcreg
= DECODE_RM_LONG_REGISTER(rh
);
2467 DECODE_PRINTF("\n");
2469 *destreg
= sub_long(*destreg
, *srcreg
);
2472 u16
*destreg
, *srcreg
;
2474 destreg
= DECODE_RM_WORD_REGISTER(rl
);
2476 srcreg
= DECODE_RM_WORD_REGISTER(rh
);
2477 DECODE_PRINTF("\n");
2479 *destreg
= sub_word(*destreg
, *srcreg
);
2483 DECODE_CLEAR_SEGOVR();
2487 /****************************************************************************
2490 ****************************************************************************/
2492 x86emuOp_sub_byte_R_RM(u8
X86EMU_UNUSED(op1
))
2495 u8
*destreg
, *srcreg
;
2500 DECODE_PRINTF("SUB\t");
2501 FETCH_DECODE_MODRM(mod
, rh
, rl
);
2504 destreg
= DECODE_RM_BYTE_REGISTER(rh
);
2506 srcoffset
= decode_rm00_address(rl
);
2507 srcval
= fetch_data_byte(srcoffset
);
2508 DECODE_PRINTF("\n");
2510 *destreg
= sub_byte(*destreg
, srcval
);
2513 destreg
= DECODE_RM_BYTE_REGISTER(rh
);
2515 srcoffset
= decode_rm01_address(rl
);
2516 srcval
= fetch_data_byte(srcoffset
);
2517 DECODE_PRINTF("\n");
2519 *destreg
= sub_byte(*destreg
, srcval
);
2522 destreg
= DECODE_RM_BYTE_REGISTER(rh
);
2524 srcoffset
= decode_rm10_address(rl
);
2525 srcval
= fetch_data_byte(srcoffset
);
2526 DECODE_PRINTF("\n");
2528 *destreg
= sub_byte(*destreg
, srcval
);
2530 case 3: /* register to register */
2531 destreg
= DECODE_RM_BYTE_REGISTER(rh
);
2533 srcreg
= DECODE_RM_BYTE_REGISTER(rl
);
2534 DECODE_PRINTF("\n");
2536 *destreg
= sub_byte(*destreg
, *srcreg
);
2539 DECODE_CLEAR_SEGOVR();
2543 /****************************************************************************
2546 ****************************************************************************/
2548 x86emuOp_sub_word_R_RM(u8
X86EMU_UNUSED(op1
))
2554 DECODE_PRINTF("SUB\t");
2555 FETCH_DECODE_MODRM(mod
, rh
, rl
);
2558 if (M
.x86
.mode
& SYSMODE_PREFIX_DATA
) {
2562 destreg
= DECODE_RM_LONG_REGISTER(rh
);
2564 srcoffset
= decode_rm00_address(rl
);
2565 srcval
= fetch_data_long(srcoffset
);
2566 DECODE_PRINTF("\n");
2568 *destreg
= sub_long(*destreg
, srcval
);
2574 destreg
= DECODE_RM_WORD_REGISTER(rh
);
2576 srcoffset
= decode_rm00_address(rl
);
2577 srcval
= fetch_data_word(srcoffset
);
2578 DECODE_PRINTF("\n");
2580 *destreg
= sub_word(*destreg
, srcval
);
2584 if (M
.x86
.mode
& SYSMODE_PREFIX_DATA
) {
2588 destreg
= DECODE_RM_LONG_REGISTER(rh
);
2590 srcoffset
= decode_rm01_address(rl
);
2591 srcval
= fetch_data_long(srcoffset
);
2592 DECODE_PRINTF("\n");
2594 *destreg
= sub_long(*destreg
, srcval
);
2600 destreg
= DECODE_RM_WORD_REGISTER(rh
);
2602 srcoffset
= decode_rm01_address(rl
);
2603 srcval
= fetch_data_word(srcoffset
);
2604 DECODE_PRINTF("\n");
2606 *destreg
= sub_word(*destreg
, srcval
);
2610 if (M
.x86
.mode
& SYSMODE_PREFIX_DATA
) {
2614 destreg
= DECODE_RM_LONG_REGISTER(rh
);
2616 srcoffset
= decode_rm10_address(rl
);
2617 srcval
= fetch_data_long(srcoffset
);
2618 DECODE_PRINTF("\n");
2620 *destreg
= sub_long(*destreg
, srcval
);
2626 destreg
= DECODE_RM_WORD_REGISTER(rh
);
2628 srcoffset
= decode_rm10_address(rl
);
2629 srcval
= fetch_data_word(srcoffset
);
2630 DECODE_PRINTF("\n");
2632 *destreg
= sub_word(*destreg
, srcval
);
2635 case 3: /* register to register */
2636 if (M
.x86
.mode
& SYSMODE_PREFIX_DATA
) {
2637 u32
*destreg
, *srcreg
;
2639 destreg
= DECODE_RM_LONG_REGISTER(rh
);
2641 srcreg
= DECODE_RM_LONG_REGISTER(rl
);
2642 DECODE_PRINTF("\n");
2644 *destreg
= sub_long(*destreg
, *srcreg
);
2647 u16
*destreg
, *srcreg
;
2649 destreg
= DECODE_RM_WORD_REGISTER(rh
);
2651 srcreg
= DECODE_RM_WORD_REGISTER(rl
);
2652 DECODE_PRINTF("\n");
2654 *destreg
= sub_word(*destreg
, *srcreg
);
2658 DECODE_CLEAR_SEGOVR();
2662 /****************************************************************************
2665 ****************************************************************************/
2667 x86emuOp_sub_byte_AL_IMM(u8
X86EMU_UNUSED(op1
))
2672 DECODE_PRINTF("SUB\tAL,");
2673 srcval
= fetch_byte_imm();
2674 DECODE_PRINTF2("%x\n", srcval
);
2676 M
.x86
.R_AL
= sub_byte(M
.x86
.R_AL
, srcval
);
2677 DECODE_CLEAR_SEGOVR();
2681 /****************************************************************************
2684 ****************************************************************************/
2686 x86emuOp_sub_word_AX_IMM(u8
X86EMU_UNUSED(op1
))
2691 if (M
.x86
.mode
& SYSMODE_PREFIX_DATA
) {
2692 DECODE_PRINTF("SUB\tEAX,");
2693 srcval
= fetch_long_imm();
2696 DECODE_PRINTF("SUB\tAX,");
2697 srcval
= fetch_word_imm();
2699 DECODE_PRINTF2("%x\n", srcval
);
2701 if (M
.x86
.mode
& SYSMODE_PREFIX_DATA
) {
2702 M
.x86
.R_EAX
= sub_long(M
.x86
.R_EAX
, srcval
);
2705 M
.x86
.R_AX
= sub_word(M
.x86
.R_AX
, (u16
) srcval
);
2707 DECODE_CLEAR_SEGOVR();
2711 /****************************************************************************
2714 ****************************************************************************/
2716 x86emuOp_segovr_CS(u8
X86EMU_UNUSED(op1
))
2719 DECODE_PRINTF("CS:\n");
2721 M
.x86
.mode
|= SYSMODE_SEGOVR_CS
;
2722 /* note no DECODE_CLEAR_SEGOVR here. */
2726 /****************************************************************************
2729 ****************************************************************************/
2731 x86emuOp_das(u8
X86EMU_UNUSED(op1
))
2734 DECODE_PRINTF("DAS\n");
2736 M
.x86
.R_AL
= das_byte(M
.x86
.R_AL
);
2737 DECODE_CLEAR_SEGOVR();
2741 /****************************************************************************
2744 ****************************************************************************/
2746 x86emuOp_xor_byte_RM_R(u8
X86EMU_UNUSED(op1
))
2749 u8
*destreg
, *srcreg
;
2754 DECODE_PRINTF("XOR\t");
2755 FETCH_DECODE_MODRM(mod
, rh
, rl
);
2758 destoffset
= decode_rm00_address(rl
);
2760 destval
= fetch_data_byte(destoffset
);
2761 srcreg
= DECODE_RM_BYTE_REGISTER(rh
);
2762 DECODE_PRINTF("\n");
2764 destval
= xor_byte(destval
, *srcreg
);
2765 store_data_byte(destoffset
, destval
);
2768 destoffset
= decode_rm01_address(rl
);
2770 destval
= fetch_data_byte(destoffset
);
2771 srcreg
= DECODE_RM_BYTE_REGISTER(rh
);
2772 DECODE_PRINTF("\n");
2774 destval
= xor_byte(destval
, *srcreg
);
2775 store_data_byte(destoffset
, destval
);
2778 destoffset
= decode_rm10_address(rl
);
2780 destval
= fetch_data_byte(destoffset
);
2781 srcreg
= DECODE_RM_BYTE_REGISTER(rh
);
2782 DECODE_PRINTF("\n");
2784 destval
= xor_byte(destval
, *srcreg
);
2785 store_data_byte(destoffset
, destval
);
2787 case 3: /* register to register */
2788 destreg
= DECODE_RM_BYTE_REGISTER(rl
);
2790 srcreg
= DECODE_RM_BYTE_REGISTER(rh
);
2791 DECODE_PRINTF("\n");
2793 *destreg
= xor_byte(*destreg
, *srcreg
);
2796 DECODE_CLEAR_SEGOVR();
2800 /****************************************************************************
2803 ****************************************************************************/
2805 x86emuOp_xor_word_RM_R(u8
X86EMU_UNUSED(op1
))
2811 DECODE_PRINTF("XOR\t");
2812 FETCH_DECODE_MODRM(mod
, rh
, rl
);
2815 if (M
.x86
.mode
& SYSMODE_PREFIX_DATA
) {
2819 destoffset
= decode_rm00_address(rl
);
2821 destval
= fetch_data_long(destoffset
);
2822 srcreg
= DECODE_RM_LONG_REGISTER(rh
);
2823 DECODE_PRINTF("\n");
2825 destval
= xor_long(destval
, *srcreg
);
2826 store_data_long(destoffset
, destval
);
2832 destoffset
= decode_rm00_address(rl
);
2834 destval
= fetch_data_word(destoffset
);
2835 srcreg
= DECODE_RM_WORD_REGISTER(rh
);
2836 DECODE_PRINTF("\n");
2838 destval
= xor_word(destval
, *srcreg
);
2839 store_data_word(destoffset
, destval
);
2843 if (M
.x86
.mode
& SYSMODE_PREFIX_DATA
) {
2847 destoffset
= decode_rm01_address(rl
);
2849 destval
= fetch_data_long(destoffset
);
2850 srcreg
= DECODE_RM_LONG_REGISTER(rh
);
2851 DECODE_PRINTF("\n");
2853 destval
= xor_long(destval
, *srcreg
);
2854 store_data_long(destoffset
, destval
);
2860 destoffset
= decode_rm01_address(rl
);
2862 destval
= fetch_data_word(destoffset
);
2863 srcreg
= DECODE_RM_WORD_REGISTER(rh
);
2864 DECODE_PRINTF("\n");
2866 destval
= xor_word(destval
, *srcreg
);
2867 store_data_word(destoffset
, destval
);
2871 if (M
.x86
.mode
& SYSMODE_PREFIX_DATA
) {
2875 destoffset
= decode_rm10_address(rl
);
2877 destval
= fetch_data_long(destoffset
);
2878 srcreg
= DECODE_RM_LONG_REGISTER(rh
);
2879 DECODE_PRINTF("\n");
2881 destval
= xor_long(destval
, *srcreg
);
2882 store_data_long(destoffset
, destval
);
2888 destoffset
= decode_rm10_address(rl
);
2890 destval
= fetch_data_word(destoffset
);
2891 srcreg
= DECODE_RM_WORD_REGISTER(rh
);
2892 DECODE_PRINTF("\n");
2894 destval
= xor_word(destval
, *srcreg
);
2895 store_data_word(destoffset
, destval
);
2898 case 3: /* register to register */
2899 if (M
.x86
.mode
& SYSMODE_PREFIX_DATA
) {
2900 u32
*destreg
, *srcreg
;
2902 destreg
= DECODE_RM_LONG_REGISTER(rl
);
2904 srcreg
= DECODE_RM_LONG_REGISTER(rh
);
2905 DECODE_PRINTF("\n");
2907 *destreg
= xor_long(*destreg
, *srcreg
);
2910 u16
*destreg
, *srcreg
;
2912 destreg
= DECODE_RM_WORD_REGISTER(rl
);
2914 srcreg
= DECODE_RM_WORD_REGISTER(rh
);
2915 DECODE_PRINTF("\n");
2917 *destreg
= xor_word(*destreg
, *srcreg
);
2921 DECODE_CLEAR_SEGOVR();
2925 /****************************************************************************
2928 ****************************************************************************/
2930 x86emuOp_xor_byte_R_RM(u8
X86EMU_UNUSED(op1
))
2933 u8
*destreg
, *srcreg
;
2938 DECODE_PRINTF("XOR\t");
2939 FETCH_DECODE_MODRM(mod
, rh
, rl
);
2942 destreg
= DECODE_RM_BYTE_REGISTER(rh
);
2944 srcoffset
= decode_rm00_address(rl
);
2945 srcval
= fetch_data_byte(srcoffset
);
2946 DECODE_PRINTF("\n");
2948 *destreg
= xor_byte(*destreg
, srcval
);
2951 destreg
= DECODE_RM_BYTE_REGISTER(rh
);
2953 srcoffset
= decode_rm01_address(rl
);
2954 srcval
= fetch_data_byte(srcoffset
);
2955 DECODE_PRINTF("\n");
2957 *destreg
= xor_byte(*destreg
, srcval
);
2960 destreg
= DECODE_RM_BYTE_REGISTER(rh
);
2962 srcoffset
= decode_rm10_address(rl
);
2963 srcval
= fetch_data_byte(srcoffset
);
2964 DECODE_PRINTF("\n");
2966 *destreg
= xor_byte(*destreg
, srcval
);
2968 case 3: /* register to register */
2969 destreg
= DECODE_RM_BYTE_REGISTER(rh
);
2971 srcreg
= DECODE_RM_BYTE_REGISTER(rl
);
2972 DECODE_PRINTF("\n");
2974 *destreg
= xor_byte(*destreg
, *srcreg
);
2977 DECODE_CLEAR_SEGOVR();
2981 /****************************************************************************
2984 ****************************************************************************/
2986 x86emuOp_xor_word_R_RM(u8
X86EMU_UNUSED(op1
))
2992 DECODE_PRINTF("XOR\t");
2993 FETCH_DECODE_MODRM(mod
, rh
, rl
);
2996 if (M
.x86
.mode
& SYSMODE_PREFIX_DATA
) {
3000 destreg
= DECODE_RM_LONG_REGISTER(rh
);
3002 srcoffset
= decode_rm00_address(rl
);
3003 srcval
= fetch_data_long(srcoffset
);
3004 DECODE_PRINTF("\n");
3006 *destreg
= xor_long(*destreg
, srcval
);
3012 destreg
= DECODE_RM_WORD_REGISTER(rh
);
3014 srcoffset
= decode_rm00_address(rl
);
3015 srcval
= fetch_data_word(srcoffset
);
3016 DECODE_PRINTF("\n");
3018 *destreg
= xor_word(*destreg
, srcval
);
3022 if (M
.x86
.mode
& SYSMODE_PREFIX_DATA
) {
3026 destreg
= DECODE_RM_LONG_REGISTER(rh
);
3028 srcoffset
= decode_rm01_address(rl
);
3029 srcval
= fetch_data_long(srcoffset
);
3030 DECODE_PRINTF("\n");
3032 *destreg
= xor_long(*destreg
, srcval
);
3038 destreg
= DECODE_RM_WORD_REGISTER(rh
);
3040 srcoffset
= decode_rm01_address(rl
);
3041 srcval
= fetch_data_word(srcoffset
);
3042 DECODE_PRINTF("\n");
3044 *destreg
= xor_word(*destreg
, srcval
);
3048 if (M
.x86
.mode
& SYSMODE_PREFIX_DATA
) {
3052 destreg
= DECODE_RM_LONG_REGISTER(rh
);
3054 srcoffset
= decode_rm10_address(rl
);
3055 srcval
= fetch_data_long(srcoffset
);
3056 DECODE_PRINTF("\n");
3058 *destreg
= xor_long(*destreg
, srcval
);
3064 destreg
= DECODE_RM_WORD_REGISTER(rh
);
3066 srcoffset
= decode_rm10_address(rl
);
3067 srcval
= fetch_data_word(srcoffset
);
3068 DECODE_PRINTF("\n");
3070 *destreg
= xor_word(*destreg
, srcval
);
3073 case 3: /* register to register */
3074 if (M
.x86
.mode
& SYSMODE_PREFIX_DATA
) {
3075 u32
*destreg
, *srcreg
;
3077 destreg
= DECODE_RM_LONG_REGISTER(rh
);
3079 srcreg
= DECODE_RM_LONG_REGISTER(rl
);
3080 DECODE_PRINTF("\n");
3082 *destreg
= xor_long(*destreg
, *srcreg
);
3085 u16
*destreg
, *srcreg
;
3087 destreg
= DECODE_RM_WORD_REGISTER(rh
);
3089 srcreg
= DECODE_RM_WORD_REGISTER(rl
);
3090 DECODE_PRINTF("\n");
3092 *destreg
= xor_word(*destreg
, *srcreg
);
3096 DECODE_CLEAR_SEGOVR();
3100 /****************************************************************************
3103 ****************************************************************************/
3105 x86emuOp_xor_byte_AL_IMM(u8
X86EMU_UNUSED(op1
))
3110 DECODE_PRINTF("XOR\tAL,");
3111 srcval
= fetch_byte_imm();
3112 DECODE_PRINTF2("%x\n", srcval
);
3114 M
.x86
.R_AL
= xor_byte(M
.x86
.R_AL
, srcval
);
3115 DECODE_CLEAR_SEGOVR();
3119 /****************************************************************************
3122 ****************************************************************************/
3124 x86emuOp_xor_word_AX_IMM(u8
X86EMU_UNUSED(op1
))
3129 if (M
.x86
.mode
& SYSMODE_PREFIX_DATA
) {
3130 DECODE_PRINTF("XOR\tEAX,");
3131 srcval
= fetch_long_imm();
3134 DECODE_PRINTF("XOR\tAX,");
3135 srcval
= fetch_word_imm();
3137 DECODE_PRINTF2("%x\n", srcval
);
3139 if (M
.x86
.mode
& SYSMODE_PREFIX_DATA
) {
3140 M
.x86
.R_EAX
= xor_long(M
.x86
.R_EAX
, srcval
);
3143 M
.x86
.R_AX
= xor_word(M
.x86
.R_AX
, (u16
) srcval
);
3145 DECODE_CLEAR_SEGOVR();
3149 /****************************************************************************
3152 ****************************************************************************/
3154 x86emuOp_segovr_SS(u8
X86EMU_UNUSED(op1
))
3157 DECODE_PRINTF("SS:\n");
3159 M
.x86
.mode
|= SYSMODE_SEGOVR_SS
;
3160 /* no DECODE_CLEAR_SEGOVR ! */
3164 /****************************************************************************
3167 ****************************************************************************/
3169 x86emuOp_aaa(u8
X86EMU_UNUSED(op1
))
3172 DECODE_PRINTF("AAA\n");
3174 M
.x86
.R_AX
= aaa_word(M
.x86
.R_AX
);
3175 DECODE_CLEAR_SEGOVR();
3179 /****************************************************************************
3182 ****************************************************************************/
3184 x86emuOp_cmp_byte_RM_R(u8
X86EMU_UNUSED(op1
))
3188 u8
*destreg
, *srcreg
;
3192 DECODE_PRINTF("CMP\t");
3193 FETCH_DECODE_MODRM(mod
, rh
, rl
);
3196 destoffset
= decode_rm00_address(rl
);
3198 destval
= fetch_data_byte(destoffset
);
3199 srcreg
= DECODE_RM_BYTE_REGISTER(rh
);
3200 DECODE_PRINTF("\n");
3202 cmp_byte(destval
, *srcreg
);
3205 destoffset
= decode_rm01_address(rl
);
3207 destval
= fetch_data_byte(destoffset
);
3208 srcreg
= DECODE_RM_BYTE_REGISTER(rh
);
3209 DECODE_PRINTF("\n");
3211 cmp_byte(destval
, *srcreg
);
3214 destoffset
= decode_rm10_address(rl
);
3216 destval
= fetch_data_byte(destoffset
);
3217 srcreg
= DECODE_RM_BYTE_REGISTER(rh
);
3218 DECODE_PRINTF("\n");
3220 cmp_byte(destval
, *srcreg
);
3222 case 3: /* register to register */
3223 destreg
= DECODE_RM_BYTE_REGISTER(rl
);
3225 srcreg
= DECODE_RM_BYTE_REGISTER(rh
);
3226 DECODE_PRINTF("\n");
3228 cmp_byte(*destreg
, *srcreg
);
3231 DECODE_CLEAR_SEGOVR();
3235 /****************************************************************************
3238 ****************************************************************************/
3240 x86emuOp_cmp_word_RM_R(u8
X86EMU_UNUSED(op1
))
3246 DECODE_PRINTF("CMP\t");
3247 FETCH_DECODE_MODRM(mod
, rh
, rl
);
3250 if (M
.x86
.mode
& SYSMODE_PREFIX_DATA
) {
3254 destoffset
= decode_rm00_address(rl
);
3256 destval
= fetch_data_long(destoffset
);
3257 srcreg
= DECODE_RM_LONG_REGISTER(rh
);
3258 DECODE_PRINTF("\n");
3260 cmp_long(destval
, *srcreg
);
3266 destoffset
= decode_rm00_address(rl
);
3268 destval
= fetch_data_word(destoffset
);
3269 srcreg
= DECODE_RM_WORD_REGISTER(rh
);
3270 DECODE_PRINTF("\n");
3272 cmp_word(destval
, *srcreg
);
3276 if (M
.x86
.mode
& SYSMODE_PREFIX_DATA
) {
3280 destoffset
= decode_rm01_address(rl
);
3282 destval
= fetch_data_long(destoffset
);
3283 srcreg
= DECODE_RM_LONG_REGISTER(rh
);
3284 DECODE_PRINTF("\n");
3286 cmp_long(destval
, *srcreg
);
3292 destoffset
= decode_rm01_address(rl
);
3294 destval
= fetch_data_word(destoffset
);
3295 srcreg
= DECODE_RM_WORD_REGISTER(rh
);
3296 DECODE_PRINTF("\n");
3298 cmp_word(destval
, *srcreg
);
3302 if (M
.x86
.mode
& SYSMODE_PREFIX_DATA
) {
3306 destoffset
= decode_rm10_address(rl
);
3308 destval
= fetch_data_long(destoffset
);
3309 srcreg
= DECODE_RM_LONG_REGISTER(rh
);
3310 DECODE_PRINTF("\n");
3312 cmp_long(destval
, *srcreg
);
3318 destoffset
= decode_rm10_address(rl
);
3320 destval
= fetch_data_word(destoffset
);
3321 srcreg
= DECODE_RM_WORD_REGISTER(rh
);
3322 DECODE_PRINTF("\n");
3324 cmp_word(destval
, *srcreg
);
3327 case 3: /* register to register */
3328 if (M
.x86
.mode
& SYSMODE_PREFIX_DATA
) {
3329 u32
*destreg
, *srcreg
;
3331 destreg
= DECODE_RM_LONG_REGISTER(rl
);
3333 srcreg
= DECODE_RM_LONG_REGISTER(rh
);
3334 DECODE_PRINTF("\n");
3336 cmp_long(*destreg
, *srcreg
);
3339 u16
*destreg
, *srcreg
;
3341 destreg
= DECODE_RM_WORD_REGISTER(rl
);
3343 srcreg
= DECODE_RM_WORD_REGISTER(rh
);
3344 DECODE_PRINTF("\n");
3346 cmp_word(*destreg
, *srcreg
);
3350 DECODE_CLEAR_SEGOVR();
3354 /****************************************************************************
3357 ****************************************************************************/
3359 x86emuOp_cmp_byte_R_RM(u8
X86EMU_UNUSED(op1
))
3362 u8
*destreg
, *srcreg
;
3367 DECODE_PRINTF("CMP\t");
3368 FETCH_DECODE_MODRM(mod
, rh
, rl
);
3371 destreg
= DECODE_RM_BYTE_REGISTER(rh
);
3373 srcoffset
= decode_rm00_address(rl
);
3374 srcval
= fetch_data_byte(srcoffset
);
3375 DECODE_PRINTF("\n");
3377 cmp_byte(*destreg
, srcval
);
3380 destreg
= DECODE_RM_BYTE_REGISTER(rh
);
3382 srcoffset
= decode_rm01_address(rl
);
3383 srcval
= fetch_data_byte(srcoffset
);
3384 DECODE_PRINTF("\n");
3386 cmp_byte(*destreg
, srcval
);
3389 destreg
= DECODE_RM_BYTE_REGISTER(rh
);
3391 srcoffset
= decode_rm10_address(rl
);
3392 srcval
= fetch_data_byte(srcoffset
);
3393 DECODE_PRINTF("\n");
3395 cmp_byte(*destreg
, srcval
);
3397 case 3: /* register to register */
3398 destreg
= DECODE_RM_BYTE_REGISTER(rh
);
3400 srcreg
= DECODE_RM_BYTE_REGISTER(rl
);
3401 DECODE_PRINTF("\n");
3403 cmp_byte(*destreg
, *srcreg
);
3406 DECODE_CLEAR_SEGOVR();
3410 /****************************************************************************
3413 ****************************************************************************/
3415 x86emuOp_cmp_word_R_RM(u8
X86EMU_UNUSED(op1
))
3421 DECODE_PRINTF("CMP\t");
3422 FETCH_DECODE_MODRM(mod
, rh
, rl
);
3425 if (M
.x86
.mode
& SYSMODE_PREFIX_DATA
) {
3429 destreg
= DECODE_RM_LONG_REGISTER(rh
);
3431 srcoffset
= decode_rm00_address(rl
);
3432 srcval
= fetch_data_long(srcoffset
);
3433 DECODE_PRINTF("\n");
3435 cmp_long(*destreg
, srcval
);
3441 destreg
= DECODE_RM_WORD_REGISTER(rh
);
3443 srcoffset
= decode_rm00_address(rl
);
3444 srcval
= fetch_data_word(srcoffset
);
3445 DECODE_PRINTF("\n");
3447 cmp_word(*destreg
, srcval
);
3451 if (M
.x86
.mode
& SYSMODE_PREFIX_DATA
) {
3455 destreg
= DECODE_RM_LONG_REGISTER(rh
);
3457 srcoffset
= decode_rm01_address(rl
);
3458 srcval
= fetch_data_long(srcoffset
);
3459 DECODE_PRINTF("\n");
3461 cmp_long(*destreg
, srcval
);
3467 destreg
= DECODE_RM_WORD_REGISTER(rh
);
3469 srcoffset
= decode_rm01_address(rl
);
3470 srcval
= fetch_data_word(srcoffset
);
3471 DECODE_PRINTF("\n");
3473 cmp_word(*destreg
, srcval
);
3477 if (M
.x86
.mode
& SYSMODE_PREFIX_DATA
) {
3481 destreg
= DECODE_RM_LONG_REGISTER(rh
);
3483 srcoffset
= decode_rm10_address(rl
);
3484 srcval
= fetch_data_long(srcoffset
);
3485 DECODE_PRINTF("\n");
3487 cmp_long(*destreg
, srcval
);
3493 destreg
= DECODE_RM_WORD_REGISTER(rh
);
3495 srcoffset
= decode_rm10_address(rl
);
3496 srcval
= fetch_data_word(srcoffset
);
3497 DECODE_PRINTF("\n");
3499 cmp_word(*destreg
, srcval
);
3502 case 3: /* register to register */
3503 if (M
.x86
.mode
& SYSMODE_PREFIX_DATA
) {
3504 u32
*destreg
, *srcreg
;
3506 destreg
= DECODE_RM_LONG_REGISTER(rh
);
3508 srcreg
= DECODE_RM_LONG_REGISTER(rl
);
3509 DECODE_PRINTF("\n");
3511 cmp_long(*destreg
, *srcreg
);
3514 u16
*destreg
, *srcreg
;
3516 destreg
= DECODE_RM_WORD_REGISTER(rh
);
3518 srcreg
= DECODE_RM_WORD_REGISTER(rl
);
3519 DECODE_PRINTF("\n");
3521 cmp_word(*destreg
, *srcreg
);
3525 DECODE_CLEAR_SEGOVR();
3529 /****************************************************************************
3532 ****************************************************************************/
3534 x86emuOp_cmp_byte_AL_IMM(u8
X86EMU_UNUSED(op1
))
3539 DECODE_PRINTF("CMP\tAL,");
3540 srcval
= fetch_byte_imm();
3541 DECODE_PRINTF2("%x\n", srcval
);
3543 cmp_byte(M
.x86
.R_AL
, srcval
);
3544 DECODE_CLEAR_SEGOVR();
3548 /****************************************************************************
3551 ****************************************************************************/
3553 x86emuOp_cmp_word_AX_IMM(u8
X86EMU_UNUSED(op1
))
3558 if (M
.x86
.mode
& SYSMODE_PREFIX_DATA
) {
3559 DECODE_PRINTF("CMP\tEAX,");
3560 srcval
= fetch_long_imm();
3563 DECODE_PRINTF("CMP\tAX,");
3564 srcval
= fetch_word_imm();
3566 DECODE_PRINTF2("%x\n", srcval
);
3568 if (M
.x86
.mode
& SYSMODE_PREFIX_DATA
) {
3569 cmp_long(M
.x86
.R_EAX
, srcval
);
3572 cmp_word(M
.x86
.R_AX
, (u16
) srcval
);
3574 DECODE_CLEAR_SEGOVR();
3578 /****************************************************************************
3581 ****************************************************************************/
3583 x86emuOp_segovr_DS(u8
X86EMU_UNUSED(op1
))
3586 DECODE_PRINTF("DS:\n");
3588 M
.x86
.mode
|= SYSMODE_SEGOVR_DS
;
3589 /* NO DECODE_CLEAR_SEGOVR! */
3593 /****************************************************************************
3596 ****************************************************************************/
3598 x86emuOp_aas(u8
X86EMU_UNUSED(op1
))
3601 DECODE_PRINTF("AAS\n");
3603 M
.x86
.R_AX
= aas_word(M
.x86
.R_AX
);
3604 DECODE_CLEAR_SEGOVR();
3608 /****************************************************************************
3611 ****************************************************************************/
3613 x86emuOp_inc_AX(u8
X86EMU_UNUSED(op1
))
3616 if (M
.x86
.mode
& SYSMODE_PREFIX_DATA
) {
3617 DECODE_PRINTF("INC\tEAX\n");
3620 DECODE_PRINTF("INC\tAX\n");
3623 if (M
.x86
.mode
& SYSMODE_PREFIX_DATA
) {
3624 M
.x86
.R_EAX
= inc_long(M
.x86
.R_EAX
);
3627 M
.x86
.R_AX
= inc_word(M
.x86
.R_AX
);
3629 DECODE_CLEAR_SEGOVR();
3633 /****************************************************************************
3636 ****************************************************************************/
3638 x86emuOp_inc_CX(u8
X86EMU_UNUSED(op1
))
3641 if (M
.x86
.mode
& SYSMODE_PREFIX_DATA
) {
3642 DECODE_PRINTF("INC\tECX\n");
3645 DECODE_PRINTF("INC\tCX\n");
3648 if (M
.x86
.mode
& SYSMODE_PREFIX_DATA
) {
3649 M
.x86
.R_ECX
= inc_long(M
.x86
.R_ECX
);
3652 M
.x86
.R_CX
= inc_word(M
.x86
.R_CX
);
3654 DECODE_CLEAR_SEGOVR();
3658 /****************************************************************************
3661 ****************************************************************************/
3663 x86emuOp_inc_DX(u8
X86EMU_UNUSED(op1
))
3666 if (M
.x86
.mode
& SYSMODE_PREFIX_DATA
) {
3667 DECODE_PRINTF("INC\tEDX\n");
3670 DECODE_PRINTF("INC\tDX\n");
3673 if (M
.x86
.mode
& SYSMODE_PREFIX_DATA
) {
3674 M
.x86
.R_EDX
= inc_long(M
.x86
.R_EDX
);
3677 M
.x86
.R_DX
= inc_word(M
.x86
.R_DX
);
3679 DECODE_CLEAR_SEGOVR();
3683 /****************************************************************************
3686 ****************************************************************************/
3688 x86emuOp_inc_BX(u8
X86EMU_UNUSED(op1
))
3691 if (M
.x86
.mode
& SYSMODE_PREFIX_DATA
) {
3692 DECODE_PRINTF("INC\tEBX\n");
3695 DECODE_PRINTF("INC\tBX\n");
3698 if (M
.x86
.mode
& SYSMODE_PREFIX_DATA
) {
3699 M
.x86
.R_EBX
= inc_long(M
.x86
.R_EBX
);
3702 M
.x86
.R_BX
= inc_word(M
.x86
.R_BX
);
3704 DECODE_CLEAR_SEGOVR();
3708 /****************************************************************************
3711 ****************************************************************************/
3713 x86emuOp_inc_SP(u8
X86EMU_UNUSED(op1
))
3716 if (M
.x86
.mode
& SYSMODE_PREFIX_DATA
) {
3717 DECODE_PRINTF("INC\tESP\n");
3720 DECODE_PRINTF("INC\tSP\n");
3723 if (M
.x86
.mode
& SYSMODE_PREFIX_DATA
) {
3724 M
.x86
.R_ESP
= inc_long(M
.x86
.R_ESP
);
3727 M
.x86
.R_SP
= inc_word(M
.x86
.R_SP
);
3729 DECODE_CLEAR_SEGOVR();
3733 /****************************************************************************
3736 ****************************************************************************/
3738 x86emuOp_inc_BP(u8
X86EMU_UNUSED(op1
))
3741 if (M
.x86
.mode
& SYSMODE_PREFIX_DATA
) {
3742 DECODE_PRINTF("INC\tEBP\n");
3745 DECODE_PRINTF("INC\tBP\n");
3748 if (M
.x86
.mode
& SYSMODE_PREFIX_DATA
) {
3749 M
.x86
.R_EBP
= inc_long(M
.x86
.R_EBP
);
3752 M
.x86
.R_BP
= inc_word(M
.x86
.R_BP
);
3754 DECODE_CLEAR_SEGOVR();
3758 /****************************************************************************
3761 ****************************************************************************/
3763 x86emuOp_inc_SI(u8
X86EMU_UNUSED(op1
))
3766 if (M
.x86
.mode
& SYSMODE_PREFIX_DATA
) {
3767 DECODE_PRINTF("INC\tESI\n");
3770 DECODE_PRINTF("INC\tSI\n");
3773 if (M
.x86
.mode
& SYSMODE_PREFIX_DATA
) {
3774 M
.x86
.R_ESI
= inc_long(M
.x86
.R_ESI
);
3777 M
.x86
.R_SI
= inc_word(M
.x86
.R_SI
);
3779 DECODE_CLEAR_SEGOVR();
3783 /****************************************************************************
3786 ****************************************************************************/
3788 x86emuOp_inc_DI(u8
X86EMU_UNUSED(op1
))
3791 if (M
.x86
.mode
& SYSMODE_PREFIX_DATA
) {
3792 DECODE_PRINTF("INC\tEDI\n");
3795 DECODE_PRINTF("INC\tDI\n");
3798 if (M
.x86
.mode
& SYSMODE_PREFIX_DATA
) {
3799 M
.x86
.R_EDI
= inc_long(M
.x86
.R_EDI
);
3802 M
.x86
.R_DI
= inc_word(M
.x86
.R_DI
);
3804 DECODE_CLEAR_SEGOVR();
3808 /****************************************************************************
3811 ****************************************************************************/
3813 x86emuOp_dec_AX(u8
X86EMU_UNUSED(op1
))
3816 if (M
.x86
.mode
& SYSMODE_PREFIX_DATA
) {
3817 DECODE_PRINTF("DEC\tEAX\n");
3820 DECODE_PRINTF("DEC\tAX\n");
3823 if (M
.x86
.mode
& SYSMODE_PREFIX_DATA
) {
3824 M
.x86
.R_EAX
= dec_long(M
.x86
.R_EAX
);
3827 M
.x86
.R_AX
= dec_word(M
.x86
.R_AX
);
3829 DECODE_CLEAR_SEGOVR();
3833 /****************************************************************************
3836 ****************************************************************************/
3838 x86emuOp_dec_CX(u8
X86EMU_UNUSED(op1
))
3841 if (M
.x86
.mode
& SYSMODE_PREFIX_DATA
) {
3842 DECODE_PRINTF("DEC\tECX\n");
3845 DECODE_PRINTF("DEC\tCX\n");
3848 if (M
.x86
.mode
& SYSMODE_PREFIX_DATA
) {
3849 M
.x86
.R_ECX
= dec_long(M
.x86
.R_ECX
);
3852 M
.x86
.R_CX
= dec_word(M
.x86
.R_CX
);
3854 DECODE_CLEAR_SEGOVR();
3858 /****************************************************************************
3861 ****************************************************************************/
3863 x86emuOp_dec_DX(u8
X86EMU_UNUSED(op1
))
3866 if (M
.x86
.mode
& SYSMODE_PREFIX_DATA
) {
3867 DECODE_PRINTF("DEC\tEDX\n");
3870 DECODE_PRINTF("DEC\tDX\n");
3873 if (M
.x86
.mode
& SYSMODE_PREFIX_DATA
) {
3874 M
.x86
.R_EDX
= dec_long(M
.x86
.R_EDX
);
3877 M
.x86
.R_DX
= dec_word(M
.x86
.R_DX
);
3879 DECODE_CLEAR_SEGOVR();
3883 /****************************************************************************
3886 ****************************************************************************/
3888 x86emuOp_dec_BX(u8
X86EMU_UNUSED(op1
))
3891 if (M
.x86
.mode
& SYSMODE_PREFIX_DATA
) {
3892 DECODE_PRINTF("DEC\tEBX\n");
3895 DECODE_PRINTF("DEC\tBX\n");
3898 if (M
.x86
.mode
& SYSMODE_PREFIX_DATA
) {
3899 M
.x86
.R_EBX
= dec_long(M
.x86
.R_EBX
);
3902 M
.x86
.R_BX
= dec_word(M
.x86
.R_BX
);
3904 DECODE_CLEAR_SEGOVR();
3908 /****************************************************************************
3911 ****************************************************************************/
3913 x86emuOp_dec_SP(u8
X86EMU_UNUSED(op1
))
3916 if (M
.x86
.mode
& SYSMODE_PREFIX_DATA
) {
3917 DECODE_PRINTF("DEC\tESP\n");
3920 DECODE_PRINTF("DEC\tSP\n");
3923 if (M
.x86
.mode
& SYSMODE_PREFIX_DATA
) {
3924 M
.x86
.R_ESP
= dec_long(M
.x86
.R_ESP
);
3927 M
.x86
.R_SP
= dec_word(M
.x86
.R_SP
);
3929 DECODE_CLEAR_SEGOVR();
3933 /****************************************************************************
3936 ****************************************************************************/
3938 x86emuOp_dec_BP(u8
X86EMU_UNUSED(op1
))
3941 if (M
.x86
.mode
& SYSMODE_PREFIX_DATA
) {
3942 DECODE_PRINTF("DEC\tEBP\n");
3945 DECODE_PRINTF("DEC\tBP\n");
3948 if (M
.x86
.mode
& SYSMODE_PREFIX_DATA
) {
3949 M
.x86
.R_EBP
= dec_long(M
.x86
.R_EBP
);
3952 M
.x86
.R_BP
= dec_word(M
.x86
.R_BP
);
3954 DECODE_CLEAR_SEGOVR();
3958 /****************************************************************************
3961 ****************************************************************************/
3963 x86emuOp_dec_SI(u8
X86EMU_UNUSED(op1
))
3966 if (M
.x86
.mode
& SYSMODE_PREFIX_DATA
) {
3967 DECODE_PRINTF("DEC\tESI\n");
3970 DECODE_PRINTF("DEC\tSI\n");
3973 if (M
.x86
.mode
& SYSMODE_PREFIX_DATA
) {
3974 M
.x86
.R_ESI
= dec_long(M
.x86
.R_ESI
);
3977 M
.x86
.R_SI
= dec_word(M
.x86
.R_SI
);
3979 DECODE_CLEAR_SEGOVR();
3983 /****************************************************************************
3986 ****************************************************************************/
3988 x86emuOp_dec_DI(u8
X86EMU_UNUSED(op1
))
3991 if (M
.x86
.mode
& SYSMODE_PREFIX_DATA
) {
3992 DECODE_PRINTF("DEC\tEDI\n");
3995 DECODE_PRINTF("DEC\tDI\n");
3998 if (M
.x86
.mode
& SYSMODE_PREFIX_DATA
) {
3999 M
.x86
.R_EDI
= dec_long(M
.x86
.R_EDI
);
4002 M
.x86
.R_DI
= dec_word(M
.x86
.R_DI
);
4004 DECODE_CLEAR_SEGOVR();
4008 /****************************************************************************
4011 ****************************************************************************/
4013 x86emuOp_push_AX(u8
X86EMU_UNUSED(op1
))
4016 if (M
.x86
.mode
& SYSMODE_PREFIX_DATA
) {
4017 DECODE_PRINTF("PUSH\tEAX\n");
4020 DECODE_PRINTF("PUSH\tAX\n");
4023 if (M
.x86
.mode
& SYSMODE_PREFIX_DATA
) {
4024 push_long(M
.x86
.R_EAX
);
4027 push_word(M
.x86
.R_AX
);
4029 DECODE_CLEAR_SEGOVR();
4033 /****************************************************************************
4036 ****************************************************************************/
4038 x86emuOp_push_CX(u8
X86EMU_UNUSED(op1
))
4041 if (M
.x86
.mode
& SYSMODE_PREFIX_DATA
) {
4042 DECODE_PRINTF("PUSH\tECX\n");
4045 DECODE_PRINTF("PUSH\tCX\n");
4048 if (M
.x86
.mode
& SYSMODE_PREFIX_DATA
) {
4049 push_long(M
.x86
.R_ECX
);
4052 push_word(M
.x86
.R_CX
);
4054 DECODE_CLEAR_SEGOVR();
4058 /****************************************************************************
4061 ****************************************************************************/
4063 x86emuOp_push_DX(u8
X86EMU_UNUSED(op1
))
4066 if (M
.x86
.mode
& SYSMODE_PREFIX_DATA
) {
4067 DECODE_PRINTF("PUSH\tEDX\n");
4070 DECODE_PRINTF("PUSH\tDX\n");
4073 if (M
.x86
.mode
& SYSMODE_PREFIX_DATA
) {
4074 push_long(M
.x86
.R_EDX
);
4077 push_word(M
.x86
.R_DX
);
4079 DECODE_CLEAR_SEGOVR();
4083 /****************************************************************************
4086 ****************************************************************************/
4088 x86emuOp_push_BX(u8
X86EMU_UNUSED(op1
))
4091 if (M
.x86
.mode
& SYSMODE_PREFIX_DATA
) {
4092 DECODE_PRINTF("PUSH\tEBX\n");
4095 DECODE_PRINTF("PUSH\tBX\n");
4098 if (M
.x86
.mode
& SYSMODE_PREFIX_DATA
) {
4099 push_long(M
.x86
.R_EBX
);
4102 push_word(M
.x86
.R_BX
);
4104 DECODE_CLEAR_SEGOVR();
4108 /****************************************************************************
4111 ****************************************************************************/
4113 x86emuOp_push_SP(u8
X86EMU_UNUSED(op1
))
4116 if (M
.x86
.mode
& SYSMODE_PREFIX_DATA
) {
4117 DECODE_PRINTF("PUSH\tESP\n");
4120 DECODE_PRINTF("PUSH\tSP\n");
4123 /* Always push (E)SP, since we are emulating an i386 and above
4124 * processor. This is necessary as some BIOS'es use this to check
4125 * what type of processor is in the system.
4127 if (M
.x86
.mode
& SYSMODE_PREFIX_DATA
) {
4128 push_long(M
.x86
.R_ESP
);
4131 push_word((u16
) (M
.x86
.R_SP
));
4133 DECODE_CLEAR_SEGOVR();
4137 /****************************************************************************
4140 ****************************************************************************/
4142 x86emuOp_push_BP(u8
X86EMU_UNUSED(op1
))
4145 if (M
.x86
.mode
& SYSMODE_PREFIX_DATA
) {
4146 DECODE_PRINTF("PUSH\tEBP\n");
4149 DECODE_PRINTF("PUSH\tBP\n");
4152 if (M
.x86
.mode
& SYSMODE_PREFIX_DATA
) {
4153 push_long(M
.x86
.R_EBP
);
4156 push_word(M
.x86
.R_BP
);
4158 DECODE_CLEAR_SEGOVR();
4162 /****************************************************************************
4165 ****************************************************************************/
4167 x86emuOp_push_SI(u8
X86EMU_UNUSED(op1
))
4170 if (M
.x86
.mode
& SYSMODE_PREFIX_DATA
) {
4171 DECODE_PRINTF("PUSH\tESI\n");
4174 DECODE_PRINTF("PUSH\tSI\n");
4177 if (M
.x86
.mode
& SYSMODE_PREFIX_DATA
) {
4178 push_long(M
.x86
.R_ESI
);
4181 push_word(M
.x86
.R_SI
);
4183 DECODE_CLEAR_SEGOVR();
4187 /****************************************************************************
4190 ****************************************************************************/
4192 x86emuOp_push_DI(u8
X86EMU_UNUSED(op1
))
4195 if (M
.x86
.mode
& SYSMODE_PREFIX_DATA
) {
4196 DECODE_PRINTF("PUSH\tEDI\n");
4199 DECODE_PRINTF("PUSH\tDI\n");
4202 if (M
.x86
.mode
& SYSMODE_PREFIX_DATA
) {
4203 push_long(M
.x86
.R_EDI
);
4206 push_word(M
.x86
.R_DI
);
4208 DECODE_CLEAR_SEGOVR();
4212 /****************************************************************************
4215 ****************************************************************************/
4217 x86emuOp_pop_AX(u8
X86EMU_UNUSED(op1
))
4220 if (M
.x86
.mode
& SYSMODE_PREFIX_DATA
) {
4221 DECODE_PRINTF("POP\tEAX\n");
4224 DECODE_PRINTF("POP\tAX\n");
4227 if (M
.x86
.mode
& SYSMODE_PREFIX_DATA
) {
4228 M
.x86
.R_EAX
= pop_long();
4231 M
.x86
.R_AX
= pop_word();
4233 DECODE_CLEAR_SEGOVR();
4237 /****************************************************************************
4240 ****************************************************************************/
4242 x86emuOp_pop_CX(u8
X86EMU_UNUSED(op1
))
4245 if (M
.x86
.mode
& SYSMODE_PREFIX_DATA
) {
4246 DECODE_PRINTF("POP\tECX\n");
4249 DECODE_PRINTF("POP\tCX\n");
4252 if (M
.x86
.mode
& SYSMODE_PREFIX_DATA
) {
4253 M
.x86
.R_ECX
= pop_long();
4256 M
.x86
.R_CX
= pop_word();
4258 DECODE_CLEAR_SEGOVR();
4262 /****************************************************************************
4265 ****************************************************************************/
4267 x86emuOp_pop_DX(u8
X86EMU_UNUSED(op1
))
4270 if (M
.x86
.mode
& SYSMODE_PREFIX_DATA
) {
4271 DECODE_PRINTF("POP\tEDX\n");
4274 DECODE_PRINTF("POP\tDX\n");
4277 if (M
.x86
.mode
& SYSMODE_PREFIX_DATA
) {
4278 M
.x86
.R_EDX
= pop_long();
4281 M
.x86
.R_DX
= pop_word();
4283 DECODE_CLEAR_SEGOVR();
4287 /****************************************************************************
4290 ****************************************************************************/
4292 x86emuOp_pop_BX(u8
X86EMU_UNUSED(op1
))
4295 if (M
.x86
.mode
& SYSMODE_PREFIX_DATA
) {
4296 DECODE_PRINTF("POP\tEBX\n");
4299 DECODE_PRINTF("POP\tBX\n");
4302 if (M
.x86
.mode
& SYSMODE_PREFIX_DATA
) {
4303 M
.x86
.R_EBX
= pop_long();
4306 M
.x86
.R_BX
= pop_word();
4308 DECODE_CLEAR_SEGOVR();
4312 /****************************************************************************
4315 ****************************************************************************/
4317 x86emuOp_pop_SP(u8
X86EMU_UNUSED(op1
))
4320 if (M
.x86
.mode
& SYSMODE_PREFIX_DATA
) {
4321 DECODE_PRINTF("POP\tESP\n");
4324 DECODE_PRINTF("POP\tSP\n");
4327 if (M
.x86
.mode
& SYSMODE_PREFIX_DATA
) {
4328 M
.x86
.R_ESP
= pop_long();
4331 M
.x86
.R_SP
= pop_word();
4333 DECODE_CLEAR_SEGOVR();
4337 /****************************************************************************
4340 ****************************************************************************/
4342 x86emuOp_pop_BP(u8
X86EMU_UNUSED(op1
))
4345 if (M
.x86
.mode
& SYSMODE_PREFIX_DATA
) {
4346 DECODE_PRINTF("POP\tEBP\n");
4349 DECODE_PRINTF("POP\tBP\n");
4352 if (M
.x86
.mode
& SYSMODE_PREFIX_DATA
) {
4353 M
.x86
.R_EBP
= pop_long();
4356 M
.x86
.R_BP
= pop_word();
4358 DECODE_CLEAR_SEGOVR();
4362 /****************************************************************************
4365 ****************************************************************************/
4367 x86emuOp_pop_SI(u8
X86EMU_UNUSED(op1
))
4370 if (M
.x86
.mode
& SYSMODE_PREFIX_DATA
) {
4371 DECODE_PRINTF("POP\tESI\n");
4374 DECODE_PRINTF("POP\tSI\n");
4377 if (M
.x86
.mode
& SYSMODE_PREFIX_DATA
) {
4378 M
.x86
.R_ESI
= pop_long();
4381 M
.x86
.R_SI
= pop_word();
4383 DECODE_CLEAR_SEGOVR();
4387 /****************************************************************************
4390 ****************************************************************************/
4392 x86emuOp_pop_DI(u8
X86EMU_UNUSED(op1
))
4395 if (M
.x86
.mode
& SYSMODE_PREFIX_DATA
) {
4396 DECODE_PRINTF("POP\tEDI\n");
4399 DECODE_PRINTF("POP\tDI\n");
4402 if (M
.x86
.mode
& SYSMODE_PREFIX_DATA
) {
4403 M
.x86
.R_EDI
= pop_long();
4406 M
.x86
.R_DI
= pop_word();
4408 DECODE_CLEAR_SEGOVR();
4412 /****************************************************************************
4415 ****************************************************************************/
4417 x86emuOp_push_all(u8
X86EMU_UNUSED(op1
))
4420 if (M
.x86
.mode
& SYSMODE_PREFIX_DATA
) {
4421 DECODE_PRINTF("PUSHAD\n");
4424 DECODE_PRINTF("PUSHA\n");
4427 if (M
.x86
.mode
& SYSMODE_PREFIX_DATA
) {
4428 u32 old_sp
= M
.x86
.R_ESP
;
4430 push_long(M
.x86
.R_EAX
);
4431 push_long(M
.x86
.R_ECX
);
4432 push_long(M
.x86
.R_EDX
);
4433 push_long(M
.x86
.R_EBX
);
4435 push_long(M
.x86
.R_EBP
);
4436 push_long(M
.x86
.R_ESI
);
4437 push_long(M
.x86
.R_EDI
);
4440 u16 old_sp
= M
.x86
.R_SP
;
4442 push_word(M
.x86
.R_AX
);
4443 push_word(M
.x86
.R_CX
);
4444 push_word(M
.x86
.R_DX
);
4445 push_word(M
.x86
.R_BX
);
4447 push_word(M
.x86
.R_BP
);
4448 push_word(M
.x86
.R_SI
);
4449 push_word(M
.x86
.R_DI
);
4451 DECODE_CLEAR_SEGOVR();
4455 /****************************************************************************
4458 ****************************************************************************/
4460 x86emuOp_pop_all(u8
X86EMU_UNUSED(op1
))
4463 if (M
.x86
.mode
& SYSMODE_PREFIX_DATA
) {
4464 DECODE_PRINTF("POPAD\n");
4467 DECODE_PRINTF("POPA\n");
4470 if (M
.x86
.mode
& SYSMODE_PREFIX_DATA
) {
4471 M
.x86
.R_EDI
= pop_long();
4472 M
.x86
.R_ESI
= pop_long();
4473 M
.x86
.R_EBP
= pop_long();
4474 M
.x86
.R_ESP
+= 4; /* skip ESP */
4475 M
.x86
.R_EBX
= pop_long();
4476 M
.x86
.R_EDX
= pop_long();
4477 M
.x86
.R_ECX
= pop_long();
4478 M
.x86
.R_EAX
= pop_long();
4481 M
.x86
.R_DI
= pop_word();
4482 M
.x86
.R_SI
= pop_word();
4483 M
.x86
.R_BP
= pop_word();
4484 M
.x86
.R_SP
+= 2; /* skip SP */
4485 M
.x86
.R_BX
= pop_word();
4486 M
.x86
.R_DX
= pop_word();
4487 M
.x86
.R_CX
= pop_word();
4488 M
.x86
.R_AX
= pop_word();
4490 DECODE_CLEAR_SEGOVR();
4494 /*opcode 0x62 ILLEGAL OP, calls x86emuOp_illegal_op() */
4495 /*opcode 0x63 ILLEGAL OP, calls x86emuOp_illegal_op() */
4497 /****************************************************************************
4500 ****************************************************************************/
4502 x86emuOp_segovr_FS(u8
X86EMU_UNUSED(op1
))
4505 DECODE_PRINTF("FS:\n");
4507 M
.x86
.mode
|= SYSMODE_SEGOVR_FS
;
4509 * note the lack of DECODE_CLEAR_SEGOVR(r) since, here is one of 4
4510 * opcode subroutines we do not want to do this.
4515 /****************************************************************************
4518 ****************************************************************************/
4520 x86emuOp_segovr_GS(u8
X86EMU_UNUSED(op1
))
4523 DECODE_PRINTF("GS:\n");
4525 M
.x86
.mode
|= SYSMODE_SEGOVR_GS
;
4527 * note the lack of DECODE_CLEAR_SEGOVR(r) since, here is one of 4
4528 * opcode subroutines we do not want to do this.
4533 /****************************************************************************
4535 Handles opcode 0x66 - prefix for 32-bit register
4536 ****************************************************************************/
4538 x86emuOp_prefix_data(u8
X86EMU_UNUSED(op1
))
4541 DECODE_PRINTF("DATA:\n");
4543 M
.x86
.mode
|= SYSMODE_PREFIX_DATA
;
4544 /* note no DECODE_CLEAR_SEGOVR here. */
4548 /****************************************************************************
4550 Handles opcode 0x67 - prefix for 32-bit address
4551 ****************************************************************************/
4553 x86emuOp_prefix_addr(u8
X86EMU_UNUSED(op1
))
4556 DECODE_PRINTF("ADDR:\n");
4558 M
.x86
.mode
|= SYSMODE_PREFIX_ADDR
;
4559 /* note no DECODE_CLEAR_SEGOVR here. */
4563 /****************************************************************************
4566 ****************************************************************************/
4568 x86emuOp_push_word_IMM(u8
X86EMU_UNUSED(op1
))
4573 if (M
.x86
.mode
& SYSMODE_PREFIX_DATA
) {
4574 imm
= fetch_long_imm();
4577 imm
= fetch_word_imm();
4579 DECODE_PRINTF2("PUSH\t%x\n", imm
);
4581 if (M
.x86
.mode
& SYSMODE_PREFIX_DATA
) {
4585 push_word((u16
) imm
);
4587 DECODE_CLEAR_SEGOVR();
4591 /****************************************************************************
4594 ****************************************************************************/
4596 x86emuOp_imul_word_IMM(u8
X86EMU_UNUSED(op1
))
4602 DECODE_PRINTF("IMUL\t");
4603 FETCH_DECODE_MODRM(mod
, rh
, rl
);
4606 if (M
.x86
.mode
& SYSMODE_PREFIX_DATA
) {
4612 destreg
= DECODE_RM_LONG_REGISTER(rh
);
4614 srcoffset
= decode_rm00_address(rl
);
4615 srcval
= fetch_data_long(srcoffset
);
4616 imm
= fetch_long_imm();
4617 DECODE_PRINTF2(",%d\n", (s32
) imm
);
4619 imul_long_direct(&res_lo
, &res_hi
, (s32
) srcval
, (s32
) imm
);
4628 *destreg
= (u32
) res_lo
;
4636 destreg
= DECODE_RM_WORD_REGISTER(rh
);
4638 srcoffset
= decode_rm00_address(rl
);
4639 srcval
= fetch_data_word(srcoffset
);
4640 imm
= fetch_word_imm();
4641 DECODE_PRINTF2(",%d\n", (s32
) imm
);
4643 res
= (s16
) srcval
*(s16
) imm
;
4653 *destreg
= (u16
) res
;
4657 if (M
.x86
.mode
& SYSMODE_PREFIX_DATA
) {
4663 destreg
= DECODE_RM_LONG_REGISTER(rh
);
4665 srcoffset
= decode_rm01_address(rl
);
4666 srcval
= fetch_data_long(srcoffset
);
4667 imm
= fetch_long_imm();
4668 DECODE_PRINTF2(",%d\n", (s32
) imm
);
4670 imul_long_direct(&res_lo
, &res_hi
, (s32
) srcval
, (s32
) imm
);
4679 *destreg
= (u32
) res_lo
;
4687 destreg
= DECODE_RM_WORD_REGISTER(rh
);
4689 srcoffset
= decode_rm01_address(rl
);
4690 srcval
= fetch_data_word(srcoffset
);
4691 imm
= fetch_word_imm();
4692 DECODE_PRINTF2(",%d\n", (s32
) imm
);
4694 res
= (s16
) srcval
*(s16
) imm
;
4704 *destreg
= (u16
) res
;
4708 if (M
.x86
.mode
& SYSMODE_PREFIX_DATA
) {
4714 destreg
= DECODE_RM_LONG_REGISTER(rh
);
4716 srcoffset
= decode_rm10_address(rl
);
4717 srcval
= fetch_data_long(srcoffset
);
4718 imm
= fetch_long_imm();
4719 DECODE_PRINTF2(",%d\n", (s32
) imm
);
4721 imul_long_direct(&res_lo
, &res_hi
, (s32
) srcval
, (s32
) imm
);
4730 *destreg
= (u32
) res_lo
;
4738 destreg
= DECODE_RM_WORD_REGISTER(rh
);
4740 srcoffset
= decode_rm10_address(rl
);
4741 srcval
= fetch_data_word(srcoffset
);
4742 imm
= fetch_word_imm();
4743 DECODE_PRINTF2(",%d\n", (s32
) imm
);
4745 res
= (s16
) srcval
*(s16
) imm
;
4755 *destreg
= (u16
) res
;
4758 case 3: /* register to register */
4759 if (M
.x86
.mode
& SYSMODE_PREFIX_DATA
) {
4760 u32
*destreg
, *srcreg
;
4764 destreg
= DECODE_RM_LONG_REGISTER(rh
);
4766 srcreg
= DECODE_RM_LONG_REGISTER(rl
);
4767 imm
= fetch_long_imm();
4768 DECODE_PRINTF2(",%d\n", (s32
) imm
);
4770 imul_long_direct(&res_lo
, &res_hi
, (s32
) * srcreg
, (s32
) imm
);
4779 *destreg
= (u32
) res_lo
;
4782 u16
*destreg
, *srcreg
;
4786 destreg
= DECODE_RM_WORD_REGISTER(rh
);
4788 srcreg
= DECODE_RM_WORD_REGISTER(rl
);
4789 imm
= fetch_word_imm();
4790 DECODE_PRINTF2(",%d\n", (s32
) imm
);
4791 res
= (s16
) * srcreg
* (s16
) imm
;
4800 *destreg
= (u16
) res
;
4804 DECODE_CLEAR_SEGOVR();
4808 /****************************************************************************
4811 ****************************************************************************/
4813 x86emuOp_push_byte_IMM(u8
X86EMU_UNUSED(op1
))
4818 imm
= (s8
) fetch_byte_imm();
4819 DECODE_PRINTF2("PUSH\t%d\n", imm
);
4821 if (M
.x86
.mode
& SYSMODE_PREFIX_DATA
) {
4822 push_long((s32
) imm
);
4827 DECODE_CLEAR_SEGOVR();
4831 /****************************************************************************
4834 ****************************************************************************/
4836 x86emuOp_imul_byte_IMM(u8
X86EMU_UNUSED(op1
))
4843 DECODE_PRINTF("IMUL\t");
4844 FETCH_DECODE_MODRM(mod
, rh
, rl
);
4847 if (M
.x86
.mode
& SYSMODE_PREFIX_DATA
) {
4852 destreg
= DECODE_RM_LONG_REGISTER(rh
);
4854 srcoffset
= decode_rm00_address(rl
);
4855 srcval
= fetch_data_long(srcoffset
);
4856 imm
= fetch_byte_imm();
4857 DECODE_PRINTF2(",%d\n", (s32
) imm
);
4859 imul_long_direct(&res_lo
, &res_hi
, (s32
) srcval
, (s32
) imm
);
4868 *destreg
= (u32
) res_lo
;
4875 destreg
= DECODE_RM_WORD_REGISTER(rh
);
4877 srcoffset
= decode_rm00_address(rl
);
4878 srcval
= fetch_data_word(srcoffset
);
4879 imm
= fetch_byte_imm();
4880 DECODE_PRINTF2(",%d\n", (s32
) imm
);
4882 res
= (s16
) srcval
*(s16
) imm
;
4892 *destreg
= (u16
) res
;
4896 if (M
.x86
.mode
& SYSMODE_PREFIX_DATA
) {
4901 destreg
= DECODE_RM_LONG_REGISTER(rh
);
4903 srcoffset
= decode_rm01_address(rl
);
4904 srcval
= fetch_data_long(srcoffset
);
4905 imm
= fetch_byte_imm();
4906 DECODE_PRINTF2(",%d\n", (s32
) imm
);
4908 imul_long_direct(&res_lo
, &res_hi
, (s32
) srcval
, (s32
) imm
);
4917 *destreg
= (u32
) res_lo
;
4924 destreg
= DECODE_RM_WORD_REGISTER(rh
);
4926 srcoffset
= decode_rm01_address(rl
);
4927 srcval
= fetch_data_word(srcoffset
);
4928 imm
= fetch_byte_imm();
4929 DECODE_PRINTF2(",%d\n", (s32
) imm
);
4931 res
= (s16
) srcval
*(s16
) imm
;
4941 *destreg
= (u16
) res
;
4945 if (M
.x86
.mode
& SYSMODE_PREFIX_DATA
) {
4950 destreg
= DECODE_RM_LONG_REGISTER(rh
);
4952 srcoffset
= decode_rm10_address(rl
);
4953 srcval
= fetch_data_long(srcoffset
);
4954 imm
= fetch_byte_imm();
4955 DECODE_PRINTF2(",%d\n", (s32
) imm
);
4957 imul_long_direct(&res_lo
, &res_hi
, (s32
) srcval
, (s32
) imm
);
4966 *destreg
= (u32
) res_lo
;
4973 destreg
= DECODE_RM_WORD_REGISTER(rh
);
4975 srcoffset
= decode_rm10_address(rl
);
4976 srcval
= fetch_data_word(srcoffset
);
4977 imm
= fetch_byte_imm();
4978 DECODE_PRINTF2(",%d\n", (s32
) imm
);
4980 res
= (s16
) srcval
*(s16
) imm
;
4990 *destreg
= (u16
) res
;
4993 case 3: /* register to register */
4994 if (M
.x86
.mode
& SYSMODE_PREFIX_DATA
) {
4995 u32
*destreg
, *srcreg
;
4998 destreg
= DECODE_RM_LONG_REGISTER(rh
);
5000 srcreg
= DECODE_RM_LONG_REGISTER(rl
);
5001 imm
= fetch_byte_imm();
5002 DECODE_PRINTF2(",%d\n", (s32
) imm
);
5004 imul_long_direct(&res_lo
, &res_hi
, (s32
) * srcreg
, (s32
) imm
);
5013 *destreg
= (u32
) res_lo
;
5016 u16
*destreg
, *srcreg
;
5019 destreg
= DECODE_RM_WORD_REGISTER(rh
);
5021 srcreg
= DECODE_RM_WORD_REGISTER(rl
);
5022 imm
= fetch_byte_imm();
5023 DECODE_PRINTF2(",%d\n", (s32
) imm
);
5024 res
= (s16
) * srcreg
* (s16
) imm
;
5033 *destreg
= (u16
) res
;
5037 DECODE_CLEAR_SEGOVR();
5041 /****************************************************************************
5044 ****************************************************************************/
5046 x86emuOp_ins_byte(u8
X86EMU_UNUSED(op1
))
5049 DECODE_PRINTF("INSB\n");
5052 DECODE_CLEAR_SEGOVR();
5056 /****************************************************************************
5059 ****************************************************************************/
5061 x86emuOp_ins_word(u8
X86EMU_UNUSED(op1
))
5064 if (M
.x86
.mode
& SYSMODE_PREFIX_DATA
) {
5065 DECODE_PRINTF("INSD\n");
5069 DECODE_PRINTF("INSW\n");
5073 DECODE_CLEAR_SEGOVR();
5077 /****************************************************************************
5080 ****************************************************************************/
5082 x86emuOp_outs_byte(u8
X86EMU_UNUSED(op1
))
5085 DECODE_PRINTF("OUTSB\n");
5088 DECODE_CLEAR_SEGOVR();
5092 /****************************************************************************
5095 ****************************************************************************/
5097 x86emuOp_outs_word(u8
X86EMU_UNUSED(op1
))
5100 if (M
.x86
.mode
& SYSMODE_PREFIX_DATA
) {
5101 DECODE_PRINTF("OUTSD\n");
5105 DECODE_PRINTF("OUTSW\n");
5109 DECODE_CLEAR_SEGOVR();
5113 /****************************************************************************
5116 ****************************************************************************/
5118 x86emuOp_jump_near_O(u8
X86EMU_UNUSED(op1
))
5123 /* jump to byte offset if overflow flag is set */
5125 DECODE_PRINTF("JO\t");
5126 offset
= (s8
) fetch_byte_imm();
5127 target
= (u16
) (M
.x86
.R_IP
+ (s16
) offset
);
5128 DECODE_PRINTF2("%x\n", target
);
5130 if (ACCESS_FLAG(F_OF
))
5131 M
.x86
.R_IP
= target
;
5132 DECODE_CLEAR_SEGOVR();
5136 /****************************************************************************
5139 ****************************************************************************/
5141 x86emuOp_jump_near_NO(u8
X86EMU_UNUSED(op1
))
5146 /* jump to byte offset if overflow is not set */
5148 DECODE_PRINTF("JNO\t");
5149 offset
= (s8
) fetch_byte_imm();
5150 target
= (u16
) (M
.x86
.R_IP
+ (s16
) offset
);
5151 DECODE_PRINTF2("%x\n", target
);
5153 if (!ACCESS_FLAG(F_OF
))
5154 M
.x86
.R_IP
= target
;
5155 DECODE_CLEAR_SEGOVR();
5159 /****************************************************************************
5162 ****************************************************************************/
5164 x86emuOp_jump_near_B(u8
X86EMU_UNUSED(op1
))
5169 /* jump to byte offset if carry flag is set. */
5171 DECODE_PRINTF("JB\t");
5172 offset
= (s8
) fetch_byte_imm();
5173 target
= (u16
) (M
.x86
.R_IP
+ (s16
) offset
);
5174 DECODE_PRINTF2("%x\n", target
);
5176 if (ACCESS_FLAG(F_CF
))
5177 M
.x86
.R_IP
= target
;
5178 DECODE_CLEAR_SEGOVR();
5182 /****************************************************************************
5185 ****************************************************************************/
5187 x86emuOp_jump_near_NB(u8
X86EMU_UNUSED(op1
))
5192 /* jump to byte offset if carry flag is clear. */
5194 DECODE_PRINTF("JNB\t");
5195 offset
= (s8
) fetch_byte_imm();
5196 target
= (u16
) (M
.x86
.R_IP
+ (s16
) offset
);
5197 DECODE_PRINTF2("%x\n", target
);
5199 if (!ACCESS_FLAG(F_CF
))
5200 M
.x86
.R_IP
= target
;
5201 DECODE_CLEAR_SEGOVR();
5205 /****************************************************************************
5208 ****************************************************************************/
5210 x86emuOp_jump_near_Z(u8
X86EMU_UNUSED(op1
))
5215 /* jump to byte offset if zero flag is set. */
5217 DECODE_PRINTF("JZ\t");
5218 offset
= (s8
) fetch_byte_imm();
5219 target
= (u16
) (M
.x86
.R_IP
+ (s16
) offset
);
5220 DECODE_PRINTF2("%x\n", target
);
5222 if (ACCESS_FLAG(F_ZF
))
5223 M
.x86
.R_IP
= target
;
5224 DECODE_CLEAR_SEGOVR();
5228 /****************************************************************************
5231 ****************************************************************************/
5233 x86emuOp_jump_near_NZ(u8
X86EMU_UNUSED(op1
))
5238 /* jump to byte offset if zero flag is clear. */
5240 DECODE_PRINTF("JNZ\t");
5241 offset
= (s8
) fetch_byte_imm();
5242 target
= (u16
) (M
.x86
.R_IP
+ (s16
) offset
);
5243 DECODE_PRINTF2("%x\n", target
);
5245 if (!ACCESS_FLAG(F_ZF
))
5246 M
.x86
.R_IP
= target
;
5247 DECODE_CLEAR_SEGOVR();
5251 /****************************************************************************
5254 ****************************************************************************/
5256 x86emuOp_jump_near_BE(u8
X86EMU_UNUSED(op1
))
5261 /* jump to byte offset if carry flag is set or if the zero
5264 DECODE_PRINTF("JBE\t");
5265 offset
= (s8
) fetch_byte_imm();
5266 target
= (u16
) (M
.x86
.R_IP
+ (s16
) offset
);
5267 DECODE_PRINTF2("%x\n", target
);
5269 if (ACCESS_FLAG(F_CF
) || ACCESS_FLAG(F_ZF
))
5270 M
.x86
.R_IP
= target
;
5271 DECODE_CLEAR_SEGOVR();
5275 /****************************************************************************
5278 ****************************************************************************/
5280 x86emuOp_jump_near_NBE(u8
X86EMU_UNUSED(op1
))
5285 /* jump to byte offset if carry flag is clear and if the zero
5288 DECODE_PRINTF("JNBE\t");
5289 offset
= (s8
) fetch_byte_imm();
5290 target
= (u16
) (M
.x86
.R_IP
+ (s16
) offset
);
5291 DECODE_PRINTF2("%x\n", target
);
5293 if (!(ACCESS_FLAG(F_CF
) || ACCESS_FLAG(F_ZF
)))
5294 M
.x86
.R_IP
= target
;
5295 DECODE_CLEAR_SEGOVR();
5299 /****************************************************************************
5302 ****************************************************************************/
5304 x86emuOp_jump_near_S(u8
X86EMU_UNUSED(op1
))
5309 /* jump to byte offset if sign flag is set */
5311 DECODE_PRINTF("JS\t");
5312 offset
= (s8
) fetch_byte_imm();
5313 target
= (u16
) (M
.x86
.R_IP
+ (s16
) offset
);
5314 DECODE_PRINTF2("%x\n", target
);
5316 if (ACCESS_FLAG(F_SF
))
5317 M
.x86
.R_IP
= target
;
5318 DECODE_CLEAR_SEGOVR();
5322 /****************************************************************************
5325 ****************************************************************************/
5327 x86emuOp_jump_near_NS(u8
X86EMU_UNUSED(op1
))
5332 /* jump to byte offset if sign flag is clear */
5334 DECODE_PRINTF("JNS\t");
5335 offset
= (s8
) fetch_byte_imm();
5336 target
= (u16
) (M
.x86
.R_IP
+ (s16
) offset
);
5337 DECODE_PRINTF2("%x\n", target
);
5339 if (!ACCESS_FLAG(F_SF
))
5340 M
.x86
.R_IP
= target
;
5341 DECODE_CLEAR_SEGOVR();
5345 /****************************************************************************
5348 ****************************************************************************/
5350 x86emuOp_jump_near_P(u8
X86EMU_UNUSED(op1
))
5355 /* jump to byte offset if parity flag is set (even parity) */
5357 DECODE_PRINTF("JP\t");
5358 offset
= (s8
) fetch_byte_imm();
5359 target
= (u16
) (M
.x86
.R_IP
+ (s16
) offset
);
5360 DECODE_PRINTF2("%x\n", target
);
5362 if (ACCESS_FLAG(F_PF
))
5363 M
.x86
.R_IP
= target
;
5364 DECODE_CLEAR_SEGOVR();
5368 /****************************************************************************
5371 ****************************************************************************/
5373 x86emuOp_jump_near_NP(u8
X86EMU_UNUSED(op1
))
5378 /* jump to byte offset if parity flag is clear (odd parity) */
5380 DECODE_PRINTF("JNP\t");
5381 offset
= (s8
) fetch_byte_imm();
5382 target
= (u16
) (M
.x86
.R_IP
+ (s16
) offset
);
5383 DECODE_PRINTF2("%x\n", target
);
5385 if (!ACCESS_FLAG(F_PF
))
5386 M
.x86
.R_IP
= target
;
5387 DECODE_CLEAR_SEGOVR();
5391 /****************************************************************************
5394 ****************************************************************************/
5396 x86emuOp_jump_near_L(u8
X86EMU_UNUSED(op1
))
5402 /* jump to byte offset if sign flag not equal to overflow flag. */
5404 DECODE_PRINTF("JL\t");
5405 offset
= (s8
) fetch_byte_imm();
5406 target
= (u16
) (M
.x86
.R_IP
+ (s16
) offset
);
5407 DECODE_PRINTF2("%x\n", target
);
5409 sf
= ACCESS_FLAG(F_SF
) != 0;
5410 of
= ACCESS_FLAG(F_OF
) != 0;
5412 M
.x86
.R_IP
= target
;
5413 DECODE_CLEAR_SEGOVR();
5417 /****************************************************************************
5420 ****************************************************************************/
5422 x86emuOp_jump_near_NL(u8
X86EMU_UNUSED(op1
))
5428 /* jump to byte offset if sign flag not equal to overflow flag. */
5430 DECODE_PRINTF("JNL\t");
5431 offset
= (s8
) fetch_byte_imm();
5432 target
= (u16
) (M
.x86
.R_IP
+ (s16
) offset
);
5433 DECODE_PRINTF2("%x\n", target
);
5435 sf
= ACCESS_FLAG(F_SF
) != 0;
5436 of
= ACCESS_FLAG(F_OF
) != 0;
5437 /* note: inverse of above, but using == instead of xor. */
5439 M
.x86
.R_IP
= target
;
5440 DECODE_CLEAR_SEGOVR();
5444 /****************************************************************************
5447 ****************************************************************************/
5449 x86emuOp_jump_near_LE(u8
X86EMU_UNUSED(op1
))
5455 /* jump to byte offset if sign flag not equal to overflow flag
5456 or the zero flag is set */
5458 DECODE_PRINTF("JLE\t");
5459 offset
= (s8
) fetch_byte_imm();
5460 target
= (u16
) (M
.x86
.R_IP
+ (s16
) offset
);
5461 DECODE_PRINTF2("%x\n", target
);
5463 sf
= ACCESS_FLAG(F_SF
) != 0;
5464 of
= ACCESS_FLAG(F_OF
) != 0;
5465 if ((sf
^ of
) || ACCESS_FLAG(F_ZF
))
5466 M
.x86
.R_IP
= target
;
5467 DECODE_CLEAR_SEGOVR();
5471 /****************************************************************************
5474 ****************************************************************************/
5476 x86emuOp_jump_near_NLE(u8
X86EMU_UNUSED(op1
))
5482 /* jump to byte offset if sign flag equal to overflow flag.
5483 and the zero flag is clear */
5485 DECODE_PRINTF("JNLE\t");
5486 offset
= (s8
) fetch_byte_imm();
5487 target
= (u16
) (M
.x86
.R_IP
+ (s16
) offset
);
5488 DECODE_PRINTF2("%x\n", target
);
5490 sf
= ACCESS_FLAG(F_SF
) != 0;
5491 of
= ACCESS_FLAG(F_OF
) != 0;
5492 if ((sf
== of
) && !ACCESS_FLAG(F_ZF
))
5493 M
.x86
.R_IP
= target
;
5494 DECODE_CLEAR_SEGOVR();
5498 static u8(*opc80_byte_operation
[]) (u8 d
, u8 s
) = {
5509 /****************************************************************************
5512 ****************************************************************************/
5514 x86emuOp_opc80_byte_RM_IMM(u8
X86EMU_UNUSED(op1
))
5523 * Weirdo special case instruction format. Part of the opcode
5524 * held below in "RH". Doubly nested case would result, except
5525 * that the decoded instruction
5528 FETCH_DECODE_MODRM(mod
, rh
, rl
);
5530 if (DEBUG_DECODE()) {
5531 /* XXX DECODE_PRINTF may be changed to something more
5532 general, so that it is important to leave the strings
5533 in the same format, even though the result is that the
5534 above test is done twice. */
5538 DECODE_PRINTF("ADD\t");
5541 DECODE_PRINTF("OR\t");
5544 DECODE_PRINTF("ADC\t");
5547 DECODE_PRINTF("SBB\t");
5550 DECODE_PRINTF("AND\t");
5553 DECODE_PRINTF("SUB\t");
5556 DECODE_PRINTF("XOR\t");
5559 DECODE_PRINTF("CMP\t");
5564 /* know operation, decode the mod byte to find the addressing
5568 DECODE_PRINTF("BYTE PTR ");
5569 destoffset
= decode_rm00_address(rl
);
5571 destval
= fetch_data_byte(destoffset
);
5572 imm
= fetch_byte_imm();
5573 DECODE_PRINTF2("%x\n", imm
);
5575 destval
= (*opc80_byte_operation
[rh
]) (destval
, imm
);
5577 store_data_byte(destoffset
, destval
);
5580 DECODE_PRINTF("BYTE PTR ");
5581 destoffset
= decode_rm01_address(rl
);
5583 destval
= fetch_data_byte(destoffset
);
5584 imm
= fetch_byte_imm();
5585 DECODE_PRINTF2("%x\n", imm
);
5587 destval
= (*opc80_byte_operation
[rh
]) (destval
, imm
);
5589 store_data_byte(destoffset
, destval
);
5592 DECODE_PRINTF("BYTE PTR ");
5593 destoffset
= decode_rm10_address(rl
);
5595 destval
= fetch_data_byte(destoffset
);
5596 imm
= fetch_byte_imm();
5597 DECODE_PRINTF2("%x\n", imm
);
5599 destval
= (*opc80_byte_operation
[rh
]) (destval
, imm
);
5601 store_data_byte(destoffset
, destval
);
5603 case 3: /* register to register */
5604 destreg
= DECODE_RM_BYTE_REGISTER(rl
);
5606 imm
= fetch_byte_imm();
5607 DECODE_PRINTF2("%x\n", imm
);
5609 destval
= (*opc80_byte_operation
[rh
]) (*destreg
, imm
);
5614 DECODE_CLEAR_SEGOVR();
5618 static u16(*opc81_word_operation
[]) (u16 d
, u16 s
) = {
5629 static u32(*opc81_long_operation
[]) (u32 d
, u32 s
) = {
5640 /****************************************************************************
5643 ****************************************************************************/
5645 x86emuOp_opc81_word_RM_IMM(u8
X86EMU_UNUSED(op1
))
5651 * Weirdo special case instruction format. Part of the opcode
5652 * held below in "RH". Doubly nested case would result, except
5653 * that the decoded instruction
5656 FETCH_DECODE_MODRM(mod
, rh
, rl
);
5658 if (DEBUG_DECODE()) {
5659 /* XXX DECODE_PRINTF may be changed to something more
5660 general, so that it is important to leave the strings
5661 in the same format, even though the result is that the
5662 above test is done twice. */
5666 DECODE_PRINTF("ADD\t");
5669 DECODE_PRINTF("OR\t");
5672 DECODE_PRINTF("ADC\t");
5675 DECODE_PRINTF("SBB\t");
5678 DECODE_PRINTF("AND\t");
5681 DECODE_PRINTF("SUB\t");
5684 DECODE_PRINTF("XOR\t");
5687 DECODE_PRINTF("CMP\t");
5693 * Know operation, decode the mod byte to find the addressing
5698 if (M
.x86
.mode
& SYSMODE_PREFIX_DATA
) {
5701 DECODE_PRINTF("DWORD PTR ");
5702 destoffset
= decode_rm00_address(rl
);
5704 destval
= fetch_data_long(destoffset
);
5705 imm
= fetch_long_imm();
5706 DECODE_PRINTF2("%x\n", imm
);
5708 destval
= (*opc81_long_operation
[rh
]) (destval
, imm
);
5710 store_data_long(destoffset
, destval
);
5715 DECODE_PRINTF("WORD PTR ");
5716 destoffset
= decode_rm00_address(rl
);
5718 destval
= fetch_data_word(destoffset
);
5719 imm
= fetch_word_imm();
5720 DECODE_PRINTF2("%x\n", imm
);
5722 destval
= (*opc81_word_operation
[rh
]) (destval
, imm
);
5724 store_data_word(destoffset
, destval
);
5728 if (M
.x86
.mode
& SYSMODE_PREFIX_DATA
) {
5731 DECODE_PRINTF("DWORD PTR ");
5732 destoffset
= decode_rm01_address(rl
);
5734 destval
= fetch_data_long(destoffset
);
5735 imm
= fetch_long_imm();
5736 DECODE_PRINTF2("%x\n", imm
);
5738 destval
= (*opc81_long_operation
[rh
]) (destval
, imm
);
5740 store_data_long(destoffset
, destval
);
5745 DECODE_PRINTF("WORD PTR ");
5746 destoffset
= decode_rm01_address(rl
);
5748 destval
= fetch_data_word(destoffset
);
5749 imm
= fetch_word_imm();
5750 DECODE_PRINTF2("%x\n", imm
);
5752 destval
= (*opc81_word_operation
[rh
]) (destval
, imm
);
5754 store_data_word(destoffset
, destval
);
5758 if (M
.x86
.mode
& SYSMODE_PREFIX_DATA
) {
5761 DECODE_PRINTF("DWORD PTR ");
5762 destoffset
= decode_rm10_address(rl
);
5764 destval
= fetch_data_long(destoffset
);
5765 imm
= fetch_long_imm();
5766 DECODE_PRINTF2("%x\n", imm
);
5768 destval
= (*opc81_long_operation
[rh
]) (destval
, imm
);
5770 store_data_long(destoffset
, destval
);
5775 DECODE_PRINTF("WORD PTR ");
5776 destoffset
= decode_rm10_address(rl
);
5778 destval
= fetch_data_word(destoffset
);
5779 imm
= fetch_word_imm();
5780 DECODE_PRINTF2("%x\n", imm
);
5782 destval
= (*opc81_word_operation
[rh
]) (destval
, imm
);
5784 store_data_word(destoffset
, destval
);
5787 case 3: /* register to register */
5788 if (M
.x86
.mode
& SYSMODE_PREFIX_DATA
) {
5792 destreg
= DECODE_RM_LONG_REGISTER(rl
);
5794 imm
= fetch_long_imm();
5795 DECODE_PRINTF2("%x\n", imm
);
5797 destval
= (*opc81_long_operation
[rh
]) (*destreg
, imm
);
5805 destreg
= DECODE_RM_WORD_REGISTER(rl
);
5807 imm
= fetch_word_imm();
5808 DECODE_PRINTF2("%x\n", imm
);
5810 destval
= (*opc81_word_operation
[rh
]) (*destreg
, imm
);
5816 DECODE_CLEAR_SEGOVR();
5820 static u8(*opc82_byte_operation
[]) (u8 s
, u8 d
) = {
5822 or_byte
, /*01 *//*YYY UNUSED ???? */
5825 and_byte
, /*04 *//*YYY UNUSED ???? */
5827 xor_byte
, /*06 *//*YYY UNUSED ???? */
5831 /****************************************************************************
5834 ****************************************************************************/
5836 x86emuOp_opc82_byte_RM_IMM(u8
X86EMU_UNUSED(op1
))
5845 * Weirdo special case instruction format. Part of the opcode
5846 * held below in "RH". Doubly nested case would result, except
5847 * that the decoded instruction Similar to opcode 81, except that
5848 * the immediate byte is sign extended to a word length.
5851 FETCH_DECODE_MODRM(mod
, rh
, rl
);
5853 if (DEBUG_DECODE()) {
5854 /* XXX DECODE_PRINTF may be changed to something more
5855 general, so that it is important to leave the strings
5856 in the same format, even though the result is that the
5857 above test is done twice. */
5860 DECODE_PRINTF("ADD\t");
5863 DECODE_PRINTF("OR\t");
5866 DECODE_PRINTF("ADC\t");
5869 DECODE_PRINTF("SBB\t");
5872 DECODE_PRINTF("AND\t");
5875 DECODE_PRINTF("SUB\t");
5878 DECODE_PRINTF("XOR\t");
5881 DECODE_PRINTF("CMP\t");
5886 /* know operation, decode the mod byte to find the addressing
5890 DECODE_PRINTF("BYTE PTR ");
5891 destoffset
= decode_rm00_address(rl
);
5892 destval
= fetch_data_byte(destoffset
);
5893 imm
= fetch_byte_imm();
5894 DECODE_PRINTF2(",%x\n", imm
);
5896 destval
= (*opc82_byte_operation
[rh
]) (destval
, imm
);
5898 store_data_byte(destoffset
, destval
);
5901 DECODE_PRINTF("BYTE PTR ");
5902 destoffset
= decode_rm01_address(rl
);
5903 destval
= fetch_data_byte(destoffset
);
5904 imm
= fetch_byte_imm();
5905 DECODE_PRINTF2(",%x\n", imm
);
5907 destval
= (*opc82_byte_operation
[rh
]) (destval
, imm
);
5909 store_data_byte(destoffset
, destval
);
5912 DECODE_PRINTF("BYTE PTR ");
5913 destoffset
= decode_rm10_address(rl
);
5914 destval
= fetch_data_byte(destoffset
);
5915 imm
= fetch_byte_imm();
5916 DECODE_PRINTF2(",%x\n", imm
);
5918 destval
= (*opc82_byte_operation
[rh
]) (destval
, imm
);
5920 store_data_byte(destoffset
, destval
);
5922 case 3: /* register to register */
5923 destreg
= DECODE_RM_BYTE_REGISTER(rl
);
5924 imm
= fetch_byte_imm();
5925 DECODE_PRINTF2(",%x\n", imm
);
5927 destval
= (*opc82_byte_operation
[rh
]) (*destreg
, imm
);
5932 DECODE_CLEAR_SEGOVR();
5936 static u16(*opc83_word_operation
[]) (u16 s
, u16 d
) = {
5938 or_word
, /*01 *//*YYY UNUSED ???? */
5941 and_word
, /*04 *//*YYY UNUSED ???? */
5943 xor_word
, /*06 *//*YYY UNUSED ???? */
5947 static u32(*opc83_long_operation
[]) (u32 s
, u32 d
) = {
5949 or_long
, /*01 *//*YYY UNUSED ???? */
5952 and_long
, /*04 *//*YYY UNUSED ???? */
5954 xor_long
, /*06 *//*YYY UNUSED ???? */
5958 /****************************************************************************
5961 ****************************************************************************/
5963 x86emuOp_opc83_word_RM_IMM(u8
X86EMU_UNUSED(op1
))
5969 * Weirdo special case instruction format. Part of the opcode
5970 * held below in "RH". Doubly nested case would result, except
5971 * that the decoded instruction Similar to opcode 81, except that
5972 * the immediate byte is sign extended to a word length.
5975 FETCH_DECODE_MODRM(mod
, rh
, rl
);
5977 if (DEBUG_DECODE()) {
5978 /* XXX DECODE_PRINTF may be changed to something more
5979 general, so that it is important to leave the strings
5980 in the same format, even though the result is that the
5981 above test is done twice. */
5984 DECODE_PRINTF("ADD\t");
5987 DECODE_PRINTF("OR\t");
5990 DECODE_PRINTF("ADC\t");
5993 DECODE_PRINTF("SBB\t");
5996 DECODE_PRINTF("AND\t");
5999 DECODE_PRINTF("SUB\t");
6002 DECODE_PRINTF("XOR\t");
6005 DECODE_PRINTF("CMP\t");
6010 /* know operation, decode the mod byte to find the addressing
6014 if (M
.x86
.mode
& SYSMODE_PREFIX_DATA
) {
6017 DECODE_PRINTF("DWORD PTR ");
6018 destoffset
= decode_rm00_address(rl
);
6019 destval
= fetch_data_long(destoffset
);
6020 imm
= (s8
) fetch_byte_imm();
6021 DECODE_PRINTF2(",%x\n", imm
);
6023 destval
= (*opc83_long_operation
[rh
]) (destval
, imm
);
6025 store_data_long(destoffset
, destval
);
6030 DECODE_PRINTF("WORD PTR ");
6031 destoffset
= decode_rm00_address(rl
);
6032 destval
= fetch_data_word(destoffset
);
6033 imm
= (s8
) fetch_byte_imm();
6034 DECODE_PRINTF2(",%x\n", imm
);
6036 destval
= (*opc83_word_operation
[rh
]) (destval
, imm
);
6038 store_data_word(destoffset
, destval
);
6042 if (M
.x86
.mode
& SYSMODE_PREFIX_DATA
) {
6045 DECODE_PRINTF("DWORD PTR ");
6046 destoffset
= decode_rm01_address(rl
);
6047 destval
= fetch_data_long(destoffset
);
6048 imm
= (s8
) fetch_byte_imm();
6049 DECODE_PRINTF2(",%x\n", imm
);
6051 destval
= (*opc83_long_operation
[rh
]) (destval
, imm
);
6053 store_data_long(destoffset
, destval
);
6058 DECODE_PRINTF("WORD PTR ");
6059 destoffset
= decode_rm01_address(rl
);
6060 destval
= fetch_data_word(destoffset
);
6061 imm
= (s8
) fetch_byte_imm();
6062 DECODE_PRINTF2(",%x\n", imm
);
6064 destval
= (*opc83_word_operation
[rh
]) (destval
, imm
);
6066 store_data_word(destoffset
, destval
);
6070 if (M
.x86
.mode
& SYSMODE_PREFIX_DATA
) {
6073 DECODE_PRINTF("DWORD PTR ");
6074 destoffset
= decode_rm10_address(rl
);
6075 destval
= fetch_data_long(destoffset
);
6076 imm
= (s8
) fetch_byte_imm();
6077 DECODE_PRINTF2(",%x\n", imm
);
6079 destval
= (*opc83_long_operation
[rh
]) (destval
, imm
);
6081 store_data_long(destoffset
, destval
);
6086 DECODE_PRINTF("WORD PTR ");
6087 destoffset
= decode_rm10_address(rl
);
6088 destval
= fetch_data_word(destoffset
);
6089 imm
= (s8
) fetch_byte_imm();
6090 DECODE_PRINTF2(",%x\n", imm
);
6092 destval
= (*opc83_word_operation
[rh
]) (destval
, imm
);
6094 store_data_word(destoffset
, destval
);
6097 case 3: /* register to register */
6098 if (M
.x86
.mode
& SYSMODE_PREFIX_DATA
) {
6102 destreg
= DECODE_RM_LONG_REGISTER(rl
);
6103 imm
= (s8
) fetch_byte_imm();
6104 DECODE_PRINTF2(",%x\n", imm
);
6106 destval
= (*opc83_long_operation
[rh
]) (*destreg
, imm
);
6114 destreg
= DECODE_RM_WORD_REGISTER(rl
);
6115 imm
= (s8
) fetch_byte_imm();
6116 DECODE_PRINTF2(",%x\n", imm
);
6118 destval
= (*opc83_word_operation
[rh
]) (*destreg
, imm
);
6124 DECODE_CLEAR_SEGOVR();
6128 /****************************************************************************
6131 ****************************************************************************/
6133 x86emuOp_test_byte_RM_R(u8
X86EMU_UNUSED(op1
))
6136 u8
*destreg
, *srcreg
;
6141 DECODE_PRINTF("TEST\t");
6142 FETCH_DECODE_MODRM(mod
, rh
, rl
);
6145 destoffset
= decode_rm00_address(rl
);
6147 destval
= fetch_data_byte(destoffset
);
6148 srcreg
= DECODE_RM_BYTE_REGISTER(rh
);
6149 DECODE_PRINTF("\n");
6151 test_byte(destval
, *srcreg
);
6154 destoffset
= decode_rm01_address(rl
);
6156 destval
= fetch_data_byte(destoffset
);
6157 srcreg
= DECODE_RM_BYTE_REGISTER(rh
);
6158 DECODE_PRINTF("\n");
6160 test_byte(destval
, *srcreg
);
6163 destoffset
= decode_rm10_address(rl
);
6165 destval
= fetch_data_byte(destoffset
);
6166 srcreg
= DECODE_RM_BYTE_REGISTER(rh
);
6167 DECODE_PRINTF("\n");
6169 test_byte(destval
, *srcreg
);
6171 case 3: /* register to register */
6172 destreg
= DECODE_RM_BYTE_REGISTER(rl
);
6174 srcreg
= DECODE_RM_BYTE_REGISTER(rh
);
6175 DECODE_PRINTF("\n");
6177 test_byte(*destreg
, *srcreg
);
6180 DECODE_CLEAR_SEGOVR();
6184 /****************************************************************************
6187 ****************************************************************************/
6189 x86emuOp_test_word_RM_R(u8
X86EMU_UNUSED(op1
))
6195 DECODE_PRINTF("TEST\t");
6196 FETCH_DECODE_MODRM(mod
, rh
, rl
);
6199 if (M
.x86
.mode
& SYSMODE_PREFIX_DATA
) {
6203 destoffset
= decode_rm00_address(rl
);
6205 destval
= fetch_data_long(destoffset
);
6206 srcreg
= DECODE_RM_LONG_REGISTER(rh
);
6207 DECODE_PRINTF("\n");
6209 test_long(destval
, *srcreg
);
6215 destoffset
= decode_rm00_address(rl
);
6217 destval
= fetch_data_word(destoffset
);
6218 srcreg
= DECODE_RM_WORD_REGISTER(rh
);
6219 DECODE_PRINTF("\n");
6221 test_word(destval
, *srcreg
);
6225 if (M
.x86
.mode
& SYSMODE_PREFIX_DATA
) {
6229 destoffset
= decode_rm01_address(rl
);
6231 destval
= fetch_data_long(destoffset
);
6232 srcreg
= DECODE_RM_LONG_REGISTER(rh
);
6233 DECODE_PRINTF("\n");
6235 test_long(destval
, *srcreg
);
6241 destoffset
= decode_rm01_address(rl
);
6243 destval
= fetch_data_word(destoffset
);
6244 srcreg
= DECODE_RM_WORD_REGISTER(rh
);
6245 DECODE_PRINTF("\n");
6247 test_word(destval
, *srcreg
);
6251 if (M
.x86
.mode
& SYSMODE_PREFIX_DATA
) {
6255 destoffset
= decode_rm10_address(rl
);
6257 destval
= fetch_data_long(destoffset
);
6258 srcreg
= DECODE_RM_LONG_REGISTER(rh
);
6259 DECODE_PRINTF("\n");
6261 test_long(destval
, *srcreg
);
6267 destoffset
= decode_rm10_address(rl
);
6269 destval
= fetch_data_word(destoffset
);
6270 srcreg
= DECODE_RM_WORD_REGISTER(rh
);
6271 DECODE_PRINTF("\n");
6273 test_word(destval
, *srcreg
);
6276 case 3: /* register to register */
6277 if (M
.x86
.mode
& SYSMODE_PREFIX_DATA
) {
6278 u32
*destreg
, *srcreg
;
6280 destreg
= DECODE_RM_LONG_REGISTER(rl
);
6282 srcreg
= DECODE_RM_LONG_REGISTER(rh
);
6283 DECODE_PRINTF("\n");
6285 test_long(*destreg
, *srcreg
);
6288 u16
*destreg
, *srcreg
;
6290 destreg
= DECODE_RM_WORD_REGISTER(rl
);
6292 srcreg
= DECODE_RM_WORD_REGISTER(rh
);
6293 DECODE_PRINTF("\n");
6295 test_word(*destreg
, *srcreg
);
6299 DECODE_CLEAR_SEGOVR();
6303 /****************************************************************************
6306 ****************************************************************************/
6308 x86emuOp_xchg_byte_RM_R(u8
X86EMU_UNUSED(op1
))
6311 u8
*destreg
, *srcreg
;
6317 DECODE_PRINTF("XCHG\t");
6318 FETCH_DECODE_MODRM(mod
, rh
, rl
);
6321 destoffset
= decode_rm00_address(rl
);
6323 destval
= fetch_data_byte(destoffset
);
6324 srcreg
= DECODE_RM_BYTE_REGISTER(rh
);
6325 DECODE_PRINTF("\n");
6330 store_data_byte(destoffset
, destval
);
6333 destoffset
= decode_rm01_address(rl
);
6335 destval
= fetch_data_byte(destoffset
);
6336 srcreg
= DECODE_RM_BYTE_REGISTER(rh
);
6337 DECODE_PRINTF("\n");
6342 store_data_byte(destoffset
, destval
);
6345 destoffset
= decode_rm10_address(rl
);
6347 destval
= fetch_data_byte(destoffset
);
6348 srcreg
= DECODE_RM_BYTE_REGISTER(rh
);
6349 DECODE_PRINTF("\n");
6354 store_data_byte(destoffset
, destval
);
6356 case 3: /* register to register */
6357 destreg
= DECODE_RM_BYTE_REGISTER(rl
);
6359 srcreg
= DECODE_RM_BYTE_REGISTER(rh
);
6360 DECODE_PRINTF("\n");
6367 DECODE_CLEAR_SEGOVR();
6371 /****************************************************************************
6374 ****************************************************************************/
6376 x86emuOp_xchg_word_RM_R(u8
X86EMU_UNUSED(op1
))
6382 DECODE_PRINTF("XCHG\t");
6383 FETCH_DECODE_MODRM(mod
, rh
, rl
);
6386 if (M
.x86
.mode
& SYSMODE_PREFIX_DATA
) {
6390 destoffset
= decode_rm00_address(rl
);
6392 destval
= fetch_data_long(destoffset
);
6393 srcreg
= DECODE_RM_LONG_REGISTER(rh
);
6394 DECODE_PRINTF("\n");
6399 store_data_long(destoffset
, destval
);
6405 destoffset
= decode_rm00_address(rl
);
6407 destval
= fetch_data_word(destoffset
);
6408 srcreg
= DECODE_RM_WORD_REGISTER(rh
);
6409 DECODE_PRINTF("\n");
6414 store_data_word(destoffset
, destval
);
6418 if (M
.x86
.mode
& SYSMODE_PREFIX_DATA
) {
6422 destoffset
= decode_rm01_address(rl
);
6424 destval
= fetch_data_long(destoffset
);
6425 srcreg
= DECODE_RM_LONG_REGISTER(rh
);
6426 DECODE_PRINTF("\n");
6431 store_data_long(destoffset
, destval
);
6437 destoffset
= decode_rm01_address(rl
);
6439 destval
= fetch_data_word(destoffset
);
6440 srcreg
= DECODE_RM_WORD_REGISTER(rh
);
6441 DECODE_PRINTF("\n");
6446 store_data_word(destoffset
, destval
);
6450 if (M
.x86
.mode
& SYSMODE_PREFIX_DATA
) {
6454 destoffset
= decode_rm10_address(rl
);
6456 destval
= fetch_data_long(destoffset
);
6457 srcreg
= DECODE_RM_LONG_REGISTER(rh
);
6458 DECODE_PRINTF("\n");
6463 store_data_long(destoffset
, destval
);
6469 destoffset
= decode_rm10_address(rl
);
6471 destval
= fetch_data_word(destoffset
);
6472 srcreg
= DECODE_RM_WORD_REGISTER(rh
);
6473 DECODE_PRINTF("\n");
6478 store_data_word(destoffset
, destval
);
6481 case 3: /* register to register */
6482 if (M
.x86
.mode
& SYSMODE_PREFIX_DATA
) {
6483 u32
*destreg
, *srcreg
;
6486 destreg
= DECODE_RM_LONG_REGISTER(rl
);
6488 srcreg
= DECODE_RM_LONG_REGISTER(rh
);
6489 DECODE_PRINTF("\n");
6496 u16
*destreg
, *srcreg
;
6499 destreg
= DECODE_RM_WORD_REGISTER(rl
);
6501 srcreg
= DECODE_RM_WORD_REGISTER(rh
);
6502 DECODE_PRINTF("\n");
6510 DECODE_CLEAR_SEGOVR();
6514 /****************************************************************************
6517 ****************************************************************************/
6519 x86emuOp_mov_byte_RM_R(u8
X86EMU_UNUSED(op1
))
6522 u8
*destreg
, *srcreg
;
6526 DECODE_PRINTF("MOV\t");
6527 FETCH_DECODE_MODRM(mod
, rh
, rl
);
6530 destoffset
= decode_rm00_address(rl
);
6532 srcreg
= DECODE_RM_BYTE_REGISTER(rh
);
6533 DECODE_PRINTF("\n");
6535 store_data_byte(destoffset
, *srcreg
);
6538 destoffset
= decode_rm01_address(rl
);
6540 srcreg
= DECODE_RM_BYTE_REGISTER(rh
);
6541 DECODE_PRINTF("\n");
6543 store_data_byte(destoffset
, *srcreg
);
6546 destoffset
= decode_rm10_address(rl
);
6548 srcreg
= DECODE_RM_BYTE_REGISTER(rh
);
6549 DECODE_PRINTF("\n");
6551 store_data_byte(destoffset
, *srcreg
);
6553 case 3: /* register to register */
6554 destreg
= DECODE_RM_BYTE_REGISTER(rl
);
6556 srcreg
= DECODE_RM_BYTE_REGISTER(rh
);
6557 DECODE_PRINTF("\n");
6562 DECODE_CLEAR_SEGOVR();
6566 /****************************************************************************
6569 ****************************************************************************/
6571 x86emuOp_mov_word_RM_R(u8
X86EMU_UNUSED(op1
))
6577 DECODE_PRINTF("MOV\t");
6578 FETCH_DECODE_MODRM(mod
, rh
, rl
);
6581 if (M
.x86
.mode
& SYSMODE_PREFIX_DATA
) {
6584 destoffset
= decode_rm00_address(rl
);
6586 srcreg
= DECODE_RM_LONG_REGISTER(rh
);
6587 DECODE_PRINTF("\n");
6589 store_data_long(destoffset
, *srcreg
);
6594 destoffset
= decode_rm00_address(rl
);
6596 srcreg
= DECODE_RM_WORD_REGISTER(rh
);
6597 DECODE_PRINTF("\n");
6599 store_data_word(destoffset
, *srcreg
);
6603 if (M
.x86
.mode
& SYSMODE_PREFIX_DATA
) {
6606 destoffset
= decode_rm01_address(rl
);
6608 srcreg
= DECODE_RM_LONG_REGISTER(rh
);
6609 DECODE_PRINTF("\n");
6611 store_data_long(destoffset
, *srcreg
);
6616 destoffset
= decode_rm01_address(rl
);
6618 srcreg
= DECODE_RM_WORD_REGISTER(rh
);
6619 DECODE_PRINTF("\n");
6621 store_data_word(destoffset
, *srcreg
);
6625 if (M
.x86
.mode
& SYSMODE_PREFIX_DATA
) {
6628 destoffset
= decode_rm10_address(rl
);
6630 srcreg
= DECODE_RM_LONG_REGISTER(rh
);
6631 DECODE_PRINTF("\n");
6633 store_data_long(destoffset
, *srcreg
);
6638 destoffset
= decode_rm10_address(rl
);
6640 srcreg
= DECODE_RM_WORD_REGISTER(rh
);
6641 DECODE_PRINTF("\n");
6643 store_data_word(destoffset
, *srcreg
);
6646 case 3: /* register to register */
6647 if (M
.x86
.mode
& SYSMODE_PREFIX_DATA
) {
6648 u32
*destreg
, *srcreg
;
6650 destreg
= DECODE_RM_LONG_REGISTER(rl
);
6652 srcreg
= DECODE_RM_LONG_REGISTER(rh
);
6653 DECODE_PRINTF("\n");
6658 u16
*destreg
, *srcreg
;
6660 destreg
= DECODE_RM_WORD_REGISTER(rl
);
6662 srcreg
= DECODE_RM_WORD_REGISTER(rh
);
6663 DECODE_PRINTF("\n");
6669 DECODE_CLEAR_SEGOVR();
6673 /****************************************************************************
6676 ****************************************************************************/
6678 x86emuOp_mov_byte_R_RM(u8
X86EMU_UNUSED(op1
))
6681 u8
*destreg
, *srcreg
;
6686 DECODE_PRINTF("MOV\t");
6687 FETCH_DECODE_MODRM(mod
, rh
, rl
);
6690 destreg
= DECODE_RM_BYTE_REGISTER(rh
);
6692 srcoffset
= decode_rm00_address(rl
);
6693 srcval
= fetch_data_byte(srcoffset
);
6694 DECODE_PRINTF("\n");
6699 destreg
= DECODE_RM_BYTE_REGISTER(rh
);
6701 srcoffset
= decode_rm01_address(rl
);
6702 srcval
= fetch_data_byte(srcoffset
);
6703 DECODE_PRINTF("\n");
6708 destreg
= DECODE_RM_BYTE_REGISTER(rh
);
6710 srcoffset
= decode_rm10_address(rl
);
6711 srcval
= fetch_data_byte(srcoffset
);
6712 DECODE_PRINTF("\n");
6716 case 3: /* register to register */
6717 destreg
= DECODE_RM_BYTE_REGISTER(rh
);
6719 srcreg
= DECODE_RM_BYTE_REGISTER(rl
);
6720 DECODE_PRINTF("\n");
6725 DECODE_CLEAR_SEGOVR();
6729 /****************************************************************************
6732 ****************************************************************************/
6734 x86emuOp_mov_word_R_RM(u8
X86EMU_UNUSED(op1
))
6740 DECODE_PRINTF("MOV\t");
6741 FETCH_DECODE_MODRM(mod
, rh
, rl
);
6744 if (M
.x86
.mode
& SYSMODE_PREFIX_DATA
) {
6748 destreg
= DECODE_RM_LONG_REGISTER(rh
);
6750 srcoffset
= decode_rm00_address(rl
);
6751 srcval
= fetch_data_long(srcoffset
);
6752 DECODE_PRINTF("\n");
6760 destreg
= DECODE_RM_WORD_REGISTER(rh
);
6762 srcoffset
= decode_rm00_address(rl
);
6763 srcval
= fetch_data_word(srcoffset
);
6764 DECODE_PRINTF("\n");
6770 if (M
.x86
.mode
& SYSMODE_PREFIX_DATA
) {
6774 destreg
= DECODE_RM_LONG_REGISTER(rh
);
6776 srcoffset
= decode_rm01_address(rl
);
6777 srcval
= fetch_data_long(srcoffset
);
6778 DECODE_PRINTF("\n");
6786 destreg
= DECODE_RM_WORD_REGISTER(rh
);
6788 srcoffset
= decode_rm01_address(rl
);
6789 srcval
= fetch_data_word(srcoffset
);
6790 DECODE_PRINTF("\n");
6796 if (M
.x86
.mode
& SYSMODE_PREFIX_DATA
) {
6800 destreg
= DECODE_RM_LONG_REGISTER(rh
);
6802 srcoffset
= decode_rm10_address(rl
);
6803 srcval
= fetch_data_long(srcoffset
);
6804 DECODE_PRINTF("\n");
6812 destreg
= DECODE_RM_WORD_REGISTER(rh
);
6814 srcoffset
= decode_rm10_address(rl
);
6815 srcval
= fetch_data_word(srcoffset
);
6816 DECODE_PRINTF("\n");
6821 case 3: /* register to register */
6822 if (M
.x86
.mode
& SYSMODE_PREFIX_DATA
) {
6823 u32
*destreg
, *srcreg
;
6825 destreg
= DECODE_RM_LONG_REGISTER(rh
);
6827 srcreg
= DECODE_RM_LONG_REGISTER(rl
);
6828 DECODE_PRINTF("\n");
6833 u16
*destreg
, *srcreg
;
6835 destreg
= DECODE_RM_WORD_REGISTER(rh
);
6837 srcreg
= DECODE_RM_WORD_REGISTER(rl
);
6838 DECODE_PRINTF("\n");
6844 DECODE_CLEAR_SEGOVR();
6848 /****************************************************************************
6851 ****************************************************************************/
6853 x86emuOp_mov_word_RM_SR(u8
X86EMU_UNUSED(op1
))
6856 u16
*destreg
, *srcreg
;
6861 DECODE_PRINTF("MOV\t");
6862 FETCH_DECODE_MODRM(mod
, rh
, rl
);
6865 destoffset
= decode_rm00_address(rl
);
6867 srcreg
= decode_rm_seg_register(rh
);
6868 DECODE_PRINTF("\n");
6871 store_data_word(destoffset
, destval
);
6874 destoffset
= decode_rm01_address(rl
);
6876 srcreg
= decode_rm_seg_register(rh
);
6877 DECODE_PRINTF("\n");
6880 store_data_word(destoffset
, destval
);
6883 destoffset
= decode_rm10_address(rl
);
6885 srcreg
= decode_rm_seg_register(rh
);
6886 DECODE_PRINTF("\n");
6889 store_data_word(destoffset
, destval
);
6891 case 3: /* register to register */
6892 destreg
= DECODE_RM_WORD_REGISTER(rl
);
6894 srcreg
= decode_rm_seg_register(rh
);
6895 DECODE_PRINTF("\n");
6900 DECODE_CLEAR_SEGOVR();
6904 /****************************************************************************
6907 ****************************************************************************/
6909 x86emuOp_lea_word_R_M(u8
X86EMU_UNUSED(op1
))
6915 DECODE_PRINTF("LEA\t");
6916 FETCH_DECODE_MODRM(mod
, rh
, rl
);
6919 if (M
.x86
.mode
& SYSMODE_PREFIX_ADDR
) {
6920 u32
*srcreg
= DECODE_RM_LONG_REGISTER(rh
);
6923 destoffset
= decode_rm00_address(rl
);
6924 DECODE_PRINTF("\n");
6926 *srcreg
= (u32
) destoffset
;
6929 u16
*srcreg
= DECODE_RM_WORD_REGISTER(rh
);
6932 destoffset
= decode_rm00_address(rl
);
6933 DECODE_PRINTF("\n");
6935 *srcreg
= (u16
) destoffset
;
6939 if (M
.x86
.mode
& SYSMODE_PREFIX_ADDR
) {
6940 u32
*srcreg
= DECODE_RM_LONG_REGISTER(rh
);
6943 destoffset
= decode_rm01_address(rl
);
6944 DECODE_PRINTF("\n");
6946 *srcreg
= (u32
) destoffset
;
6949 u16
*srcreg
= DECODE_RM_WORD_REGISTER(rh
);
6952 destoffset
= decode_rm01_address(rl
);
6953 DECODE_PRINTF("\n");
6955 *srcreg
= (u16
) destoffset
;
6959 if (M
.x86
.mode
& SYSMODE_PREFIX_ADDR
) {
6960 u32
*srcreg
= DECODE_RM_LONG_REGISTER(rh
);
6963 destoffset
= decode_rm10_address(rl
);
6964 DECODE_PRINTF("\n");
6966 *srcreg
= (u32
) destoffset
;
6969 u16
*srcreg
= DECODE_RM_WORD_REGISTER(rh
);
6972 destoffset
= decode_rm10_address(rl
);
6973 DECODE_PRINTF("\n");
6975 *srcreg
= (u16
) destoffset
;
6978 case 3: /* register to register */
6979 /* undefined. Do nothing. */
6982 DECODE_CLEAR_SEGOVR();
6986 /****************************************************************************
6989 ****************************************************************************/
6991 x86emuOp_mov_word_SR_RM(u8
X86EMU_UNUSED(op1
))
6994 u16
*destreg
, *srcreg
;
6999 DECODE_PRINTF("MOV\t");
7000 FETCH_DECODE_MODRM(mod
, rh
, rl
);
7003 destreg
= decode_rm_seg_register(rh
);
7005 srcoffset
= decode_rm00_address(rl
);
7006 srcval
= fetch_data_word(srcoffset
);
7007 DECODE_PRINTF("\n");
7012 destreg
= decode_rm_seg_register(rh
);
7014 srcoffset
= decode_rm01_address(rl
);
7015 srcval
= fetch_data_word(srcoffset
);
7016 DECODE_PRINTF("\n");
7021 destreg
= decode_rm_seg_register(rh
);
7023 srcoffset
= decode_rm10_address(rl
);
7024 srcval
= fetch_data_word(srcoffset
);
7025 DECODE_PRINTF("\n");
7029 case 3: /* register to register */
7030 destreg
= decode_rm_seg_register(rh
);
7032 srcreg
= DECODE_RM_WORD_REGISTER(rl
);
7033 DECODE_PRINTF("\n");
7039 * Clean up, and reset all the R_xSP pointers to the correct
7040 * locations. This is about 3x too much overhead (doing all the
7041 * segreg ptrs when only one is needed, but this instruction
7042 * *cannot* be that common, and this isn't too much work anyway.
7044 DECODE_CLEAR_SEGOVR();
7048 /****************************************************************************
7051 ****************************************************************************/
7053 x86emuOp_pop_RM(u8
X86EMU_UNUSED(op1
))
7059 DECODE_PRINTF("POP\t");
7060 FETCH_DECODE_MODRM(mod
, rh
, rl
);
7062 DECODE_PRINTF("ILLEGAL DECODE OF OPCODE 8F\n");
7067 if (M
.x86
.mode
& SYSMODE_PREFIX_DATA
) {
7070 destoffset
= decode_rm00_address(rl
);
7071 DECODE_PRINTF("\n");
7073 destval
= pop_long();
7074 store_data_long(destoffset
, destval
);
7079 destoffset
= decode_rm00_address(rl
);
7080 DECODE_PRINTF("\n");
7082 destval
= pop_word();
7083 store_data_word(destoffset
, destval
);
7087 if (M
.x86
.mode
& SYSMODE_PREFIX_DATA
) {
7090 destoffset
= decode_rm01_address(rl
);
7091 DECODE_PRINTF("\n");
7093 destval
= pop_long();
7094 store_data_long(destoffset
, destval
);
7099 destoffset
= decode_rm01_address(rl
);
7100 DECODE_PRINTF("\n");
7102 destval
= pop_word();
7103 store_data_word(destoffset
, destval
);
7107 if (M
.x86
.mode
& SYSMODE_PREFIX_DATA
) {
7110 destoffset
= decode_rm10_address(rl
);
7111 DECODE_PRINTF("\n");
7113 destval
= pop_long();
7114 store_data_long(destoffset
, destval
);
7119 destoffset
= decode_rm10_address(rl
);
7120 DECODE_PRINTF("\n");
7122 destval
= pop_word();
7123 store_data_word(destoffset
, destval
);
7126 case 3: /* register to register */
7127 if (M
.x86
.mode
& SYSMODE_PREFIX_DATA
) {
7130 destreg
= DECODE_RM_LONG_REGISTER(rl
);
7131 DECODE_PRINTF("\n");
7133 *destreg
= pop_long();
7138 destreg
= DECODE_RM_WORD_REGISTER(rl
);
7139 DECODE_PRINTF("\n");
7141 *destreg
= pop_word();
7145 DECODE_CLEAR_SEGOVR();
7149 /****************************************************************************
7152 ****************************************************************************/
7154 x86emuOp_nop(u8
X86EMU_UNUSED(op1
))
7157 DECODE_PRINTF("NOP\n");
7159 DECODE_CLEAR_SEGOVR();
7163 /****************************************************************************
7166 ****************************************************************************/
7168 x86emuOp_xchg_word_AX_CX(u8
X86EMU_UNUSED(op1
))
7173 if (M
.x86
.mode
& SYSMODE_PREFIX_DATA
) {
7174 DECODE_PRINTF("XCHG\tEAX,ECX\n");
7177 DECODE_PRINTF("XCHG\tAX,CX\n");
7180 if (M
.x86
.mode
& SYSMODE_PREFIX_DATA
) {
7182 M
.x86
.R_EAX
= M
.x86
.R_ECX
;
7187 M
.x86
.R_AX
= M
.x86
.R_CX
;
7188 M
.x86
.R_CX
= (u16
) tmp
;
7190 DECODE_CLEAR_SEGOVR();
7194 /****************************************************************************
7197 ****************************************************************************/
7199 x86emuOp_xchg_word_AX_DX(u8
X86EMU_UNUSED(op1
))
7204 if (M
.x86
.mode
& SYSMODE_PREFIX_DATA
) {
7205 DECODE_PRINTF("XCHG\tEAX,EDX\n");
7208 DECODE_PRINTF("XCHG\tAX,DX\n");
7211 if (M
.x86
.mode
& SYSMODE_PREFIX_DATA
) {
7213 M
.x86
.R_EAX
= M
.x86
.R_EDX
;
7218 M
.x86
.R_AX
= M
.x86
.R_DX
;
7219 M
.x86
.R_DX
= (u16
) tmp
;
7221 DECODE_CLEAR_SEGOVR();
7225 /****************************************************************************
7228 ****************************************************************************/
7230 x86emuOp_xchg_word_AX_BX(u8
X86EMU_UNUSED(op1
))
7235 if (M
.x86
.mode
& SYSMODE_PREFIX_DATA
) {
7236 DECODE_PRINTF("XCHG\tEAX,EBX\n");
7239 DECODE_PRINTF("XCHG\tAX,BX\n");
7242 if (M
.x86
.mode
& SYSMODE_PREFIX_DATA
) {
7244 M
.x86
.R_EAX
= M
.x86
.R_EBX
;
7249 M
.x86
.R_AX
= M
.x86
.R_BX
;
7250 M
.x86
.R_BX
= (u16
) tmp
;
7252 DECODE_CLEAR_SEGOVR();
7256 /****************************************************************************
7259 ****************************************************************************/
7261 x86emuOp_xchg_word_AX_SP(u8
X86EMU_UNUSED(op1
))
7266 if (M
.x86
.mode
& SYSMODE_PREFIX_DATA
) {
7267 DECODE_PRINTF("XCHG\tEAX,ESP\n");
7270 DECODE_PRINTF("XCHG\tAX,SP\n");
7273 if (M
.x86
.mode
& SYSMODE_PREFIX_DATA
) {
7275 M
.x86
.R_EAX
= M
.x86
.R_ESP
;
7280 M
.x86
.R_AX
= M
.x86
.R_SP
;
7281 M
.x86
.R_SP
= (u16
) tmp
;
7283 DECODE_CLEAR_SEGOVR();
7287 /****************************************************************************
7290 ****************************************************************************/
7292 x86emuOp_xchg_word_AX_BP(u8
X86EMU_UNUSED(op1
))
7297 if (M
.x86
.mode
& SYSMODE_PREFIX_DATA
) {
7298 DECODE_PRINTF("XCHG\tEAX,EBP\n");
7301 DECODE_PRINTF("XCHG\tAX,BP\n");
7304 if (M
.x86
.mode
& SYSMODE_PREFIX_DATA
) {
7306 M
.x86
.R_EAX
= M
.x86
.R_EBP
;
7311 M
.x86
.R_AX
= M
.x86
.R_BP
;
7312 M
.x86
.R_BP
= (u16
) tmp
;
7314 DECODE_CLEAR_SEGOVR();
7318 /****************************************************************************
7321 ****************************************************************************/
7323 x86emuOp_xchg_word_AX_SI(u8
X86EMU_UNUSED(op1
))
7328 if (M
.x86
.mode
& SYSMODE_PREFIX_DATA
) {
7329 DECODE_PRINTF("XCHG\tEAX,ESI\n");
7332 DECODE_PRINTF("XCHG\tAX,SI\n");
7335 if (M
.x86
.mode
& SYSMODE_PREFIX_DATA
) {
7337 M
.x86
.R_EAX
= M
.x86
.R_ESI
;
7342 M
.x86
.R_AX
= M
.x86
.R_SI
;
7343 M
.x86
.R_SI
= (u16
) tmp
;
7345 DECODE_CLEAR_SEGOVR();
7349 /****************************************************************************
7352 ****************************************************************************/
7354 x86emuOp_xchg_word_AX_DI(u8
X86EMU_UNUSED(op1
))
7359 if (M
.x86
.mode
& SYSMODE_PREFIX_DATA
) {
7360 DECODE_PRINTF("XCHG\tEAX,EDI\n");
7363 DECODE_PRINTF("XCHG\tAX,DI\n");
7366 if (M
.x86
.mode
& SYSMODE_PREFIX_DATA
) {
7368 M
.x86
.R_EAX
= M
.x86
.R_EDI
;
7373 M
.x86
.R_AX
= M
.x86
.R_DI
;
7374 M
.x86
.R_DI
= (u16
) tmp
;
7376 DECODE_CLEAR_SEGOVR();
7380 /****************************************************************************
7383 ****************************************************************************/
7385 x86emuOp_cbw(u8
X86EMU_UNUSED(op1
))
7388 if (M
.x86
.mode
& SYSMODE_PREFIX_DATA
) {
7389 DECODE_PRINTF("CWDE\n");
7392 DECODE_PRINTF("CBW\n");
7395 if (M
.x86
.mode
& SYSMODE_PREFIX_DATA
) {
7396 if (M
.x86
.R_AX
& 0x8000) {
7397 M
.x86
.R_EAX
|= 0xffff0000;
7400 M
.x86
.R_EAX
&= 0x0000ffff;
7404 if (M
.x86
.R_AL
& 0x80) {
7411 DECODE_CLEAR_SEGOVR();
7415 /****************************************************************************
7418 ****************************************************************************/
7420 x86emuOp_cwd(u8
X86EMU_UNUSED(op1
))
7423 if (M
.x86
.mode
& SYSMODE_PREFIX_DATA
) {
7424 DECODE_PRINTF("CDQ\n");
7427 DECODE_PRINTF("CWD\n");
7429 DECODE_PRINTF("CWD\n");
7431 if (M
.x86
.mode
& SYSMODE_PREFIX_DATA
) {
7432 if (M
.x86
.R_EAX
& 0x80000000) {
7433 M
.x86
.R_EDX
= 0xffffffff;
7440 if (M
.x86
.R_AX
& 0x8000) {
7441 M
.x86
.R_DX
= 0xffff;
7447 DECODE_CLEAR_SEGOVR();
7451 /****************************************************************************
7454 ****************************************************************************/
7456 x86emuOp_call_far_IMM(u8
X86EMU_UNUSED(op1
))
7461 DECODE_PRINTF("CALL\t");
7462 if (M
.x86
.mode
& SYSMODE_PREFIX_DATA
) {
7463 faroff
= fetch_long_imm();
7464 farseg
= fetch_word_imm();
7467 faroff
= fetch_word_imm();
7468 farseg
= fetch_word_imm();
7470 DECODE_PRINTF2("%04x:", farseg
);
7471 DECODE_PRINTF2("%04x\n", faroff
);
7472 CALL_TRACE(M
.x86
.saved_cs
, M
.x86
.saved_ip
, farseg
, faroff
, "FAR ");
7476 * Hooked interrupt vectors calling into our "BIOS" will cause
7477 * problems unless all intersegment stuff is checked for BIOS
7478 * access. Check needed here. For moment, let it alone.
7481 push_word(M
.x86
.R_CS
);
7482 M
.x86
.R_CS
= farseg
;
7483 if (M
.x86
.mode
& SYSMODE_PREFIX_DATA
) {
7484 push_long(M
.x86
.R_EIP
);
7487 push_word(M
.x86
.R_IP
);
7489 M
.x86
.R_EIP
= faroff
& 0xffff;
7490 DECODE_CLEAR_SEGOVR();
7494 /****************************************************************************
7497 ****************************************************************************/
7499 x86emuOp_wait(u8
X86EMU_UNUSED(op1
))
7502 DECODE_PRINTF("WAIT");
7505 DECODE_CLEAR_SEGOVR();
7509 /****************************************************************************
7512 ****************************************************************************/
7514 x86emuOp_pushf_word(u8
X86EMU_UNUSED(op1
))
7519 if (M
.x86
.mode
& SYSMODE_PREFIX_DATA
) {
7520 DECODE_PRINTF("PUSHFD\n");
7523 DECODE_PRINTF("PUSHF\n");
7527 /* clear out *all* bits not representing flags, and turn on real bits */
7528 flags
= (M
.x86
.R_EFLG
& F_MSK
) | F_ALWAYS_ON
;
7529 if (M
.x86
.mode
& SYSMODE_PREFIX_DATA
) {
7533 push_word((u16
) flags
);
7535 DECODE_CLEAR_SEGOVR();
7539 /****************************************************************************
7542 ****************************************************************************/
7544 x86emuOp_popf_word(u8
X86EMU_UNUSED(op1
))
7547 if (M
.x86
.mode
& SYSMODE_PREFIX_DATA
) {
7548 DECODE_PRINTF("POPFD\n");
7551 DECODE_PRINTF("POPF\n");
7554 if (M
.x86
.mode
& SYSMODE_PREFIX_DATA
) {
7555 M
.x86
.R_EFLG
= pop_long();
7558 M
.x86
.R_FLG
= pop_word();
7560 DECODE_CLEAR_SEGOVR();
7564 /****************************************************************************
7567 ****************************************************************************/
7569 x86emuOp_sahf(u8
X86EMU_UNUSED(op1
))
7572 DECODE_PRINTF("SAHF\n");
7574 /* clear the lower bits of the flag register */
7575 M
.x86
.R_FLG
&= 0xffffff00;
7576 /* or in the AH register into the flags register */
7577 M
.x86
.R_FLG
|= M
.x86
.R_AH
;
7578 DECODE_CLEAR_SEGOVR();
7582 /****************************************************************************
7585 ****************************************************************************/
7587 x86emuOp_lahf(u8
X86EMU_UNUSED(op1
))
7590 DECODE_PRINTF("LAHF\n");
7592 M
.x86
.R_AH
= (u8
) (M
.x86
.R_FLG
& 0xff);
7593 /*undocumented TC++ behavior??? Nope. It's documented, but
7594 you have too look real hard to notice it. */
7596 DECODE_CLEAR_SEGOVR();
7600 /****************************************************************************
7603 ****************************************************************************/
7605 x86emuOp_mov_AL_M_IMM(u8
X86EMU_UNUSED(op1
))
7610 DECODE_PRINTF("MOV\tAL,");
7611 offset
= fetch_word_imm();
7612 DECODE_PRINTF2("[%04x]\n", offset
);
7614 M
.x86
.R_AL
= fetch_data_byte(offset
);
7615 DECODE_CLEAR_SEGOVR();
7619 /****************************************************************************
7622 ****************************************************************************/
7624 x86emuOp_mov_AX_M_IMM(u8
X86EMU_UNUSED(op1
))
7629 offset
= fetch_word_imm();
7630 if (M
.x86
.mode
& SYSMODE_PREFIX_DATA
) {
7631 DECODE_PRINTF2("MOV\tEAX,[%04x]\n", offset
);
7634 DECODE_PRINTF2("MOV\tAX,[%04x]\n", offset
);
7637 if (M
.x86
.mode
& SYSMODE_PREFIX_DATA
) {
7638 M
.x86
.R_EAX
= fetch_data_long(offset
);
7641 M
.x86
.R_AX
= fetch_data_word(offset
);
7643 DECODE_CLEAR_SEGOVR();
7647 /****************************************************************************
7650 ****************************************************************************/
7652 x86emuOp_mov_M_AL_IMM(u8
X86EMU_UNUSED(op1
))
7657 DECODE_PRINTF("MOV\t");
7658 offset
= fetch_word_imm();
7659 DECODE_PRINTF2("[%04x],AL\n", offset
);
7661 store_data_byte(offset
, M
.x86
.R_AL
);
7662 DECODE_CLEAR_SEGOVR();
7666 /****************************************************************************
7669 ****************************************************************************/
7671 x86emuOp_mov_M_AX_IMM(u8
X86EMU_UNUSED(op1
))
7676 offset
= fetch_word_imm();
7677 if (M
.x86
.mode
& SYSMODE_PREFIX_DATA
) {
7678 DECODE_PRINTF2("MOV\t[%04x],EAX\n", offset
);
7681 DECODE_PRINTF2("MOV\t[%04x],AX\n", offset
);
7684 if (M
.x86
.mode
& SYSMODE_PREFIX_DATA
) {
7685 store_data_long(offset
, M
.x86
.R_EAX
);
7688 store_data_word(offset
, M
.x86
.R_AX
);
7690 DECODE_CLEAR_SEGOVR();
7694 /****************************************************************************
7697 ****************************************************************************/
7699 x86emuOp_movs_byte(u8
X86EMU_UNUSED(op1
))
7706 DECODE_PRINTF("MOVS\tBYTE\n");
7707 if (ACCESS_FLAG(F_DF
)) /* down */
7713 if (M
.x86
.mode
& (SYSMODE_PREFIX_REPE
| SYSMODE_PREFIX_REPNE
)) {
7714 /* dont care whether REPE or REPNE */
7715 /* move them until CX is ZERO. */
7718 M
.x86
.mode
&= ~(SYSMODE_PREFIX_REPE
| SYSMODE_PREFIX_REPNE
);
7721 val
= fetch_data_byte(M
.x86
.R_SI
);
7722 store_data_byte_abs(M
.x86
.R_ES
, M
.x86
.R_DI
, val
);
7726 DECODE_CLEAR_SEGOVR();
7730 /****************************************************************************
7733 ****************************************************************************/
7735 x86emuOp_movs_word(u8
X86EMU_UNUSED(op1
))
7742 if (M
.x86
.mode
& SYSMODE_PREFIX_DATA
) {
7743 DECODE_PRINTF("MOVS\tDWORD\n");
7744 if (ACCESS_FLAG(F_DF
)) /* down */
7750 DECODE_PRINTF("MOVS\tWORD\n");
7751 if (ACCESS_FLAG(F_DF
)) /* down */
7758 if (M
.x86
.mode
& (SYSMODE_PREFIX_REPE
| SYSMODE_PREFIX_REPNE
)) {
7759 /* dont care whether REPE or REPNE */
7760 /* move them until CX is ZERO. */
7763 M
.x86
.mode
&= ~(SYSMODE_PREFIX_REPE
| SYSMODE_PREFIX_REPNE
);
7766 if (M
.x86
.mode
& SYSMODE_PREFIX_DATA
) {
7767 val
= fetch_data_long(M
.x86
.R_SI
);
7768 store_data_long_abs(M
.x86
.R_ES
, M
.x86
.R_DI
, val
);
7771 val
= fetch_data_word(M
.x86
.R_SI
);
7772 store_data_word_abs(M
.x86
.R_ES
, M
.x86
.R_DI
, (u16
) val
);
7777 DECODE_CLEAR_SEGOVR();
7781 /****************************************************************************
7784 ****************************************************************************/
7786 x86emuOp_cmps_byte(u8
X86EMU_UNUSED(op1
))
7792 DECODE_PRINTF("CMPS\tBYTE\n");
7794 if (ACCESS_FLAG(F_DF
)) /* down */
7799 if (M
.x86
.mode
& SYSMODE_PREFIX_REPE
) {
7801 /* move them until CX is ZERO. */
7802 while (M
.x86
.R_CX
!= 0) {
7803 val1
= fetch_data_byte(M
.x86
.R_SI
);
7804 val2
= fetch_data_byte_abs(M
.x86
.R_ES
, M
.x86
.R_DI
);
7805 cmp_byte(val1
, val2
);
7809 if (ACCESS_FLAG(F_ZF
) == 0)
7812 M
.x86
.mode
&= ~SYSMODE_PREFIX_REPE
;
7814 else if (M
.x86
.mode
& SYSMODE_PREFIX_REPNE
) {
7816 /* move them until CX is ZERO. */
7817 while (M
.x86
.R_CX
!= 0) {
7818 val1
= fetch_data_byte(M
.x86
.R_SI
);
7819 val2
= fetch_data_byte_abs(M
.x86
.R_ES
, M
.x86
.R_DI
);
7820 cmp_byte(val1
, val2
);
7824 if (ACCESS_FLAG(F_ZF
))
7825 break; /* zero flag set means equal */
7827 M
.x86
.mode
&= ~SYSMODE_PREFIX_REPNE
;
7830 val1
= fetch_data_byte(M
.x86
.R_SI
);
7831 val2
= fetch_data_byte_abs(M
.x86
.R_ES
, M
.x86
.R_DI
);
7832 cmp_byte(val1
, val2
);
7836 DECODE_CLEAR_SEGOVR();
7840 /****************************************************************************
7843 ****************************************************************************/
7845 x86emuOp_cmps_word(u8
X86EMU_UNUSED(op1
))
7851 if (M
.x86
.mode
& SYSMODE_PREFIX_DATA
) {
7852 DECODE_PRINTF("CMPS\tDWORD\n");
7853 if (ACCESS_FLAG(F_DF
)) /* down */
7859 DECODE_PRINTF("CMPS\tWORD\n");
7860 if (ACCESS_FLAG(F_DF
)) /* down */
7866 if (M
.x86
.mode
& SYSMODE_PREFIX_REPE
) {
7868 /* move them until CX is ZERO. */
7869 while (M
.x86
.R_CX
!= 0) {
7870 if (M
.x86
.mode
& SYSMODE_PREFIX_DATA
) {
7871 val1
= fetch_data_long(M
.x86
.R_SI
);
7872 val2
= fetch_data_long_abs(M
.x86
.R_ES
, M
.x86
.R_DI
);
7873 cmp_long(val1
, val2
);
7876 val1
= fetch_data_word(M
.x86
.R_SI
);
7877 val2
= fetch_data_word_abs(M
.x86
.R_ES
, M
.x86
.R_DI
);
7878 cmp_word((u16
) val1
, (u16
) val2
);
7883 if (ACCESS_FLAG(F_ZF
) == 0)
7886 M
.x86
.mode
&= ~SYSMODE_PREFIX_REPE
;
7888 else if (M
.x86
.mode
& SYSMODE_PREFIX_REPNE
) {
7890 /* move them until CX is ZERO. */
7891 while (M
.x86
.R_CX
!= 0) {
7892 if (M
.x86
.mode
& SYSMODE_PREFIX_DATA
) {
7893 val1
= fetch_data_long(M
.x86
.R_SI
);
7894 val2
= fetch_data_long_abs(M
.x86
.R_ES
, M
.x86
.R_DI
);
7895 cmp_long(val1
, val2
);
7898 val1
= fetch_data_word(M
.x86
.R_SI
);
7899 val2
= fetch_data_word_abs(M
.x86
.R_ES
, M
.x86
.R_DI
);
7900 cmp_word((u16
) val1
, (u16
) val2
);
7905 if (ACCESS_FLAG(F_ZF
))
7906 break; /* zero flag set means equal */
7908 M
.x86
.mode
&= ~SYSMODE_PREFIX_REPNE
;
7911 if (M
.x86
.mode
& SYSMODE_PREFIX_DATA
) {
7912 val1
= fetch_data_long(M
.x86
.R_SI
);
7913 val2
= fetch_data_long_abs(M
.x86
.R_ES
, M
.x86
.R_DI
);
7914 cmp_long(val1
, val2
);
7917 val1
= fetch_data_word(M
.x86
.R_SI
);
7918 val2
= fetch_data_word_abs(M
.x86
.R_ES
, M
.x86
.R_DI
);
7919 cmp_word((u16
) val1
, (u16
) val2
);
7924 DECODE_CLEAR_SEGOVR();
7928 /****************************************************************************
7931 ****************************************************************************/
7933 x86emuOp_test_AL_IMM(u8
X86EMU_UNUSED(op1
))
7938 DECODE_PRINTF("TEST\tAL,");
7939 imm
= fetch_byte_imm();
7940 DECODE_PRINTF2("%04x\n", imm
);
7942 test_byte(M
.x86
.R_AL
, (u8
) imm
);
7943 DECODE_CLEAR_SEGOVR();
7947 /****************************************************************************
7950 ****************************************************************************/
7952 x86emuOp_test_AX_IMM(u8
X86EMU_UNUSED(op1
))
7957 if (M
.x86
.mode
& SYSMODE_PREFIX_DATA
) {
7958 DECODE_PRINTF("TEST\tEAX,");
7959 srcval
= fetch_long_imm();
7962 DECODE_PRINTF("TEST\tAX,");
7963 srcval
= fetch_word_imm();
7965 DECODE_PRINTF2("%x\n", srcval
);
7967 if (M
.x86
.mode
& SYSMODE_PREFIX_DATA
) {
7968 test_long(M
.x86
.R_EAX
, srcval
);
7971 test_word(M
.x86
.R_AX
, (u16
) srcval
);
7973 DECODE_CLEAR_SEGOVR();
7977 /****************************************************************************
7980 ****************************************************************************/
7982 x86emuOp_stos_byte(u8
X86EMU_UNUSED(op1
))
7987 DECODE_PRINTF("STOS\tBYTE\n");
7988 if (ACCESS_FLAG(F_DF
)) /* down */
7993 if (M
.x86
.mode
& (SYSMODE_PREFIX_REPE
| SYSMODE_PREFIX_REPNE
)) {
7994 /* dont care whether REPE or REPNE */
7995 /* move them until CX is ZERO. */
7996 while (M
.x86
.R_CX
!= 0) {
7997 store_data_byte_abs(M
.x86
.R_ES
, M
.x86
.R_DI
, M
.x86
.R_AL
);
8001 M
.x86
.mode
&= ~(SYSMODE_PREFIX_REPE
| SYSMODE_PREFIX_REPNE
);
8004 store_data_byte_abs(M
.x86
.R_ES
, M
.x86
.R_DI
, M
.x86
.R_AL
);
8007 DECODE_CLEAR_SEGOVR();
8011 /****************************************************************************
8014 ****************************************************************************/
8016 x86emuOp_stos_word(u8
X86EMU_UNUSED(op1
))
8022 if (M
.x86
.mode
& SYSMODE_PREFIX_DATA
) {
8023 DECODE_PRINTF("STOS\tDWORD\n");
8024 if (ACCESS_FLAG(F_DF
)) /* down */
8030 DECODE_PRINTF("STOS\tWORD\n");
8031 if (ACCESS_FLAG(F_DF
)) /* down */
8038 if (M
.x86
.mode
& (SYSMODE_PREFIX_REPE
| SYSMODE_PREFIX_REPNE
)) {
8039 /* dont care whether REPE or REPNE */
8040 /* move them until CX is ZERO. */
8043 M
.x86
.mode
&= ~(SYSMODE_PREFIX_REPE
| SYSMODE_PREFIX_REPNE
);
8046 if (M
.x86
.mode
& SYSMODE_PREFIX_DATA
) {
8047 store_data_long_abs(M
.x86
.R_ES
, M
.x86
.R_DI
, M
.x86
.R_EAX
);
8050 store_data_word_abs(M
.x86
.R_ES
, M
.x86
.R_DI
, M
.x86
.R_AX
);
8054 DECODE_CLEAR_SEGOVR();
8058 /****************************************************************************
8061 ****************************************************************************/
8063 x86emuOp_lods_byte(u8
X86EMU_UNUSED(op1
))
8068 DECODE_PRINTF("LODS\tBYTE\n");
8070 if (ACCESS_FLAG(F_DF
)) /* down */
8074 if (M
.x86
.mode
& (SYSMODE_PREFIX_REPE
| SYSMODE_PREFIX_REPNE
)) {
8075 /* dont care whether REPE or REPNE */
8076 /* move them until CX is ZERO. */
8077 while (M
.x86
.R_CX
!= 0) {
8078 M
.x86
.R_AL
= fetch_data_byte(M
.x86
.R_SI
);
8082 M
.x86
.mode
&= ~(SYSMODE_PREFIX_REPE
| SYSMODE_PREFIX_REPNE
);
8085 M
.x86
.R_AL
= fetch_data_byte(M
.x86
.R_SI
);
8088 DECODE_CLEAR_SEGOVR();
8092 /****************************************************************************
8095 ****************************************************************************/
8097 x86emuOp_lods_word(u8
X86EMU_UNUSED(op1
))
8103 if (M
.x86
.mode
& SYSMODE_PREFIX_DATA
) {
8104 DECODE_PRINTF("LODS\tDWORD\n");
8105 if (ACCESS_FLAG(F_DF
)) /* down */
8111 DECODE_PRINTF("LODS\tWORD\n");
8112 if (ACCESS_FLAG(F_DF
)) /* down */
8119 if (M
.x86
.mode
& (SYSMODE_PREFIX_REPE
| SYSMODE_PREFIX_REPNE
)) {
8120 /* dont care whether REPE or REPNE */
8121 /* move them until CX is ZERO. */
8124 M
.x86
.mode
&= ~(SYSMODE_PREFIX_REPE
| SYSMODE_PREFIX_REPNE
);
8127 if (M
.x86
.mode
& SYSMODE_PREFIX_DATA
) {
8128 M
.x86
.R_EAX
= fetch_data_long(M
.x86
.R_SI
);
8131 M
.x86
.R_AX
= fetch_data_word(M
.x86
.R_SI
);
8135 DECODE_CLEAR_SEGOVR();
8139 /****************************************************************************
8142 ****************************************************************************/
8144 x86emuOp_scas_byte(u8
X86EMU_UNUSED(op1
))
8150 DECODE_PRINTF("SCAS\tBYTE\n");
8152 if (ACCESS_FLAG(F_DF
)) /* down */
8156 if (M
.x86
.mode
& SYSMODE_PREFIX_REPE
) {
8158 /* move them until CX is ZERO. */
8159 while (M
.x86
.R_CX
!= 0) {
8160 val2
= fetch_data_byte_abs(M
.x86
.R_ES
, M
.x86
.R_DI
);
8161 cmp_byte(M
.x86
.R_AL
, val2
);
8164 if (ACCESS_FLAG(F_ZF
) == 0)
8167 M
.x86
.mode
&= ~SYSMODE_PREFIX_REPE
;
8169 else if (M
.x86
.mode
& SYSMODE_PREFIX_REPNE
) {
8171 /* move them until CX is ZERO. */
8172 while (M
.x86
.R_CX
!= 0) {
8173 val2
= fetch_data_byte_abs(M
.x86
.R_ES
, M
.x86
.R_DI
);
8174 cmp_byte(M
.x86
.R_AL
, val2
);
8177 if (ACCESS_FLAG(F_ZF
))
8178 break; /* zero flag set means equal */
8180 M
.x86
.mode
&= ~SYSMODE_PREFIX_REPNE
;
8183 val2
= fetch_data_byte_abs(M
.x86
.R_ES
, M
.x86
.R_DI
);
8184 cmp_byte(M
.x86
.R_AL
, val2
);
8187 DECODE_CLEAR_SEGOVR();
8191 /****************************************************************************
8194 ****************************************************************************/
8196 x86emuOp_scas_word(u8
X86EMU_UNUSED(op1
))
8202 if (M
.x86
.mode
& SYSMODE_PREFIX_DATA
) {
8203 DECODE_PRINTF("SCAS\tDWORD\n");
8204 if (ACCESS_FLAG(F_DF
)) /* down */
8210 DECODE_PRINTF("SCAS\tWORD\n");
8211 if (ACCESS_FLAG(F_DF
)) /* down */
8217 if (M
.x86
.mode
& SYSMODE_PREFIX_REPE
) {
8219 /* move them until CX is ZERO. */
8220 while (M
.x86
.R_CX
!= 0) {
8221 if (M
.x86
.mode
& SYSMODE_PREFIX_DATA
) {
8222 val
= fetch_data_long_abs(M
.x86
.R_ES
, M
.x86
.R_DI
);
8223 cmp_long(M
.x86
.R_EAX
, val
);
8226 val
= fetch_data_word_abs(M
.x86
.R_ES
, M
.x86
.R_DI
);
8227 cmp_word(M
.x86
.R_AX
, (u16
) val
);
8231 if (ACCESS_FLAG(F_ZF
) == 0)
8234 M
.x86
.mode
&= ~SYSMODE_PREFIX_REPE
;
8236 else if (M
.x86
.mode
& SYSMODE_PREFIX_REPNE
) {
8238 /* move them until CX is ZERO. */
8239 while (M
.x86
.R_CX
!= 0) {
8240 if (M
.x86
.mode
& SYSMODE_PREFIX_DATA
) {
8241 val
= fetch_data_long_abs(M
.x86
.R_ES
, M
.x86
.R_DI
);
8242 cmp_long(M
.x86
.R_EAX
, val
);
8245 val
= fetch_data_word_abs(M
.x86
.R_ES
, M
.x86
.R_DI
);
8246 cmp_word(M
.x86
.R_AX
, (u16
) val
);
8250 if (ACCESS_FLAG(F_ZF
))
8251 break; /* zero flag set means equal */
8253 M
.x86
.mode
&= ~SYSMODE_PREFIX_REPNE
;
8256 if (M
.x86
.mode
& SYSMODE_PREFIX_DATA
) {
8257 val
= fetch_data_long_abs(M
.x86
.R_ES
, M
.x86
.R_DI
);
8258 cmp_long(M
.x86
.R_EAX
, val
);
8261 val
= fetch_data_word_abs(M
.x86
.R_ES
, M
.x86
.R_DI
);
8262 cmp_word(M
.x86
.R_AX
, (u16
) val
);
8266 DECODE_CLEAR_SEGOVR();
8270 /****************************************************************************
8273 ****************************************************************************/
8275 x86emuOp_mov_byte_AL_IMM(u8
X86EMU_UNUSED(op1
))
8280 DECODE_PRINTF("MOV\tAL,");
8281 imm
= fetch_byte_imm();
8282 DECODE_PRINTF2("%x\n", imm
);
8285 DECODE_CLEAR_SEGOVR();
8289 /****************************************************************************
8292 ****************************************************************************/
8294 x86emuOp_mov_byte_CL_IMM(u8
X86EMU_UNUSED(op1
))
8299 DECODE_PRINTF("MOV\tCL,");
8300 imm
= fetch_byte_imm();
8301 DECODE_PRINTF2("%x\n", imm
);
8304 DECODE_CLEAR_SEGOVR();
8308 /****************************************************************************
8311 ****************************************************************************/
8313 x86emuOp_mov_byte_DL_IMM(u8
X86EMU_UNUSED(op1
))
8318 DECODE_PRINTF("MOV\tDL,");
8319 imm
= fetch_byte_imm();
8320 DECODE_PRINTF2("%x\n", imm
);
8323 DECODE_CLEAR_SEGOVR();
8327 /****************************************************************************
8330 ****************************************************************************/
8332 x86emuOp_mov_byte_BL_IMM(u8
X86EMU_UNUSED(op1
))
8337 DECODE_PRINTF("MOV\tBL,");
8338 imm
= fetch_byte_imm();
8339 DECODE_PRINTF2("%x\n", imm
);
8342 DECODE_CLEAR_SEGOVR();
8346 /****************************************************************************
8349 ****************************************************************************/
8351 x86emuOp_mov_byte_AH_IMM(u8
X86EMU_UNUSED(op1
))
8356 DECODE_PRINTF("MOV\tAH,");
8357 imm
= fetch_byte_imm();
8358 DECODE_PRINTF2("%x\n", imm
);
8361 DECODE_CLEAR_SEGOVR();
8365 /****************************************************************************
8368 ****************************************************************************/
8370 x86emuOp_mov_byte_CH_IMM(u8
X86EMU_UNUSED(op1
))
8375 DECODE_PRINTF("MOV\tCH,");
8376 imm
= fetch_byte_imm();
8377 DECODE_PRINTF2("%x\n", imm
);
8380 DECODE_CLEAR_SEGOVR();
8384 /****************************************************************************
8387 ****************************************************************************/
8389 x86emuOp_mov_byte_DH_IMM(u8
X86EMU_UNUSED(op1
))
8394 DECODE_PRINTF("MOV\tDH,");
8395 imm
= fetch_byte_imm();
8396 DECODE_PRINTF2("%x\n", imm
);
8399 DECODE_CLEAR_SEGOVR();
8403 /****************************************************************************
8406 ****************************************************************************/
8408 x86emuOp_mov_byte_BH_IMM(u8
X86EMU_UNUSED(op1
))
8413 DECODE_PRINTF("MOV\tBH,");
8414 imm
= fetch_byte_imm();
8415 DECODE_PRINTF2("%x\n", imm
);
8418 DECODE_CLEAR_SEGOVR();
8422 /****************************************************************************
8425 ****************************************************************************/
8427 x86emuOp_mov_word_AX_IMM(u8
X86EMU_UNUSED(op1
))
8432 if (M
.x86
.mode
& SYSMODE_PREFIX_DATA
) {
8433 DECODE_PRINTF("MOV\tEAX,");
8434 srcval
= fetch_long_imm();
8437 DECODE_PRINTF("MOV\tAX,");
8438 srcval
= fetch_word_imm();
8440 DECODE_PRINTF2("%x\n", srcval
);
8442 if (M
.x86
.mode
& SYSMODE_PREFIX_DATA
) {
8443 M
.x86
.R_EAX
= srcval
;
8446 M
.x86
.R_AX
= (u16
) srcval
;
8448 DECODE_CLEAR_SEGOVR();
8452 /****************************************************************************
8455 ****************************************************************************/
8457 x86emuOp_mov_word_CX_IMM(u8
X86EMU_UNUSED(op1
))
8462 if (M
.x86
.mode
& SYSMODE_PREFIX_DATA
) {
8463 DECODE_PRINTF("MOV\tECX,");
8464 srcval
= fetch_long_imm();
8467 DECODE_PRINTF("MOV\tCX,");
8468 srcval
= fetch_word_imm();
8470 DECODE_PRINTF2("%x\n", srcval
);
8472 if (M
.x86
.mode
& SYSMODE_PREFIX_DATA
) {
8473 M
.x86
.R_ECX
= srcval
;
8476 M
.x86
.R_CX
= (u16
) srcval
;
8478 DECODE_CLEAR_SEGOVR();
8482 /****************************************************************************
8485 ****************************************************************************/
8487 x86emuOp_mov_word_DX_IMM(u8
X86EMU_UNUSED(op1
))
8492 if (M
.x86
.mode
& SYSMODE_PREFIX_DATA
) {
8493 DECODE_PRINTF("MOV\tEDX,");
8494 srcval
= fetch_long_imm();
8497 DECODE_PRINTF("MOV\tDX,");
8498 srcval
= fetch_word_imm();
8500 DECODE_PRINTF2("%x\n", srcval
);
8502 if (M
.x86
.mode
& SYSMODE_PREFIX_DATA
) {
8503 M
.x86
.R_EDX
= srcval
;
8506 M
.x86
.R_DX
= (u16
) srcval
;
8508 DECODE_CLEAR_SEGOVR();
8512 /****************************************************************************
8515 ****************************************************************************/
8517 x86emuOp_mov_word_BX_IMM(u8
X86EMU_UNUSED(op1
))
8522 if (M
.x86
.mode
& SYSMODE_PREFIX_DATA
) {
8523 DECODE_PRINTF("MOV\tEBX,");
8524 srcval
= fetch_long_imm();
8527 DECODE_PRINTF("MOV\tBX,");
8528 srcval
= fetch_word_imm();
8530 DECODE_PRINTF2("%x\n", srcval
);
8532 if (M
.x86
.mode
& SYSMODE_PREFIX_DATA
) {
8533 M
.x86
.R_EBX
= srcval
;
8536 M
.x86
.R_BX
= (u16
) srcval
;
8538 DECODE_CLEAR_SEGOVR();
8542 /****************************************************************************
8545 ****************************************************************************/
8547 x86emuOp_mov_word_SP_IMM(u8
X86EMU_UNUSED(op1
))
8552 if (M
.x86
.mode
& SYSMODE_PREFIX_DATA
) {
8553 DECODE_PRINTF("MOV\tESP,");
8554 srcval
= fetch_long_imm();
8557 DECODE_PRINTF("MOV\tSP,");
8558 srcval
= fetch_word_imm();
8560 DECODE_PRINTF2("%x\n", srcval
);
8562 if (M
.x86
.mode
& SYSMODE_PREFIX_DATA
) {
8563 M
.x86
.R_ESP
= srcval
;
8566 M
.x86
.R_SP
= (u16
) srcval
;
8568 DECODE_CLEAR_SEGOVR();
8572 /****************************************************************************
8575 ****************************************************************************/
8577 x86emuOp_mov_word_BP_IMM(u8
X86EMU_UNUSED(op1
))
8582 if (M
.x86
.mode
& SYSMODE_PREFIX_DATA
) {
8583 DECODE_PRINTF("MOV\tEBP,");
8584 srcval
= fetch_long_imm();
8587 DECODE_PRINTF("MOV\tBP,");
8588 srcval
= fetch_word_imm();
8590 DECODE_PRINTF2("%x\n", srcval
);
8592 if (M
.x86
.mode
& SYSMODE_PREFIX_DATA
) {
8593 M
.x86
.R_EBP
= srcval
;
8596 M
.x86
.R_BP
= (u16
) srcval
;
8598 DECODE_CLEAR_SEGOVR();
8602 /****************************************************************************
8605 ****************************************************************************/
8607 x86emuOp_mov_word_SI_IMM(u8
X86EMU_UNUSED(op1
))
8612 if (M
.x86
.mode
& SYSMODE_PREFIX_DATA
) {
8613 DECODE_PRINTF("MOV\tESI,");
8614 srcval
= fetch_long_imm();
8617 DECODE_PRINTF("MOV\tSI,");
8618 srcval
= fetch_word_imm();
8620 DECODE_PRINTF2("%x\n", srcval
);
8622 if (M
.x86
.mode
& SYSMODE_PREFIX_DATA
) {
8623 M
.x86
.R_ESI
= srcval
;
8626 M
.x86
.R_SI
= (u16
) srcval
;
8628 DECODE_CLEAR_SEGOVR();
8632 /****************************************************************************
8635 ****************************************************************************/
8637 x86emuOp_mov_word_DI_IMM(u8
X86EMU_UNUSED(op1
))
8642 if (M
.x86
.mode
& SYSMODE_PREFIX_DATA
) {
8643 DECODE_PRINTF("MOV\tEDI,");
8644 srcval
= fetch_long_imm();
8647 DECODE_PRINTF("MOV\tDI,");
8648 srcval
= fetch_word_imm();
8650 DECODE_PRINTF2("%x\n", srcval
);
8652 if (M
.x86
.mode
& SYSMODE_PREFIX_DATA
) {
8653 M
.x86
.R_EDI
= srcval
;
8656 M
.x86
.R_DI
= (u16
) srcval
;
8658 DECODE_CLEAR_SEGOVR();
8662 /* used by opcodes c0, d0, and d2. */
8663 static u8(*opcD0_byte_operation
[]) (u8 d
, u8 s
) = {
8664 rol_byte
, ror_byte
, rcl_byte
, rcr_byte
, shl_byte
, shr_byte
, shl_byte
, /* sal_byte === shl_byte by definition */
8667 /****************************************************************************
8670 ****************************************************************************/
8672 x86emuOp_opcC0_byte_RM_MEM(u8
X86EMU_UNUSED(op1
))
8681 * Yet another weirdo special case instruction format. Part of
8682 * the opcode held below in "RH". Doubly nested case would
8683 * result, except that the decoded instruction
8686 FETCH_DECODE_MODRM(mod
, rh
, rl
);
8688 if (DEBUG_DECODE()) {
8689 /* XXX DECODE_PRINTF may be changed to something more
8690 general, so that it is important to leave the strings
8691 in the same format, even though the result is that the
8692 above test is done twice. */
8696 DECODE_PRINTF("ROL\t");
8699 DECODE_PRINTF("ROR\t");
8702 DECODE_PRINTF("RCL\t");
8705 DECODE_PRINTF("RCR\t");
8708 DECODE_PRINTF("SHL\t");
8711 DECODE_PRINTF("SHR\t");
8714 DECODE_PRINTF("SAL\t");
8717 DECODE_PRINTF("SAR\t");
8722 /* know operation, decode the mod byte to find the addressing
8726 DECODE_PRINTF("BYTE PTR ");
8727 destoffset
= decode_rm00_address(rl
);
8728 amt
= fetch_byte_imm();
8729 DECODE_PRINTF2(",%x\n", amt
);
8730 destval
= fetch_data_byte(destoffset
);
8732 destval
= (*opcD0_byte_operation
[rh
]) (destval
, amt
);
8733 store_data_byte(destoffset
, destval
);
8736 DECODE_PRINTF("BYTE PTR ");
8737 destoffset
= decode_rm01_address(rl
);
8738 amt
= fetch_byte_imm();
8739 DECODE_PRINTF2(",%x\n", amt
);
8740 destval
= fetch_data_byte(destoffset
);
8742 destval
= (*opcD0_byte_operation
[rh
]) (destval
, amt
);
8743 store_data_byte(destoffset
, destval
);
8746 DECODE_PRINTF("BYTE PTR ");
8747 destoffset
= decode_rm10_address(rl
);
8748 amt
= fetch_byte_imm();
8749 DECODE_PRINTF2(",%x\n", amt
);
8750 destval
= fetch_data_byte(destoffset
);
8752 destval
= (*opcD0_byte_operation
[rh
]) (destval
, amt
);
8753 store_data_byte(destoffset
, destval
);
8755 case 3: /* register to register */
8756 destreg
= DECODE_RM_BYTE_REGISTER(rl
);
8757 amt
= fetch_byte_imm();
8758 DECODE_PRINTF2(",%x\n", amt
);
8760 destval
= (*opcD0_byte_operation
[rh
]) (*destreg
, amt
);
8764 DECODE_CLEAR_SEGOVR();
8768 /* used by opcodes c1, d1, and d3. */
8769 static u16(*opcD1_word_operation
[]) (u16 s
, u8 d
) = {
8770 rol_word
, ror_word
, rcl_word
, rcr_word
, shl_word
, shr_word
, shl_word
, /* sal_byte === shl_byte by definition */
8773 /* used by opcodes c1, d1, and d3. */
8774 static u32(*opcD1_long_operation
[]) (u32 s
, u8 d
) = {
8775 rol_long
, ror_long
, rcl_long
, rcr_long
, shl_long
, shr_long
, shl_long
, /* sal_byte === shl_byte by definition */
8778 /****************************************************************************
8781 ****************************************************************************/
8783 x86emuOp_opcC1_word_RM_MEM(u8
X86EMU_UNUSED(op1
))
8790 * Yet another weirdo special case instruction format. Part of
8791 * the opcode held below in "RH". Doubly nested case would
8792 * result, except that the decoded instruction
8795 FETCH_DECODE_MODRM(mod
, rh
, rl
);
8797 if (DEBUG_DECODE()) {
8798 /* XXX DECODE_PRINTF may be changed to something more
8799 general, so that it is important to leave the strings
8800 in the same format, even though the result is that the
8801 above test is done twice. */
8805 DECODE_PRINTF("ROL\t");
8808 DECODE_PRINTF("ROR\t");
8811 DECODE_PRINTF("RCL\t");
8814 DECODE_PRINTF("RCR\t");
8817 DECODE_PRINTF("SHL\t");
8820 DECODE_PRINTF("SHR\t");
8823 DECODE_PRINTF("SAL\t");
8826 DECODE_PRINTF("SAR\t");
8831 /* know operation, decode the mod byte to find the addressing
8835 if (M
.x86
.mode
& SYSMODE_PREFIX_DATA
) {
8838 DECODE_PRINTF("DWORD PTR ");
8839 destoffset
= decode_rm00_address(rl
);
8840 amt
= fetch_byte_imm();
8841 DECODE_PRINTF2(",%x\n", amt
);
8842 destval
= fetch_data_long(destoffset
);
8844 destval
= (*opcD1_long_operation
[rh
]) (destval
, amt
);
8845 store_data_long(destoffset
, destval
);
8850 DECODE_PRINTF("WORD PTR ");
8851 destoffset
= decode_rm00_address(rl
);
8852 amt
= fetch_byte_imm();
8853 DECODE_PRINTF2(",%x\n", amt
);
8854 destval
= fetch_data_word(destoffset
);
8856 destval
= (*opcD1_word_operation
[rh
]) (destval
, amt
);
8857 store_data_word(destoffset
, destval
);
8861 if (M
.x86
.mode
& SYSMODE_PREFIX_DATA
) {
8864 DECODE_PRINTF("DWORD PTR ");
8865 destoffset
= decode_rm01_address(rl
);
8866 amt
= fetch_byte_imm();
8867 DECODE_PRINTF2(",%x\n", amt
);
8868 destval
= fetch_data_long(destoffset
);
8870 destval
= (*opcD1_long_operation
[rh
]) (destval
, amt
);
8871 store_data_long(destoffset
, destval
);
8876 DECODE_PRINTF("WORD PTR ");
8877 destoffset
= decode_rm01_address(rl
);
8878 amt
= fetch_byte_imm();
8879 DECODE_PRINTF2(",%x\n", amt
);
8880 destval
= fetch_data_word(destoffset
);
8882 destval
= (*opcD1_word_operation
[rh
]) (destval
, amt
);
8883 store_data_word(destoffset
, destval
);
8887 if (M
.x86
.mode
& SYSMODE_PREFIX_DATA
) {
8890 DECODE_PRINTF("DWORD PTR ");
8891 destoffset
= decode_rm10_address(rl
);
8892 amt
= fetch_byte_imm();
8893 DECODE_PRINTF2(",%x\n", amt
);
8894 destval
= fetch_data_long(destoffset
);
8896 destval
= (*opcD1_long_operation
[rh
]) (destval
, amt
);
8897 store_data_long(destoffset
, destval
);
8902 DECODE_PRINTF("WORD PTR ");
8903 destoffset
= decode_rm10_address(rl
);
8904 amt
= fetch_byte_imm();
8905 DECODE_PRINTF2(",%x\n", amt
);
8906 destval
= fetch_data_word(destoffset
);
8908 destval
= (*opcD1_word_operation
[rh
]) (destval
, amt
);
8909 store_data_word(destoffset
, destval
);
8912 case 3: /* register to register */
8913 if (M
.x86
.mode
& SYSMODE_PREFIX_DATA
) {
8916 destreg
= DECODE_RM_LONG_REGISTER(rl
);
8917 amt
= fetch_byte_imm();
8918 DECODE_PRINTF2(",%x\n", amt
);
8920 *destreg
= (*opcD1_long_operation
[rh
]) (*destreg
, amt
);
8925 destreg
= DECODE_RM_WORD_REGISTER(rl
);
8926 amt
= fetch_byte_imm();
8927 DECODE_PRINTF2(",%x\n", amt
);
8929 *destreg
= (*opcD1_word_operation
[rh
]) (*destreg
, amt
);
8933 DECODE_CLEAR_SEGOVR();
8937 /****************************************************************************
8940 ****************************************************************************/
8942 x86emuOp_ret_near_IMM(u8
X86EMU_UNUSED(op1
))
8947 DECODE_PRINTF("RET\t");
8948 imm
= fetch_word_imm();
8949 DECODE_PRINTF2("%x\n", imm
);
8950 RETURN_TRACE("RET", M
.x86
.saved_cs
, M
.x86
.saved_ip
);
8952 M
.x86
.R_IP
= pop_word();
8954 DECODE_CLEAR_SEGOVR();
8958 /****************************************************************************
8961 ****************************************************************************/
8963 x86emuOp_ret_near(u8
X86EMU_UNUSED(op1
))
8966 DECODE_PRINTF("RET\n");
8967 RETURN_TRACE("RET", M
.x86
.saved_cs
, M
.x86
.saved_ip
);
8969 M
.x86
.R_IP
= pop_word();
8970 DECODE_CLEAR_SEGOVR();
8974 /****************************************************************************
8977 ****************************************************************************/
8979 x86emuOp_les_R_IMM(u8
X86EMU_UNUSED(op1
))
8986 DECODE_PRINTF("LES\t");
8987 FETCH_DECODE_MODRM(mod
, rh
, rl
);
8990 dstreg
= DECODE_RM_WORD_REGISTER(rh
);
8992 srcoffset
= decode_rm00_address(rl
);
8993 DECODE_PRINTF("\n");
8995 *dstreg
= fetch_data_word(srcoffset
);
8996 M
.x86
.R_ES
= fetch_data_word(srcoffset
+ 2);
8999 dstreg
= DECODE_RM_WORD_REGISTER(rh
);
9001 srcoffset
= decode_rm01_address(rl
);
9002 DECODE_PRINTF("\n");
9004 *dstreg
= fetch_data_word(srcoffset
);
9005 M
.x86
.R_ES
= fetch_data_word(srcoffset
+ 2);
9008 dstreg
= DECODE_RM_WORD_REGISTER(rh
);
9010 srcoffset
= decode_rm10_address(rl
);
9011 DECODE_PRINTF("\n");
9013 *dstreg
= fetch_data_word(srcoffset
);
9014 M
.x86
.R_ES
= fetch_data_word(srcoffset
+ 2);
9016 case 3: /* register to register */
9020 DECODE_CLEAR_SEGOVR();
9024 /****************************************************************************
9027 ****************************************************************************/
9029 x86emuOp_lds_R_IMM(u8
X86EMU_UNUSED(op1
))
9036 DECODE_PRINTF("LDS\t");
9037 FETCH_DECODE_MODRM(mod
, rh
, rl
);
9040 dstreg
= DECODE_RM_WORD_REGISTER(rh
);
9042 srcoffset
= decode_rm00_address(rl
);
9043 DECODE_PRINTF("\n");
9045 *dstreg
= fetch_data_word(srcoffset
);
9046 M
.x86
.R_DS
= fetch_data_word(srcoffset
+ 2);
9049 dstreg
= DECODE_RM_WORD_REGISTER(rh
);
9051 srcoffset
= decode_rm01_address(rl
);
9052 DECODE_PRINTF("\n");
9054 *dstreg
= fetch_data_word(srcoffset
);
9055 M
.x86
.R_DS
= fetch_data_word(srcoffset
+ 2);
9058 dstreg
= DECODE_RM_WORD_REGISTER(rh
);
9060 srcoffset
= decode_rm10_address(rl
);
9061 DECODE_PRINTF("\n");
9063 *dstreg
= fetch_data_word(srcoffset
);
9064 M
.x86
.R_DS
= fetch_data_word(srcoffset
+ 2);
9066 case 3: /* register to register */
9070 DECODE_CLEAR_SEGOVR();
9074 /****************************************************************************
9077 ****************************************************************************/
9079 x86emuOp_mov_byte_RM_IMM(u8
X86EMU_UNUSED(op1
))
9087 DECODE_PRINTF("MOV\t");
9088 FETCH_DECODE_MODRM(mod
, rh
, rl
);
9090 DECODE_PRINTF("ILLEGAL DECODE OF OPCODE c6\n");
9095 DECODE_PRINTF("BYTE PTR ");
9096 destoffset
= decode_rm00_address(rl
);
9097 imm
= fetch_byte_imm();
9098 DECODE_PRINTF2(",%2x\n", imm
);
9100 store_data_byte(destoffset
, imm
);
9103 DECODE_PRINTF("BYTE PTR ");
9104 destoffset
= decode_rm01_address(rl
);
9105 imm
= fetch_byte_imm();
9106 DECODE_PRINTF2(",%2x\n", imm
);
9108 store_data_byte(destoffset
, imm
);
9111 DECODE_PRINTF("BYTE PTR ");
9112 destoffset
= decode_rm10_address(rl
);
9113 imm
= fetch_byte_imm();
9114 DECODE_PRINTF2(",%2x\n", imm
);
9116 store_data_byte(destoffset
, imm
);
9118 case 3: /* register to register */
9119 destreg
= DECODE_RM_BYTE_REGISTER(rl
);
9120 imm
= fetch_byte_imm();
9121 DECODE_PRINTF2(",%2x\n", imm
);
9126 DECODE_CLEAR_SEGOVR();
9130 /****************************************************************************
9133 ****************************************************************************/
9135 x86emuOp_mov_word_RM_IMM(u8
X86EMU_UNUSED(op1
))
9141 DECODE_PRINTF("MOV\t");
9142 FETCH_DECODE_MODRM(mod
, rh
, rl
);
9144 DECODE_PRINTF("ILLEGAL DECODE OF OPCODE 8F\n");
9149 if (M
.x86
.mode
& SYSMODE_PREFIX_DATA
) {
9152 DECODE_PRINTF("DWORD PTR ");
9153 destoffset
= decode_rm00_address(rl
);
9154 imm
= fetch_long_imm();
9155 DECODE_PRINTF2(",%x\n", imm
);
9157 store_data_long(destoffset
, imm
);
9162 DECODE_PRINTF("WORD PTR ");
9163 destoffset
= decode_rm00_address(rl
);
9164 imm
= fetch_word_imm();
9165 DECODE_PRINTF2(",%x\n", imm
);
9167 store_data_word(destoffset
, imm
);
9171 if (M
.x86
.mode
& SYSMODE_PREFIX_DATA
) {
9174 DECODE_PRINTF("DWORD PTR ");
9175 destoffset
= decode_rm01_address(rl
);
9176 imm
= fetch_long_imm();
9177 DECODE_PRINTF2(",%x\n", imm
);
9179 store_data_long(destoffset
, imm
);
9184 DECODE_PRINTF("WORD PTR ");
9185 destoffset
= decode_rm01_address(rl
);
9186 imm
= fetch_word_imm();
9187 DECODE_PRINTF2(",%x\n", imm
);
9189 store_data_word(destoffset
, imm
);
9193 if (M
.x86
.mode
& SYSMODE_PREFIX_DATA
) {
9196 DECODE_PRINTF("DWORD PTR ");
9197 destoffset
= decode_rm10_address(rl
);
9198 imm
= fetch_long_imm();
9199 DECODE_PRINTF2(",%x\n", imm
);
9201 store_data_long(destoffset
, imm
);
9206 DECODE_PRINTF("WORD PTR ");
9207 destoffset
= decode_rm10_address(rl
);
9208 imm
= fetch_word_imm();
9209 DECODE_PRINTF2(",%x\n", imm
);
9211 store_data_word(destoffset
, imm
);
9214 case 3: /* register to register */
9215 if (M
.x86
.mode
& SYSMODE_PREFIX_DATA
) {
9219 destreg
= DECODE_RM_LONG_REGISTER(rl
);
9220 imm
= fetch_long_imm();
9221 DECODE_PRINTF2(",%x\n", imm
);
9229 destreg
= DECODE_RM_WORD_REGISTER(rl
);
9230 imm
= fetch_word_imm();
9231 DECODE_PRINTF2(",%x\n", imm
);
9237 DECODE_CLEAR_SEGOVR();
9241 /****************************************************************************
9244 ****************************************************************************/
9246 x86emuOp_enter(u8
X86EMU_UNUSED(op1
))
9248 u16 local
, frame_pointer
;
9253 local
= fetch_word_imm();
9254 nesting
= fetch_byte_imm();
9255 DECODE_PRINTF2("ENTER %x\n", local
);
9256 DECODE_PRINTF2(",%x\n", nesting
);
9258 push_word(M
.x86
.R_BP
);
9259 frame_pointer
= M
.x86
.R_SP
;
9261 for (i
= 1; i
< nesting
; i
++) {
9263 push_word(fetch_data_word_abs(M
.x86
.R_SS
, M
.x86
.R_BP
));
9265 push_word(frame_pointer
);
9267 M
.x86
.R_BP
= frame_pointer
;
9268 M
.x86
.R_SP
= (u16
) (M
.x86
.R_SP
- local
);
9269 DECODE_CLEAR_SEGOVR();
9273 /****************************************************************************
9276 ****************************************************************************/
9278 x86emuOp_leave(u8
X86EMU_UNUSED(op1
))
9281 DECODE_PRINTF("LEAVE\n");
9283 M
.x86
.R_SP
= M
.x86
.R_BP
;
9284 M
.x86
.R_BP
= pop_word();
9285 DECODE_CLEAR_SEGOVR();
9289 /****************************************************************************
9292 ****************************************************************************/
9294 x86emuOp_ret_far_IMM(u8
X86EMU_UNUSED(op1
))
9299 DECODE_PRINTF("RETF\t");
9300 imm
= fetch_word_imm();
9301 DECODE_PRINTF2("%x\n", imm
);
9302 RETURN_TRACE("RETF", M
.x86
.saved_cs
, M
.x86
.saved_ip
);
9304 M
.x86
.R_IP
= pop_word();
9305 M
.x86
.R_CS
= pop_word();
9307 DECODE_CLEAR_SEGOVR();
9311 /****************************************************************************
9314 ****************************************************************************/
9316 x86emuOp_ret_far(u8
X86EMU_UNUSED(op1
))
9319 DECODE_PRINTF("RETF\n");
9320 RETURN_TRACE("RETF", M
.x86
.saved_cs
, M
.x86
.saved_ip
);
9322 M
.x86
.R_IP
= pop_word();
9323 M
.x86
.R_CS
= pop_word();
9324 DECODE_CLEAR_SEGOVR();
9328 /****************************************************************************
9331 ****************************************************************************/
9333 x86emuOp_int3(u8
X86EMU_UNUSED(op1
))
9336 DECODE_PRINTF("INT 3\n");
9338 if (_X86EMU_intrTab
[3]) {
9339 (*_X86EMU_intrTab
[3]) (3);
9342 push_word((u16
) M
.x86
.R_FLG
);
9345 push_word(M
.x86
.R_CS
);
9346 M
.x86
.R_CS
= mem_access_word(3 * 4 + 2);
9347 push_word(M
.x86
.R_IP
);
9348 M
.x86
.R_IP
= mem_access_word(3 * 4);
9350 DECODE_CLEAR_SEGOVR();
9354 /****************************************************************************
9357 ****************************************************************************/
9359 x86emuOp_int_IMM(u8
X86EMU_UNUSED(op1
))
9364 DECODE_PRINTF("INT\t");
9365 intnum
= fetch_byte_imm();
9366 DECODE_PRINTF2("%x\n", intnum
);
9368 if (_X86EMU_intrTab
[intnum
]) {
9369 (*_X86EMU_intrTab
[intnum
]) (intnum
);
9372 push_word((u16
) M
.x86
.R_FLG
);
9375 push_word(M
.x86
.R_CS
);
9376 M
.x86
.R_CS
= mem_access_word(intnum
* 4 + 2);
9377 push_word(M
.x86
.R_IP
);
9378 M
.x86
.R_IP
= mem_access_word(intnum
* 4);
9380 DECODE_CLEAR_SEGOVR();
9384 /****************************************************************************
9387 ****************************************************************************/
9389 x86emuOp_into(u8
X86EMU_UNUSED(op1
))
9392 DECODE_PRINTF("INTO\n");
9394 if (ACCESS_FLAG(F_OF
)) {
9395 if (_X86EMU_intrTab
[4]) {
9396 (*_X86EMU_intrTab
[4]) (4);
9399 push_word((u16
) M
.x86
.R_FLG
);
9402 push_word(M
.x86
.R_CS
);
9403 M
.x86
.R_CS
= mem_access_word(4 * 4 + 2);
9404 push_word(M
.x86
.R_IP
);
9405 M
.x86
.R_IP
= mem_access_word(4 * 4);
9408 DECODE_CLEAR_SEGOVR();
9412 /****************************************************************************
9415 ****************************************************************************/
9417 x86emuOp_iret(u8
X86EMU_UNUSED(op1
))
9420 DECODE_PRINTF("IRET\n");
9424 M
.x86
.R_IP
= pop_word();
9425 M
.x86
.R_CS
= pop_word();
9426 M
.x86
.R_FLG
= pop_word();
9427 DECODE_CLEAR_SEGOVR();
9431 /****************************************************************************
9434 ****************************************************************************/
9436 x86emuOp_opcD0_byte_RM_1(u8
X86EMU_UNUSED(op1
))
9444 * Yet another weirdo special case instruction format. Part of
9445 * the opcode held below in "RH". Doubly nested case would
9446 * result, except that the decoded instruction
9449 FETCH_DECODE_MODRM(mod
, rh
, rl
);
9451 if (DEBUG_DECODE()) {
9452 /* XXX DECODE_PRINTF may be changed to something more
9453 general, so that it is important to leave the strings
9454 in the same format, even though the result is that the
9455 above test is done twice. */
9458 DECODE_PRINTF("ROL\t");
9461 DECODE_PRINTF("ROR\t");
9464 DECODE_PRINTF("RCL\t");
9467 DECODE_PRINTF("RCR\t");
9470 DECODE_PRINTF("SHL\t");
9473 DECODE_PRINTF("SHR\t");
9476 DECODE_PRINTF("SAL\t");
9479 DECODE_PRINTF("SAR\t");
9484 /* know operation, decode the mod byte to find the addressing
9488 DECODE_PRINTF("BYTE PTR ");
9489 destoffset
= decode_rm00_address(rl
);
9490 DECODE_PRINTF(",1\n");
9491 destval
= fetch_data_byte(destoffset
);
9493 destval
= (*opcD0_byte_operation
[rh
]) (destval
, 1);
9494 store_data_byte(destoffset
, destval
);
9497 DECODE_PRINTF("BYTE PTR ");
9498 destoffset
= decode_rm01_address(rl
);
9499 DECODE_PRINTF(",1\n");
9500 destval
= fetch_data_byte(destoffset
);
9502 destval
= (*opcD0_byte_operation
[rh
]) (destval
, 1);
9503 store_data_byte(destoffset
, destval
);
9506 DECODE_PRINTF("BYTE PTR ");
9507 destoffset
= decode_rm10_address(rl
);
9508 DECODE_PRINTF(",1\n");
9509 destval
= fetch_data_byte(destoffset
);
9511 destval
= (*opcD0_byte_operation
[rh
]) (destval
, 1);
9512 store_data_byte(destoffset
, destval
);
9514 case 3: /* register to register */
9515 destreg
= DECODE_RM_BYTE_REGISTER(rl
);
9516 DECODE_PRINTF(",1\n");
9518 destval
= (*opcD0_byte_operation
[rh
]) (*destreg
, 1);
9522 DECODE_CLEAR_SEGOVR();
9526 /****************************************************************************
9529 ****************************************************************************/
9531 x86emuOp_opcD1_word_RM_1(u8
X86EMU_UNUSED(op1
))
9537 * Yet another weirdo special case instruction format. Part of
9538 * the opcode held below in "RH". Doubly nested case would
9539 * result, except that the decoded instruction
9542 FETCH_DECODE_MODRM(mod
, rh
, rl
);
9544 if (DEBUG_DECODE()) {
9545 /* XXX DECODE_PRINTF may be changed to something more
9546 general, so that it is important to leave the strings
9547 in the same format, even though the result is that the
9548 above test is done twice. */
9551 DECODE_PRINTF("ROL\t");
9554 DECODE_PRINTF("ROR\t");
9557 DECODE_PRINTF("RCL\t");
9560 DECODE_PRINTF("RCR\t");
9563 DECODE_PRINTF("SHL\t");
9566 DECODE_PRINTF("SHR\t");
9569 DECODE_PRINTF("SAL\t");
9572 DECODE_PRINTF("SAR\t");
9577 /* know operation, decode the mod byte to find the addressing
9581 if (M
.x86
.mode
& SYSMODE_PREFIX_DATA
) {
9584 DECODE_PRINTF("DWORD PTR ");
9585 destoffset
= decode_rm00_address(rl
);
9586 DECODE_PRINTF(",1\n");
9587 destval
= fetch_data_long(destoffset
);
9589 destval
= (*opcD1_long_operation
[rh
]) (destval
, 1);
9590 store_data_long(destoffset
, destval
);
9595 DECODE_PRINTF("WORD PTR ");
9596 destoffset
= decode_rm00_address(rl
);
9597 DECODE_PRINTF(",1\n");
9598 destval
= fetch_data_word(destoffset
);
9600 destval
= (*opcD1_word_operation
[rh
]) (destval
, 1);
9601 store_data_word(destoffset
, destval
);
9605 if (M
.x86
.mode
& SYSMODE_PREFIX_DATA
) {
9608 DECODE_PRINTF("DWORD PTR ");
9609 destoffset
= decode_rm01_address(rl
);
9610 DECODE_PRINTF(",1\n");
9611 destval
= fetch_data_long(destoffset
);
9613 destval
= (*opcD1_long_operation
[rh
]) (destval
, 1);
9614 store_data_long(destoffset
, destval
);
9619 DECODE_PRINTF("WORD PTR ");
9620 destoffset
= decode_rm01_address(rl
);
9621 DECODE_PRINTF(",1\n");
9622 destval
= fetch_data_word(destoffset
);
9624 destval
= (*opcD1_word_operation
[rh
]) (destval
, 1);
9625 store_data_word(destoffset
, destval
);
9629 if (M
.x86
.mode
& SYSMODE_PREFIX_DATA
) {
9632 DECODE_PRINTF("DWORD PTR ");
9633 destoffset
= decode_rm10_address(rl
);
9634 DECODE_PRINTF(",1\n");
9635 destval
= fetch_data_long(destoffset
);
9637 destval
= (*opcD1_long_operation
[rh
]) (destval
, 1);
9638 store_data_long(destoffset
, destval
);
9643 DECODE_PRINTF("BYTE PTR ");
9644 destoffset
= decode_rm10_address(rl
);
9645 DECODE_PRINTF(",1\n");
9646 destval
= fetch_data_word(destoffset
);
9648 destval
= (*opcD1_word_operation
[rh
]) (destval
, 1);
9649 store_data_word(destoffset
, destval
);
9652 case 3: /* register to register */
9653 if (M
.x86
.mode
& SYSMODE_PREFIX_DATA
) {
9657 destreg
= DECODE_RM_LONG_REGISTER(rl
);
9658 DECODE_PRINTF(",1\n");
9660 destval
= (*opcD1_long_operation
[rh
]) (*destreg
, 1);
9667 destreg
= DECODE_RM_WORD_REGISTER(rl
);
9668 DECODE_PRINTF(",1\n");
9670 destval
= (*opcD1_word_operation
[rh
]) (*destreg
, 1);
9675 DECODE_CLEAR_SEGOVR();
9679 /****************************************************************************
9682 ****************************************************************************/
9684 x86emuOp_opcD2_byte_RM_CL(u8
X86EMU_UNUSED(op1
))
9693 * Yet another weirdo special case instruction format. Part of
9694 * the opcode held below in "RH". Doubly nested case would
9695 * result, except that the decoded instruction
9698 FETCH_DECODE_MODRM(mod
, rh
, rl
);
9700 if (DEBUG_DECODE()) {
9701 /* XXX DECODE_PRINTF may be changed to something more
9702 general, so that it is important to leave the strings
9703 in the same format, even though the result is that the
9704 above test is done twice. */
9707 DECODE_PRINTF("ROL\t");
9710 DECODE_PRINTF("ROR\t");
9713 DECODE_PRINTF("RCL\t");
9716 DECODE_PRINTF("RCR\t");
9719 DECODE_PRINTF("SHL\t");
9722 DECODE_PRINTF("SHR\t");
9725 DECODE_PRINTF("SAL\t");
9728 DECODE_PRINTF("SAR\t");
9733 /* know operation, decode the mod byte to find the addressing
9738 DECODE_PRINTF("BYTE PTR ");
9739 destoffset
= decode_rm00_address(rl
);
9740 DECODE_PRINTF(",CL\n");
9741 destval
= fetch_data_byte(destoffset
);
9743 destval
= (*opcD0_byte_operation
[rh
]) (destval
, amt
);
9744 store_data_byte(destoffset
, destval
);
9747 DECODE_PRINTF("BYTE PTR ");
9748 destoffset
= decode_rm01_address(rl
);
9749 DECODE_PRINTF(",CL\n");
9750 destval
= fetch_data_byte(destoffset
);
9752 destval
= (*opcD0_byte_operation
[rh
]) (destval
, amt
);
9753 store_data_byte(destoffset
, destval
);
9756 DECODE_PRINTF("BYTE PTR ");
9757 destoffset
= decode_rm10_address(rl
);
9758 DECODE_PRINTF(",CL\n");
9759 destval
= fetch_data_byte(destoffset
);
9761 destval
= (*opcD0_byte_operation
[rh
]) (destval
, amt
);
9762 store_data_byte(destoffset
, destval
);
9764 case 3: /* register to register */
9765 destreg
= DECODE_RM_BYTE_REGISTER(rl
);
9766 DECODE_PRINTF(",CL\n");
9768 destval
= (*opcD0_byte_operation
[rh
]) (*destreg
, amt
);
9772 DECODE_CLEAR_SEGOVR();
9776 /****************************************************************************
9779 ****************************************************************************/
9781 x86emuOp_opcD3_word_RM_CL(u8
X86EMU_UNUSED(op1
))
9788 * Yet another weirdo special case instruction format. Part of
9789 * the opcode held below in "RH". Doubly nested case would
9790 * result, except that the decoded instruction
9793 FETCH_DECODE_MODRM(mod
, rh
, rl
);
9795 if (DEBUG_DECODE()) {
9796 /* XXX DECODE_PRINTF may be changed to something more
9797 general, so that it is important to leave the strings
9798 in the same format, even though the result is that the
9799 above test is done twice. */
9802 DECODE_PRINTF("ROL\t");
9805 DECODE_PRINTF("ROR\t");
9808 DECODE_PRINTF("RCL\t");
9811 DECODE_PRINTF("RCR\t");
9814 DECODE_PRINTF("SHL\t");
9817 DECODE_PRINTF("SHR\t");
9820 DECODE_PRINTF("SAL\t");
9823 DECODE_PRINTF("SAR\t");
9828 /* know operation, decode the mod byte to find the addressing
9833 if (M
.x86
.mode
& SYSMODE_PREFIX_DATA
) {
9836 DECODE_PRINTF("DWORD PTR ");
9837 destoffset
= decode_rm00_address(rl
);
9838 DECODE_PRINTF(",CL\n");
9839 destval
= fetch_data_long(destoffset
);
9841 destval
= (*opcD1_long_operation
[rh
]) (destval
, amt
);
9842 store_data_long(destoffset
, destval
);
9847 DECODE_PRINTF("WORD PTR ");
9848 destoffset
= decode_rm00_address(rl
);
9849 DECODE_PRINTF(",CL\n");
9850 destval
= fetch_data_word(destoffset
);
9852 destval
= (*opcD1_word_operation
[rh
]) (destval
, amt
);
9853 store_data_word(destoffset
, destval
);
9857 if (M
.x86
.mode
& SYSMODE_PREFIX_DATA
) {
9860 DECODE_PRINTF("DWORD PTR ");
9861 destoffset
= decode_rm01_address(rl
);
9862 DECODE_PRINTF(",CL\n");
9863 destval
= fetch_data_long(destoffset
);
9865 destval
= (*opcD1_long_operation
[rh
]) (destval
, amt
);
9866 store_data_long(destoffset
, destval
);
9871 DECODE_PRINTF("WORD PTR ");
9872 destoffset
= decode_rm01_address(rl
);
9873 DECODE_PRINTF(",CL\n");
9874 destval
= fetch_data_word(destoffset
);
9876 destval
= (*opcD1_word_operation
[rh
]) (destval
, amt
);
9877 store_data_word(destoffset
, destval
);
9881 if (M
.x86
.mode
& SYSMODE_PREFIX_DATA
) {
9884 DECODE_PRINTF("DWORD PTR ");
9885 destoffset
= decode_rm10_address(rl
);
9886 DECODE_PRINTF(",CL\n");
9887 destval
= fetch_data_long(destoffset
);
9889 destval
= (*opcD1_long_operation
[rh
]) (destval
, amt
);
9890 store_data_long(destoffset
, destval
);
9895 DECODE_PRINTF("WORD PTR ");
9896 destoffset
= decode_rm10_address(rl
);
9897 DECODE_PRINTF(",CL\n");
9898 destval
= fetch_data_word(destoffset
);
9900 destval
= (*opcD1_word_operation
[rh
]) (destval
, amt
);
9901 store_data_word(destoffset
, destval
);
9904 case 3: /* register to register */
9905 if (M
.x86
.mode
& SYSMODE_PREFIX_DATA
) {
9908 destreg
= DECODE_RM_LONG_REGISTER(rl
);
9909 DECODE_PRINTF(",CL\n");
9911 *destreg
= (*opcD1_long_operation
[rh
]) (*destreg
, amt
);
9916 destreg
= DECODE_RM_WORD_REGISTER(rl
);
9917 DECODE_PRINTF(",CL\n");
9919 *destreg
= (*opcD1_word_operation
[rh
]) (*destreg
, amt
);
9923 DECODE_CLEAR_SEGOVR();
9927 /****************************************************************************
9930 ****************************************************************************/
9932 x86emuOp_aam(u8
X86EMU_UNUSED(op1
))
9937 DECODE_PRINTF("AAM\n");
9938 a
= fetch_byte_imm(); /* this is a stupid encoding. */
9940 /* fix: add base decoding
9941 aam_word(u8 val, int base a) */
9942 DECODE_PRINTF("ERROR DECODING AAM\n");
9947 /* note the type change here --- returning AL and AH in AX. */
9948 M
.x86
.R_AX
= aam_word(M
.x86
.R_AL
);
9949 DECODE_CLEAR_SEGOVR();
9953 /****************************************************************************
9956 ****************************************************************************/
9958 x86emuOp_aad(u8
X86EMU_UNUSED(op1
))
9963 DECODE_PRINTF("AAD\n");
9964 a
= fetch_byte_imm();
9966 /* fix: add base decoding
9967 aad_word(u16 val, int base a) */
9968 DECODE_PRINTF("ERROR DECODING AAM\n");
9973 M
.x86
.R_AX
= aad_word(M
.x86
.R_AX
);
9974 DECODE_CLEAR_SEGOVR();
9978 /* opcode 0xd6 ILLEGAL OPCODE */
9980 /****************************************************************************
9983 ****************************************************************************/
9985 x86emuOp_xlat(u8
X86EMU_UNUSED(op1
))
9990 DECODE_PRINTF("XLAT\n");
9992 addr
= (u16
) (M
.x86
.R_BX
+ (u8
) M
.x86
.R_AL
);
9993 M
.x86
.R_AL
= fetch_data_byte(addr
);
9994 DECODE_CLEAR_SEGOVR();
9998 /* instuctions D8 .. DF are in i87_ops.c */
10000 /****************************************************************************
10002 Handles opcode 0xe0
10003 ****************************************************************************/
10005 x86emuOp_loopne(u8
X86EMU_UNUSED(op1
))
10010 DECODE_PRINTF("LOOPNE\t");
10011 ip
= (s8
) fetch_byte_imm();
10012 ip
+= (s16
) M
.x86
.R_IP
;
10013 DECODE_PRINTF2("%04x\n", ip
);
10016 if (M
.x86
.R_CX
!= 0 && !ACCESS_FLAG(F_ZF
)) /* CX != 0 and !ZF */
10018 DECODE_CLEAR_SEGOVR();
10022 /****************************************************************************
10024 Handles opcode 0xe1
10025 ****************************************************************************/
10027 x86emuOp_loope(u8
X86EMU_UNUSED(op1
))
10032 DECODE_PRINTF("LOOPE\t");
10033 ip
= (s8
) fetch_byte_imm();
10034 ip
+= (s16
) M
.x86
.R_IP
;
10035 DECODE_PRINTF2("%04x\n", ip
);
10038 if (M
.x86
.R_CX
!= 0 && ACCESS_FLAG(F_ZF
)) /* CX != 0 and ZF */
10040 DECODE_CLEAR_SEGOVR();
10044 /****************************************************************************
10046 Handles opcode 0xe2
10047 ****************************************************************************/
10049 x86emuOp_loop(u8
X86EMU_UNUSED(op1
))
10054 DECODE_PRINTF("LOOP\t");
10055 ip
= (s8
) fetch_byte_imm();
10056 ip
+= (s16
) M
.x86
.R_IP
;
10057 DECODE_PRINTF2("%04x\n", ip
);
10060 if (M
.x86
.R_CX
!= 0)
10062 DECODE_CLEAR_SEGOVR();
10066 /****************************************************************************
10068 Handles opcode 0xe3
10069 ****************************************************************************/
10071 x86emuOp_jcxz(u8
X86EMU_UNUSED(op1
))
10076 /* jump to byte offset if overflow flag is set */
10078 DECODE_PRINTF("JCXZ\t");
10079 offset
= (s8
) fetch_byte_imm();
10080 target
= (u16
) (M
.x86
.R_IP
+ offset
);
10081 DECODE_PRINTF2("%x\n", target
);
10083 if (M
.x86
.R_CX
== 0)
10084 M
.x86
.R_IP
= target
;
10085 DECODE_CLEAR_SEGOVR();
10089 /****************************************************************************
10091 Handles opcode 0xe4
10092 ****************************************************************************/
10094 x86emuOp_in_byte_AL_IMM(u8
X86EMU_UNUSED(op1
))
10099 DECODE_PRINTF("IN\t");
10100 port
= (u8
) fetch_byte_imm();
10101 DECODE_PRINTF2("%x,AL\n", port
);
10103 M
.x86
.R_AL
= (*sys_inb
) (port
);
10104 DECODE_CLEAR_SEGOVR();
10108 /****************************************************************************
10110 Handles opcode 0xe5
10111 ****************************************************************************/
10113 x86emuOp_in_word_AX_IMM(u8
X86EMU_UNUSED(op1
))
10118 DECODE_PRINTF("IN\t");
10119 port
= (u8
) fetch_byte_imm();
10120 if (M
.x86
.mode
& SYSMODE_PREFIX_DATA
) {
10121 DECODE_PRINTF2("EAX,%x\n", port
);
10124 DECODE_PRINTF2("AX,%x\n", port
);
10127 if (M
.x86
.mode
& SYSMODE_PREFIX_DATA
) {
10128 M
.x86
.R_EAX
= (*sys_inl
) (port
);
10131 M
.x86
.R_AX
= (*sys_inw
) (port
);
10133 DECODE_CLEAR_SEGOVR();
10137 /****************************************************************************
10139 Handles opcode 0xe6
10140 ****************************************************************************/
10142 x86emuOp_out_byte_IMM_AL(u8
X86EMU_UNUSED(op1
))
10147 DECODE_PRINTF("OUT\t");
10148 port
= (u8
) fetch_byte_imm();
10149 DECODE_PRINTF2("%x,AL\n", port
);
10151 (*sys_outb
) (port
, M
.x86
.R_AL
);
10152 DECODE_CLEAR_SEGOVR();
10156 /****************************************************************************
10158 Handles opcode 0xe7
10159 ****************************************************************************/
10161 x86emuOp_out_word_IMM_AX(u8
X86EMU_UNUSED(op1
))
10166 DECODE_PRINTF("OUT\t");
10167 port
= (u8
) fetch_byte_imm();
10168 if (M
.x86
.mode
& SYSMODE_PREFIX_DATA
) {
10169 DECODE_PRINTF2("%x,EAX\n", port
);
10172 DECODE_PRINTF2("%x,AX\n", port
);
10175 if (M
.x86
.mode
& SYSMODE_PREFIX_DATA
) {
10176 (*sys_outl
) (port
, M
.x86
.R_EAX
);
10179 (*sys_outw
) (port
, M
.x86
.R_AX
);
10181 DECODE_CLEAR_SEGOVR();
10185 /****************************************************************************
10187 Handles opcode 0xe8
10188 ****************************************************************************/
10190 x86emuOp_call_near_IMM(u8
X86EMU_UNUSED(op1
))
10196 DECODE_PRINTF("CALL\t");
10197 if (M
.x86
.mode
& SYSMODE_PREFIX_DATA
) {
10198 ip32
= (s32
) fetch_long_imm();
10199 ip32
+= (s16
) M
.x86
.R_IP
; /* CHECK SIGN */
10200 DECODE_PRINTF2("%04x\n", (u16
) ip32
);
10201 CALL_TRACE(M
.x86
.saved_cs
, M
.x86
.saved_ip
, M
.x86
.R_CS
, ip32
, "");
10204 ip16
= (s16
) fetch_word_imm();
10205 ip16
+= (s16
) M
.x86
.R_IP
; /* CHECK SIGN */
10206 DECODE_PRINTF2("%04x\n", (u16
) ip16
);
10207 CALL_TRACE(M
.x86
.saved_cs
, M
.x86
.saved_ip
, M
.x86
.R_CS
, ip16
, "");
10210 if (M
.x86
.mode
& SYSMODE_PREFIX_DATA
) {
10211 push_long(M
.x86
.R_EIP
);
10212 M
.x86
.R_EIP
= ip32
& 0xffff;
10215 push_word(M
.x86
.R_IP
);
10216 M
.x86
.R_EIP
= ip16
;
10218 DECODE_CLEAR_SEGOVR();
10222 /****************************************************************************
10224 Handles opcode 0xe9
10225 ****************************************************************************/
10227 x86emuOp_jump_near_IMM(u8
X86EMU_UNUSED(op1
))
10232 DECODE_PRINTF("JMP\t");
10233 if (M
.x86
.mode
& SYSMODE_PREFIX_DATA
) {
10234 ip
= (u32
) fetch_long_imm();
10235 ip
+= (u32
) M
.x86
.R_EIP
;
10236 DECODE_PRINTF2("%08x\n", (u32
) ip
);
10238 M
.x86
.R_EIP
= (u32
) ip
;
10241 ip
= (s16
) fetch_word_imm();
10242 ip
+= (s16
) M
.x86
.R_IP
;
10243 DECODE_PRINTF2("%04x\n", (u16
) ip
);
10245 M
.x86
.R_IP
= (u16
) ip
;
10247 DECODE_CLEAR_SEGOVR();
10251 /****************************************************************************
10253 Handles opcode 0xea
10254 ****************************************************************************/
10256 x86emuOp_jump_far_IMM(u8
X86EMU_UNUSED(op1
))
10262 DECODE_PRINTF("JMP\tFAR ");
10263 if (M
.x86
.mode
& SYSMODE_PREFIX_DATA
) {
10264 ip
= fetch_long_imm();
10267 ip
= fetch_word_imm();
10269 cs
= fetch_word_imm();
10270 DECODE_PRINTF2("%04x:", cs
);
10271 DECODE_PRINTF2("%04x\n", ip
);
10273 M
.x86
.R_EIP
= ip
& 0xffff;
10275 DECODE_CLEAR_SEGOVR();
10279 /****************************************************************************
10281 Handles opcode 0xeb
10282 ****************************************************************************/
10284 x86emuOp_jump_byte_IMM(u8
X86EMU_UNUSED(op1
))
10290 DECODE_PRINTF("JMP\t");
10291 offset
= (s8
) fetch_byte_imm();
10292 target
= (u16
) (M
.x86
.R_IP
+ offset
);
10293 DECODE_PRINTF2("%x\n", target
);
10295 M
.x86
.R_IP
= target
;
10296 DECODE_CLEAR_SEGOVR();
10300 /****************************************************************************
10302 Handles opcode 0xec
10303 ****************************************************************************/
10305 x86emuOp_in_byte_AL_DX(u8
X86EMU_UNUSED(op1
))
10308 DECODE_PRINTF("IN\tAL,DX\n");
10310 M
.x86
.R_AL
= (*sys_inb
) (M
.x86
.R_DX
);
10311 DECODE_CLEAR_SEGOVR();
10315 /****************************************************************************
10317 Handles opcode 0xed
10318 ****************************************************************************/
10320 x86emuOp_in_word_AX_DX(u8
X86EMU_UNUSED(op1
))
10323 if (M
.x86
.mode
& SYSMODE_PREFIX_DATA
) {
10324 DECODE_PRINTF("IN\tEAX,DX\n");
10327 DECODE_PRINTF("IN\tAX,DX\n");
10330 if (M
.x86
.mode
& SYSMODE_PREFIX_DATA
) {
10331 M
.x86
.R_EAX
= (*sys_inl
) (M
.x86
.R_DX
);
10334 M
.x86
.R_AX
= (*sys_inw
) (M
.x86
.R_DX
);
10336 DECODE_CLEAR_SEGOVR();
10340 /****************************************************************************
10342 Handles opcode 0xee
10343 ****************************************************************************/
10345 x86emuOp_out_byte_DX_AL(u8
X86EMU_UNUSED(op1
))
10348 DECODE_PRINTF("OUT\tDX,AL\n");
10350 (*sys_outb
) (M
.x86
.R_DX
, M
.x86
.R_AL
);
10351 DECODE_CLEAR_SEGOVR();
10355 /****************************************************************************
10357 Handles opcode 0xef
10358 ****************************************************************************/
10360 x86emuOp_out_word_DX_AX(u8
X86EMU_UNUSED(op1
))
10363 if (M
.x86
.mode
& SYSMODE_PREFIX_DATA
) {
10364 DECODE_PRINTF("OUT\tDX,EAX\n");
10367 DECODE_PRINTF("OUT\tDX,AX\n");
10370 if (M
.x86
.mode
& SYSMODE_PREFIX_DATA
) {
10371 (*sys_outl
) (M
.x86
.R_DX
, M
.x86
.R_EAX
);
10374 (*sys_outw
) (M
.x86
.R_DX
, M
.x86
.R_AX
);
10376 DECODE_CLEAR_SEGOVR();
10380 /****************************************************************************
10382 Handles opcode 0xf0
10383 ****************************************************************************/
10385 x86emuOp_lock(u8
X86EMU_UNUSED(op1
))
10388 DECODE_PRINTF("LOCK:\n");
10390 DECODE_CLEAR_SEGOVR();
10394 /*opcode 0xf1 ILLEGAL OPERATION */
10396 /****************************************************************************
10398 Handles opcode 0xf2
10399 ****************************************************************************/
10401 x86emuOp_repne(u8
X86EMU_UNUSED(op1
))
10404 DECODE_PRINTF("REPNE\n");
10406 M
.x86
.mode
|= SYSMODE_PREFIX_REPNE
;
10407 DECODE_CLEAR_SEGOVR();
10411 /****************************************************************************
10413 Handles opcode 0xf3
10414 ****************************************************************************/
10416 x86emuOp_repe(u8
X86EMU_UNUSED(op1
))
10419 DECODE_PRINTF("REPE\n");
10421 M
.x86
.mode
|= SYSMODE_PREFIX_REPE
;
10422 DECODE_CLEAR_SEGOVR();
10426 /****************************************************************************
10428 Handles opcode 0xf4
10429 ****************************************************************************/
10431 x86emuOp_halt(u8
X86EMU_UNUSED(op1
))
10434 DECODE_PRINTF("HALT\n");
10437 DECODE_CLEAR_SEGOVR();
10441 /****************************************************************************
10443 Handles opcode 0xf5
10444 ****************************************************************************/
10446 x86emuOp_cmc(u8
X86EMU_UNUSED(op1
))
10448 /* complement the carry flag. */
10450 DECODE_PRINTF("CMC\n");
10453 DECODE_CLEAR_SEGOVR();
10457 /****************************************************************************
10459 Handles opcode 0xf6
10460 ****************************************************************************/
10462 x86emuOp_opcF6_byte_RM(u8
X86EMU_UNUSED(op1
))
10467 u8 destval
, srcval
;
10469 /* long, drawn out code follows. Double switch for a total
10472 FETCH_DECODE_MODRM(mod
, rh
, rl
);
10474 case 0: /* mod=00 */
10476 case 0: /* test byte imm */
10477 DECODE_PRINTF("TEST\tBYTE PTR ");
10478 destoffset
= decode_rm00_address(rl
);
10479 DECODE_PRINTF(",");
10480 srcval
= fetch_byte_imm();
10481 DECODE_PRINTF2("%02x\n", srcval
);
10482 destval
= fetch_data_byte(destoffset
);
10484 test_byte(destval
, srcval
);
10487 DECODE_PRINTF("ILLEGAL OP MOD=00 RH=01 OP=F6\n");
10491 DECODE_PRINTF("NOT\tBYTE PTR ");
10492 destoffset
= decode_rm00_address(rl
);
10493 DECODE_PRINTF("\n");
10494 destval
= fetch_data_byte(destoffset
);
10496 destval
= not_byte(destval
);
10497 store_data_byte(destoffset
, destval
);
10500 DECODE_PRINTF("NEG\tBYTE PTR ");
10501 destoffset
= decode_rm00_address(rl
);
10502 DECODE_PRINTF("\n");
10503 destval
= fetch_data_byte(destoffset
);
10505 destval
= neg_byte(destval
);
10506 store_data_byte(destoffset
, destval
);
10509 DECODE_PRINTF("MUL\tBYTE PTR ");
10510 destoffset
= decode_rm00_address(rl
);
10511 DECODE_PRINTF("\n");
10512 destval
= fetch_data_byte(destoffset
);
10517 DECODE_PRINTF("IMUL\tBYTE PTR ");
10518 destoffset
= decode_rm00_address(rl
);
10519 DECODE_PRINTF("\n");
10520 destval
= fetch_data_byte(destoffset
);
10522 imul_byte(destval
);
10525 DECODE_PRINTF("DIV\tBYTE PTR ");
10526 destoffset
= decode_rm00_address(rl
);
10527 DECODE_PRINTF("\n");
10528 destval
= fetch_data_byte(destoffset
);
10533 DECODE_PRINTF("IDIV\tBYTE PTR ");
10534 destoffset
= decode_rm00_address(rl
);
10535 DECODE_PRINTF("\n");
10536 destval
= fetch_data_byte(destoffset
);
10538 idiv_byte(destval
);
10541 break; /* end mod==00 */
10542 case 1: /* mod=01 */
10544 case 0: /* test byte imm */
10545 DECODE_PRINTF("TEST\tBYTE PTR ");
10546 destoffset
= decode_rm01_address(rl
);
10547 DECODE_PRINTF(",");
10548 srcval
= fetch_byte_imm();
10549 DECODE_PRINTF2("%02x\n", srcval
);
10550 destval
= fetch_data_byte(destoffset
);
10552 test_byte(destval
, srcval
);
10555 DECODE_PRINTF("ILLEGAL OP MOD=01 RH=01 OP=F6\n");
10559 DECODE_PRINTF("NOT\tBYTE PTR ");
10560 destoffset
= decode_rm01_address(rl
);
10561 DECODE_PRINTF("\n");
10562 destval
= fetch_data_byte(destoffset
);
10564 destval
= not_byte(destval
);
10565 store_data_byte(destoffset
, destval
);
10568 DECODE_PRINTF("NEG\tBYTE PTR ");
10569 destoffset
= decode_rm01_address(rl
);
10570 DECODE_PRINTF("\n");
10571 destval
= fetch_data_byte(destoffset
);
10573 destval
= neg_byte(destval
);
10574 store_data_byte(destoffset
, destval
);
10577 DECODE_PRINTF("MUL\tBYTE PTR ");
10578 destoffset
= decode_rm01_address(rl
);
10579 DECODE_PRINTF("\n");
10580 destval
= fetch_data_byte(destoffset
);
10585 DECODE_PRINTF("IMUL\tBYTE PTR ");
10586 destoffset
= decode_rm01_address(rl
);
10587 DECODE_PRINTF("\n");
10588 destval
= fetch_data_byte(destoffset
);
10590 imul_byte(destval
);
10593 DECODE_PRINTF("DIV\tBYTE PTR ");
10594 destoffset
= decode_rm01_address(rl
);
10595 DECODE_PRINTF("\n");
10596 destval
= fetch_data_byte(destoffset
);
10601 DECODE_PRINTF("IDIV\tBYTE PTR ");
10602 destoffset
= decode_rm01_address(rl
);
10603 DECODE_PRINTF("\n");
10604 destval
= fetch_data_byte(destoffset
);
10606 idiv_byte(destval
);
10609 break; /* end mod==01 */
10610 case 2: /* mod=10 */
10612 case 0: /* test byte imm */
10613 DECODE_PRINTF("TEST\tBYTE PTR ");
10614 destoffset
= decode_rm10_address(rl
);
10615 DECODE_PRINTF(",");
10616 srcval
= fetch_byte_imm();
10617 DECODE_PRINTF2("%02x\n", srcval
);
10618 destval
= fetch_data_byte(destoffset
);
10620 test_byte(destval
, srcval
);
10623 DECODE_PRINTF("ILLEGAL OP MOD=10 RH=01 OP=F6\n");
10627 DECODE_PRINTF("NOT\tBYTE PTR ");
10628 destoffset
= decode_rm10_address(rl
);
10629 DECODE_PRINTF("\n");
10630 destval
= fetch_data_byte(destoffset
);
10632 destval
= not_byte(destval
);
10633 store_data_byte(destoffset
, destval
);
10636 DECODE_PRINTF("NEG\tBYTE PTR ");
10637 destoffset
= decode_rm10_address(rl
);
10638 DECODE_PRINTF("\n");
10639 destval
= fetch_data_byte(destoffset
);
10641 destval
= neg_byte(destval
);
10642 store_data_byte(destoffset
, destval
);
10645 DECODE_PRINTF("MUL\tBYTE PTR ");
10646 destoffset
= decode_rm10_address(rl
);
10647 DECODE_PRINTF("\n");
10648 destval
= fetch_data_byte(destoffset
);
10653 DECODE_PRINTF("IMUL\tBYTE PTR ");
10654 destoffset
= decode_rm10_address(rl
);
10655 DECODE_PRINTF("\n");
10656 destval
= fetch_data_byte(destoffset
);
10658 imul_byte(destval
);
10661 DECODE_PRINTF("DIV\tBYTE PTR ");
10662 destoffset
= decode_rm10_address(rl
);
10663 DECODE_PRINTF("\n");
10664 destval
= fetch_data_byte(destoffset
);
10669 DECODE_PRINTF("IDIV\tBYTE PTR ");
10670 destoffset
= decode_rm10_address(rl
);
10671 DECODE_PRINTF("\n");
10672 destval
= fetch_data_byte(destoffset
);
10674 idiv_byte(destval
);
10677 break; /* end mod==10 */
10678 case 3: /* mod=11 */
10680 case 0: /* test byte imm */
10681 DECODE_PRINTF("TEST\t");
10682 destreg
= DECODE_RM_BYTE_REGISTER(rl
);
10683 DECODE_PRINTF(",");
10684 srcval
= fetch_byte_imm();
10685 DECODE_PRINTF2("%02x\n", srcval
);
10687 test_byte(*destreg
, srcval
);
10690 DECODE_PRINTF("ILLEGAL OP MOD=00 RH=01 OP=F6\n");
10694 DECODE_PRINTF("NOT\t");
10695 destreg
= DECODE_RM_BYTE_REGISTER(rl
);
10696 DECODE_PRINTF("\n");
10698 *destreg
= not_byte(*destreg
);
10701 DECODE_PRINTF("NEG\t");
10702 destreg
= DECODE_RM_BYTE_REGISTER(rl
);
10703 DECODE_PRINTF("\n");
10705 *destreg
= neg_byte(*destreg
);
10708 DECODE_PRINTF("MUL\t");
10709 destreg
= DECODE_RM_BYTE_REGISTER(rl
);
10710 DECODE_PRINTF("\n");
10712 mul_byte(*destreg
); /*!!! */
10715 DECODE_PRINTF("IMUL\t");
10716 destreg
= DECODE_RM_BYTE_REGISTER(rl
);
10717 DECODE_PRINTF("\n");
10719 imul_byte(*destreg
);
10722 DECODE_PRINTF("DIV\t");
10723 destreg
= DECODE_RM_BYTE_REGISTER(rl
);
10724 DECODE_PRINTF("\n");
10726 div_byte(*destreg
);
10729 DECODE_PRINTF("IDIV\t");
10730 destreg
= DECODE_RM_BYTE_REGISTER(rl
);
10731 DECODE_PRINTF("\n");
10733 idiv_byte(*destreg
);
10736 break; /* end mod==11 */
10738 DECODE_CLEAR_SEGOVR();
10742 /****************************************************************************
10744 Handles opcode 0xf7
10745 ****************************************************************************/
10747 x86emuOp_opcF7_word_RM(u8
X86EMU_UNUSED(op1
))
10752 /* long, drawn out code follows. Double switch for a total
10755 FETCH_DECODE_MODRM(mod
, rh
, rl
);
10757 case 0: /* mod=00 */
10759 case 0: /* test word imm */
10760 if (M
.x86
.mode
& SYSMODE_PREFIX_DATA
) {
10761 u32 destval
, srcval
;
10763 DECODE_PRINTF("TEST\tDWORD PTR ");
10764 destoffset
= decode_rm00_address(rl
);
10765 DECODE_PRINTF(",");
10766 srcval
= fetch_long_imm();
10767 DECODE_PRINTF2("%x\n", srcval
);
10768 destval
= fetch_data_long(destoffset
);
10770 test_long(destval
, srcval
);
10773 u16 destval
, srcval
;
10775 DECODE_PRINTF("TEST\tWORD PTR ");
10776 destoffset
= decode_rm00_address(rl
);
10777 DECODE_PRINTF(",");
10778 srcval
= fetch_word_imm();
10779 DECODE_PRINTF2("%x\n", srcval
);
10780 destval
= fetch_data_word(destoffset
);
10782 test_word(destval
, srcval
);
10786 DECODE_PRINTF("ILLEGAL OP MOD=00 RH=01 OP=F7\n");
10790 if (M
.x86
.mode
& SYSMODE_PREFIX_DATA
) {
10793 DECODE_PRINTF("NOT\tDWORD PTR ");
10794 destoffset
= decode_rm00_address(rl
);
10795 DECODE_PRINTF("\n");
10796 destval
= fetch_data_long(destoffset
);
10798 destval
= not_long(destval
);
10799 store_data_long(destoffset
, destval
);
10804 DECODE_PRINTF("NOT\tWORD PTR ");
10805 destoffset
= decode_rm00_address(rl
);
10806 DECODE_PRINTF("\n");
10807 destval
= fetch_data_word(destoffset
);
10809 destval
= not_word(destval
);
10810 store_data_word(destoffset
, destval
);
10814 if (M
.x86
.mode
& SYSMODE_PREFIX_DATA
) {
10817 DECODE_PRINTF("NEG\tDWORD PTR ");
10818 destoffset
= decode_rm00_address(rl
);
10819 DECODE_PRINTF("\n");
10820 destval
= fetch_data_long(destoffset
);
10822 destval
= neg_long(destval
);
10823 store_data_long(destoffset
, destval
);
10828 DECODE_PRINTF("NEG\tWORD PTR ");
10829 destoffset
= decode_rm00_address(rl
);
10830 DECODE_PRINTF("\n");
10831 destval
= fetch_data_word(destoffset
);
10833 destval
= neg_word(destval
);
10834 store_data_word(destoffset
, destval
);
10838 if (M
.x86
.mode
& SYSMODE_PREFIX_DATA
) {
10841 DECODE_PRINTF("MUL\tDWORD PTR ");
10842 destoffset
= decode_rm00_address(rl
);
10843 DECODE_PRINTF("\n");
10844 destval
= fetch_data_long(destoffset
);
10851 DECODE_PRINTF("MUL\tWORD PTR ");
10852 destoffset
= decode_rm00_address(rl
);
10853 DECODE_PRINTF("\n");
10854 destval
= fetch_data_word(destoffset
);
10860 if (M
.x86
.mode
& SYSMODE_PREFIX_DATA
) {
10863 DECODE_PRINTF("IMUL\tDWORD PTR ");
10864 destoffset
= decode_rm00_address(rl
);
10865 DECODE_PRINTF("\n");
10866 destval
= fetch_data_long(destoffset
);
10868 imul_long(destval
);
10873 DECODE_PRINTF("IMUL\tWORD PTR ");
10874 destoffset
= decode_rm00_address(rl
);
10875 DECODE_PRINTF("\n");
10876 destval
= fetch_data_word(destoffset
);
10878 imul_word(destval
);
10882 if (M
.x86
.mode
& SYSMODE_PREFIX_DATA
) {
10885 DECODE_PRINTF("DIV\tDWORD PTR ");
10886 destoffset
= decode_rm00_address(rl
);
10887 DECODE_PRINTF("\n");
10888 destval
= fetch_data_long(destoffset
);
10895 DECODE_PRINTF("DIV\tWORD PTR ");
10896 destoffset
= decode_rm00_address(rl
);
10897 DECODE_PRINTF("\n");
10898 destval
= fetch_data_word(destoffset
);
10904 if (M
.x86
.mode
& SYSMODE_PREFIX_DATA
) {
10907 DECODE_PRINTF("IDIV\tDWORD PTR ");
10908 destoffset
= decode_rm00_address(rl
);
10909 DECODE_PRINTF("\n");
10910 destval
= fetch_data_long(destoffset
);
10912 idiv_long(destval
);
10917 DECODE_PRINTF("IDIV\tWORD PTR ");
10918 destoffset
= decode_rm00_address(rl
);
10919 DECODE_PRINTF("\n");
10920 destval
= fetch_data_word(destoffset
);
10922 idiv_word(destval
);
10926 break; /* end mod==00 */
10927 case 1: /* mod=01 */
10929 case 0: /* test word imm */
10930 if (M
.x86
.mode
& SYSMODE_PREFIX_DATA
) {
10931 u32 destval
, srcval
;
10933 DECODE_PRINTF("TEST\tDWORD PTR ");
10934 destoffset
= decode_rm01_address(rl
);
10935 DECODE_PRINTF(",");
10936 srcval
= fetch_long_imm();
10937 DECODE_PRINTF2("%x\n", srcval
);
10938 destval
= fetch_data_long(destoffset
);
10940 test_long(destval
, srcval
);
10943 u16 destval
, srcval
;
10945 DECODE_PRINTF("TEST\tWORD PTR ");
10946 destoffset
= decode_rm01_address(rl
);
10947 DECODE_PRINTF(",");
10948 srcval
= fetch_word_imm();
10949 DECODE_PRINTF2("%x\n", srcval
);
10950 destval
= fetch_data_word(destoffset
);
10952 test_word(destval
, srcval
);
10956 DECODE_PRINTF("ILLEGAL OP MOD=01 RH=01 OP=F6\n");
10960 if (M
.x86
.mode
& SYSMODE_PREFIX_DATA
) {
10963 DECODE_PRINTF("NOT\tDWORD PTR ");
10964 destoffset
= decode_rm01_address(rl
);
10965 DECODE_PRINTF("\n");
10966 destval
= fetch_data_long(destoffset
);
10968 destval
= not_long(destval
);
10969 store_data_long(destoffset
, destval
);
10974 DECODE_PRINTF("NOT\tWORD PTR ");
10975 destoffset
= decode_rm01_address(rl
);
10976 DECODE_PRINTF("\n");
10977 destval
= fetch_data_word(destoffset
);
10979 destval
= not_word(destval
);
10980 store_data_word(destoffset
, destval
);
10984 if (M
.x86
.mode
& SYSMODE_PREFIX_DATA
) {
10987 DECODE_PRINTF("NEG\tDWORD PTR ");
10988 destoffset
= decode_rm01_address(rl
);
10989 DECODE_PRINTF("\n");
10990 destval
= fetch_data_long(destoffset
);
10992 destval
= neg_long(destval
);
10993 store_data_long(destoffset
, destval
);
10998 DECODE_PRINTF("NEG\tWORD PTR ");
10999 destoffset
= decode_rm01_address(rl
);
11000 DECODE_PRINTF("\n");
11001 destval
= fetch_data_word(destoffset
);
11003 destval
= neg_word(destval
);
11004 store_data_word(destoffset
, destval
);
11008 if (M
.x86
.mode
& SYSMODE_PREFIX_DATA
) {
11011 DECODE_PRINTF("MUL\tDWORD PTR ");
11012 destoffset
= decode_rm01_address(rl
);
11013 DECODE_PRINTF("\n");
11014 destval
= fetch_data_long(destoffset
);
11021 DECODE_PRINTF("MUL\tWORD PTR ");
11022 destoffset
= decode_rm01_address(rl
);
11023 DECODE_PRINTF("\n");
11024 destval
= fetch_data_word(destoffset
);
11030 if (M
.x86
.mode
& SYSMODE_PREFIX_DATA
) {
11033 DECODE_PRINTF("IMUL\tDWORD PTR ");
11034 destoffset
= decode_rm01_address(rl
);
11035 DECODE_PRINTF("\n");
11036 destval
= fetch_data_long(destoffset
);
11038 imul_long(destval
);
11043 DECODE_PRINTF("IMUL\tWORD PTR ");
11044 destoffset
= decode_rm01_address(rl
);
11045 DECODE_PRINTF("\n");
11046 destval
= fetch_data_word(destoffset
);
11048 imul_word(destval
);
11052 if (M
.x86
.mode
& SYSMODE_PREFIX_DATA
) {
11055 DECODE_PRINTF("DIV\tDWORD PTR ");
11056 destoffset
= decode_rm01_address(rl
);
11057 DECODE_PRINTF("\n");
11058 destval
= fetch_data_long(destoffset
);
11065 DECODE_PRINTF("DIV\tWORD PTR ");
11066 destoffset
= decode_rm01_address(rl
);
11067 DECODE_PRINTF("\n");
11068 destval
= fetch_data_word(destoffset
);
11074 if (M
.x86
.mode
& SYSMODE_PREFIX_DATA
) {
11077 DECODE_PRINTF("IDIV\tDWORD PTR ");
11078 destoffset
= decode_rm01_address(rl
);
11079 DECODE_PRINTF("\n");
11080 destval
= fetch_data_long(destoffset
);
11082 idiv_long(destval
);
11087 DECODE_PRINTF("IDIV\tWORD PTR ");
11088 destoffset
= decode_rm01_address(rl
);
11089 DECODE_PRINTF("\n");
11090 destval
= fetch_data_word(destoffset
);
11092 idiv_word(destval
);
11096 break; /* end mod==01 */
11097 case 2: /* mod=10 */
11099 case 0: /* test word imm */
11100 if (M
.x86
.mode
& SYSMODE_PREFIX_DATA
) {
11101 u32 destval
, srcval
;
11103 DECODE_PRINTF("TEST\tDWORD PTR ");
11104 destoffset
= decode_rm10_address(rl
);
11105 DECODE_PRINTF(",");
11106 srcval
= fetch_long_imm();
11107 DECODE_PRINTF2("%x\n", srcval
);
11108 destval
= fetch_data_long(destoffset
);
11110 test_long(destval
, srcval
);
11113 u16 destval
, srcval
;
11115 DECODE_PRINTF("TEST\tWORD PTR ");
11116 destoffset
= decode_rm10_address(rl
);
11117 DECODE_PRINTF(",");
11118 srcval
= fetch_word_imm();
11119 DECODE_PRINTF2("%x\n", srcval
);
11120 destval
= fetch_data_word(destoffset
);
11122 test_word(destval
, srcval
);
11126 DECODE_PRINTF("ILLEGAL OP MOD=10 RH=01 OP=F6\n");
11130 if (M
.x86
.mode
& SYSMODE_PREFIX_DATA
) {
11133 DECODE_PRINTF("NOT\tDWORD PTR ");
11134 destoffset
= decode_rm10_address(rl
);
11135 DECODE_PRINTF("\n");
11136 destval
= fetch_data_long(destoffset
);
11138 destval
= not_long(destval
);
11139 store_data_long(destoffset
, destval
);
11144 DECODE_PRINTF("NOT\tWORD PTR ");
11145 destoffset
= decode_rm10_address(rl
);
11146 DECODE_PRINTF("\n");
11147 destval
= fetch_data_word(destoffset
);
11149 destval
= not_word(destval
);
11150 store_data_word(destoffset
, destval
);
11154 if (M
.x86
.mode
& SYSMODE_PREFIX_DATA
) {
11157 DECODE_PRINTF("NEG\tDWORD PTR ");
11158 destoffset
= decode_rm10_address(rl
);
11159 DECODE_PRINTF("\n");
11160 destval
= fetch_data_long(destoffset
);
11162 destval
= neg_long(destval
);
11163 store_data_long(destoffset
, destval
);
11168 DECODE_PRINTF("NEG\tWORD PTR ");
11169 destoffset
= decode_rm10_address(rl
);
11170 DECODE_PRINTF("\n");
11171 destval
= fetch_data_word(destoffset
);
11173 destval
= neg_word(destval
);
11174 store_data_word(destoffset
, destval
);
11178 if (M
.x86
.mode
& SYSMODE_PREFIX_DATA
) {
11181 DECODE_PRINTF("MUL\tDWORD PTR ");
11182 destoffset
= decode_rm10_address(rl
);
11183 DECODE_PRINTF("\n");
11184 destval
= fetch_data_long(destoffset
);
11191 DECODE_PRINTF("MUL\tWORD PTR ");
11192 destoffset
= decode_rm10_address(rl
);
11193 DECODE_PRINTF("\n");
11194 destval
= fetch_data_word(destoffset
);
11200 if (M
.x86
.mode
& SYSMODE_PREFIX_DATA
) {
11203 DECODE_PRINTF("IMUL\tDWORD PTR ");
11204 destoffset
= decode_rm10_address(rl
);
11205 DECODE_PRINTF("\n");
11206 destval
= fetch_data_long(destoffset
);
11208 imul_long(destval
);
11213 DECODE_PRINTF("IMUL\tWORD PTR ");
11214 destoffset
= decode_rm10_address(rl
);
11215 DECODE_PRINTF("\n");
11216 destval
= fetch_data_word(destoffset
);
11218 imul_word(destval
);
11222 if (M
.x86
.mode
& SYSMODE_PREFIX_DATA
) {
11225 DECODE_PRINTF("DIV\tDWORD PTR ");
11226 destoffset
= decode_rm10_address(rl
);
11227 DECODE_PRINTF("\n");
11228 destval
= fetch_data_long(destoffset
);
11235 DECODE_PRINTF("DIV\tWORD PTR ");
11236 destoffset
= decode_rm10_address(rl
);
11237 DECODE_PRINTF("\n");
11238 destval
= fetch_data_word(destoffset
);
11244 if (M
.x86
.mode
& SYSMODE_PREFIX_DATA
) {
11247 DECODE_PRINTF("IDIV\tDWORD PTR ");
11248 destoffset
= decode_rm10_address(rl
);
11249 DECODE_PRINTF("\n");
11250 destval
= fetch_data_long(destoffset
);
11252 idiv_long(destval
);
11257 DECODE_PRINTF("IDIV\tWORD PTR ");
11258 destoffset
= decode_rm10_address(rl
);
11259 DECODE_PRINTF("\n");
11260 destval
= fetch_data_word(destoffset
);
11262 idiv_word(destval
);
11266 break; /* end mod==10 */
11267 case 3: /* mod=11 */
11269 case 0: /* test word imm */
11270 if (M
.x86
.mode
& SYSMODE_PREFIX_DATA
) {
11274 DECODE_PRINTF("TEST\t");
11275 destreg
= DECODE_RM_LONG_REGISTER(rl
);
11276 DECODE_PRINTF(",");
11277 srcval
= fetch_long_imm();
11278 DECODE_PRINTF2("%x\n", srcval
);
11280 test_long(*destreg
, srcval
);
11286 DECODE_PRINTF("TEST\t");
11287 destreg
= DECODE_RM_WORD_REGISTER(rl
);
11288 DECODE_PRINTF(",");
11289 srcval
= fetch_word_imm();
11290 DECODE_PRINTF2("%x\n", srcval
);
11292 test_word(*destreg
, srcval
);
11296 DECODE_PRINTF("ILLEGAL OP MOD=00 RH=01 OP=F6\n");
11300 if (M
.x86
.mode
& SYSMODE_PREFIX_DATA
) {
11303 DECODE_PRINTF("NOT\t");
11304 destreg
= DECODE_RM_LONG_REGISTER(rl
);
11305 DECODE_PRINTF("\n");
11307 *destreg
= not_long(*destreg
);
11312 DECODE_PRINTF("NOT\t");
11313 destreg
= DECODE_RM_WORD_REGISTER(rl
);
11314 DECODE_PRINTF("\n");
11316 *destreg
= not_word(*destreg
);
11320 if (M
.x86
.mode
& SYSMODE_PREFIX_DATA
) {
11323 DECODE_PRINTF("NEG\t");
11324 destreg
= DECODE_RM_LONG_REGISTER(rl
);
11325 DECODE_PRINTF("\n");
11327 *destreg
= neg_long(*destreg
);
11332 DECODE_PRINTF("NEG\t");
11333 destreg
= DECODE_RM_WORD_REGISTER(rl
);
11334 DECODE_PRINTF("\n");
11336 *destreg
= neg_word(*destreg
);
11340 if (M
.x86
.mode
& SYSMODE_PREFIX_DATA
) {
11343 DECODE_PRINTF("MUL\t");
11344 destreg
= DECODE_RM_LONG_REGISTER(rl
);
11345 DECODE_PRINTF("\n");
11347 mul_long(*destreg
); /*!!! */
11352 DECODE_PRINTF("MUL\t");
11353 destreg
= DECODE_RM_WORD_REGISTER(rl
);
11354 DECODE_PRINTF("\n");
11356 mul_word(*destreg
); /*!!! */
11360 if (M
.x86
.mode
& SYSMODE_PREFIX_DATA
) {
11363 DECODE_PRINTF("IMUL\t");
11364 destreg
= DECODE_RM_LONG_REGISTER(rl
);
11365 DECODE_PRINTF("\n");
11367 imul_long(*destreg
);
11372 DECODE_PRINTF("IMUL\t");
11373 destreg
= DECODE_RM_WORD_REGISTER(rl
);
11374 DECODE_PRINTF("\n");
11376 imul_word(*destreg
);
11380 if (M
.x86
.mode
& SYSMODE_PREFIX_DATA
) {
11383 DECODE_PRINTF("DIV\t");
11384 destreg
= DECODE_RM_LONG_REGISTER(rl
);
11385 DECODE_PRINTF("\n");
11387 div_long(*destreg
);
11392 DECODE_PRINTF("DIV\t");
11393 destreg
= DECODE_RM_WORD_REGISTER(rl
);
11394 DECODE_PRINTF("\n");
11396 div_word(*destreg
);
11400 if (M
.x86
.mode
& SYSMODE_PREFIX_DATA
) {
11403 DECODE_PRINTF("IDIV\t");
11404 destreg
= DECODE_RM_LONG_REGISTER(rl
);
11405 DECODE_PRINTF("\n");
11407 idiv_long(*destreg
);
11412 DECODE_PRINTF("IDIV\t");
11413 destreg
= DECODE_RM_WORD_REGISTER(rl
);
11414 DECODE_PRINTF("\n");
11416 idiv_word(*destreg
);
11420 break; /* end mod==11 */
11422 DECODE_CLEAR_SEGOVR();
11426 /****************************************************************************
11428 Handles opcode 0xf8
11429 ****************************************************************************/
11431 x86emuOp_clc(u8
X86EMU_UNUSED(op1
))
11433 /* clear the carry flag. */
11435 DECODE_PRINTF("CLC\n");
11438 DECODE_CLEAR_SEGOVR();
11442 /****************************************************************************
11444 Handles opcode 0xf9
11445 ****************************************************************************/
11447 x86emuOp_stc(u8
X86EMU_UNUSED(op1
))
11449 /* set the carry flag. */
11451 DECODE_PRINTF("STC\n");
11454 DECODE_CLEAR_SEGOVR();
11458 /****************************************************************************
11460 Handles opcode 0xfa
11461 ****************************************************************************/
11463 x86emuOp_cli(u8
X86EMU_UNUSED(op1
))
11465 /* clear interrupts. */
11467 DECODE_PRINTF("CLI\n");
11470 DECODE_CLEAR_SEGOVR();
11474 /****************************************************************************
11476 Handles opcode 0xfb
11477 ****************************************************************************/
11479 x86emuOp_sti(u8
X86EMU_UNUSED(op1
))
11481 /* enable interrupts. */
11483 DECODE_PRINTF("STI\n");
11486 DECODE_CLEAR_SEGOVR();
11490 /****************************************************************************
11492 Handles opcode 0xfc
11493 ****************************************************************************/
11495 x86emuOp_cld(u8
X86EMU_UNUSED(op1
))
11497 /* clear interrupts. */
11499 DECODE_PRINTF("CLD\n");
11502 DECODE_CLEAR_SEGOVR();
11506 /****************************************************************************
11508 Handles opcode 0xfd
11509 ****************************************************************************/
11511 x86emuOp_std(u8
X86EMU_UNUSED(op1
))
11513 /* clear interrupts. */
11515 DECODE_PRINTF("STD\n");
11518 DECODE_CLEAR_SEGOVR();
11522 /****************************************************************************
11524 Handles opcode 0xfe
11525 ****************************************************************************/
11527 x86emuOp_opcFE_byte_RM(u8
X86EMU_UNUSED(op1
))
11534 /* Yet another special case instruction. */
11536 FETCH_DECODE_MODRM(mod
, rh
, rl
);
11538 if (DEBUG_DECODE()) {
11539 /* XXX DECODE_PRINTF may be changed to something more
11540 general, so that it is important to leave the strings
11541 in the same format, even though the result is that the
11542 above test is done twice. */
11546 DECODE_PRINTF("INC\t");
11549 DECODE_PRINTF("DEC\t");
11557 DECODE_PRINTF2("ILLEGAL OP MAJOR OP 0xFE MINOR OP %x \n", mod
);
11565 DECODE_PRINTF("BYTE PTR ");
11566 destoffset
= decode_rm00_address(rl
);
11567 DECODE_PRINTF("\n");
11569 case 0: /* inc word ptr ... */
11570 destval
= fetch_data_byte(destoffset
);
11572 destval
= inc_byte(destval
);
11573 store_data_byte(destoffset
, destval
);
11575 case 1: /* dec word ptr ... */
11576 destval
= fetch_data_byte(destoffset
);
11578 destval
= dec_byte(destval
);
11579 store_data_byte(destoffset
, destval
);
11584 DECODE_PRINTF("BYTE PTR ");
11585 destoffset
= decode_rm01_address(rl
);
11586 DECODE_PRINTF("\n");
11589 destval
= fetch_data_byte(destoffset
);
11591 destval
= inc_byte(destval
);
11592 store_data_byte(destoffset
, destval
);
11595 destval
= fetch_data_byte(destoffset
);
11597 destval
= dec_byte(destval
);
11598 store_data_byte(destoffset
, destval
);
11603 DECODE_PRINTF("BYTE PTR ");
11604 destoffset
= decode_rm10_address(rl
);
11605 DECODE_PRINTF("\n");
11608 destval
= fetch_data_byte(destoffset
);
11610 destval
= inc_byte(destval
);
11611 store_data_byte(destoffset
, destval
);
11614 destval
= fetch_data_byte(destoffset
);
11616 destval
= dec_byte(destval
);
11617 store_data_byte(destoffset
, destval
);
11622 destreg
= DECODE_RM_BYTE_REGISTER(rl
);
11623 DECODE_PRINTF("\n");
11627 *destreg
= inc_byte(*destreg
);
11631 *destreg
= dec_byte(*destreg
);
11636 DECODE_CLEAR_SEGOVR();
11640 /****************************************************************************
11642 Handles opcode 0xff
11643 ****************************************************************************/
11645 x86emuOp_opcFF_word_RM(u8
X86EMU_UNUSED(op1
))
11648 uint destoffset
= 0;
11650 u16 destval
, destval2
;
11652 /* Yet another special case instruction. */
11654 FETCH_DECODE_MODRM(mod
, rh
, rl
);
11656 if (DEBUG_DECODE()) {
11657 /* XXX DECODE_PRINTF may be changed to something more
11658 general, so that it is important to leave the strings
11659 in the same format, even though the result is that the
11660 above test is done twice. */
11664 if (M
.x86
.mode
& SYSMODE_PREFIX_DATA
) {
11665 DECODE_PRINTF("INC\tDWORD PTR ");
11668 DECODE_PRINTF("INC\tWORD PTR ");
11672 if (M
.x86
.mode
& SYSMODE_PREFIX_DATA
) {
11673 DECODE_PRINTF("DEC\tDWORD PTR ");
11676 DECODE_PRINTF("DEC\tWORD PTR ");
11680 DECODE_PRINTF("CALL\t");
11683 DECODE_PRINTF("CALL\tFAR ");
11686 DECODE_PRINTF("JMP\t");
11689 DECODE_PRINTF("JMP\tFAR ");
11692 DECODE_PRINTF("PUSH\t");
11695 DECODE_PRINTF("ILLEGAL DECODING OF OPCODE FF\t");
11703 destoffset
= decode_rm00_address(rl
);
11704 DECODE_PRINTF("\n");
11706 case 0: /* inc word ptr ... */
11707 if (M
.x86
.mode
& SYSMODE_PREFIX_DATA
) {
11710 destval
= fetch_data_long(destoffset
);
11712 destval
= inc_long(destval
);
11713 store_data_long(destoffset
, destval
);
11718 destval
= fetch_data_word(destoffset
);
11720 destval
= inc_word(destval
);
11721 store_data_word(destoffset
, destval
);
11724 case 1: /* dec word ptr ... */
11725 if (M
.x86
.mode
& SYSMODE_PREFIX_DATA
) {
11728 destval
= fetch_data_long(destoffset
);
11730 destval
= dec_long(destval
);
11731 store_data_long(destoffset
, destval
);
11736 destval
= fetch_data_word(destoffset
);
11738 destval
= dec_word(destval
);
11739 store_data_word(destoffset
, destval
);
11742 case 2: /* call word ptr ... */
11743 destval
= fetch_data_word(destoffset
);
11745 push_word(M
.x86
.R_IP
);
11746 M
.x86
.R_IP
= destval
;
11748 case 3: /* call far ptr ... */
11749 destval
= fetch_data_word(destoffset
);
11750 destval2
= fetch_data_word(destoffset
+ 2);
11752 push_word(M
.x86
.R_CS
);
11753 M
.x86
.R_CS
= destval2
;
11754 push_word(M
.x86
.R_IP
);
11755 M
.x86
.R_IP
= destval
;
11757 case 4: /* jmp word ptr ... */
11758 destval
= fetch_data_word(destoffset
);
11760 M
.x86
.R_IP
= destval
;
11762 case 5: /* jmp far ptr ... */
11763 destval
= fetch_data_word(destoffset
);
11764 destval2
= fetch_data_word(destoffset
+ 2);
11766 M
.x86
.R_IP
= destval
;
11767 M
.x86
.R_CS
= destval2
;
11769 case 6: /* push word ptr ... */
11770 if (M
.x86
.mode
& SYSMODE_PREFIX_DATA
) {
11773 destval
= fetch_data_long(destoffset
);
11775 push_long(destval
);
11780 destval
= fetch_data_word(destoffset
);
11782 push_word(destval
);
11788 destoffset
= decode_rm01_address(rl
);
11789 DECODE_PRINTF("\n");
11792 if (M
.x86
.mode
& SYSMODE_PREFIX_DATA
) {
11795 destval
= fetch_data_long(destoffset
);
11797 destval
= inc_long(destval
);
11798 store_data_long(destoffset
, destval
);
11803 destval
= fetch_data_word(destoffset
);
11805 destval
= inc_word(destval
);
11806 store_data_word(destoffset
, destval
);
11810 if (M
.x86
.mode
& SYSMODE_PREFIX_DATA
) {
11813 destval
= fetch_data_long(destoffset
);
11815 destval
= dec_long(destval
);
11816 store_data_long(destoffset
, destval
);
11821 destval
= fetch_data_word(destoffset
);
11823 destval
= dec_word(destval
);
11824 store_data_word(destoffset
, destval
);
11827 case 2: /* call word ptr ... */
11828 destval
= fetch_data_word(destoffset
);
11830 push_word(M
.x86
.R_IP
);
11831 M
.x86
.R_IP
= destval
;
11833 case 3: /* call far ptr ... */
11834 destval
= fetch_data_word(destoffset
);
11835 destval2
= fetch_data_word(destoffset
+ 2);
11837 push_word(M
.x86
.R_CS
);
11838 M
.x86
.R_CS
= destval2
;
11839 push_word(M
.x86
.R_IP
);
11840 M
.x86
.R_IP
= destval
;
11842 case 4: /* jmp word ptr ... */
11843 destval
= fetch_data_word(destoffset
);
11845 M
.x86
.R_IP
= destval
;
11847 case 5: /* jmp far ptr ... */
11848 destval
= fetch_data_word(destoffset
);
11849 destval2
= fetch_data_word(destoffset
+ 2);
11851 M
.x86
.R_IP
= destval
;
11852 M
.x86
.R_CS
= destval2
;
11854 case 6: /* push word ptr ... */
11855 if (M
.x86
.mode
& SYSMODE_PREFIX_DATA
) {
11858 destval
= fetch_data_long(destoffset
);
11860 push_long(destval
);
11865 destval
= fetch_data_word(destoffset
);
11867 push_word(destval
);
11873 destoffset
= decode_rm10_address(rl
);
11874 DECODE_PRINTF("\n");
11877 if (M
.x86
.mode
& SYSMODE_PREFIX_DATA
) {
11880 destval
= fetch_data_long(destoffset
);
11882 destval
= inc_long(destval
);
11883 store_data_long(destoffset
, destval
);
11888 destval
= fetch_data_word(destoffset
);
11890 destval
= inc_word(destval
);
11891 store_data_word(destoffset
, destval
);
11895 if (M
.x86
.mode
& SYSMODE_PREFIX_DATA
) {
11898 destval
= fetch_data_long(destoffset
);
11900 destval
= dec_long(destval
);
11901 store_data_long(destoffset
, destval
);
11906 destval
= fetch_data_word(destoffset
);
11908 destval
= dec_word(destval
);
11909 store_data_word(destoffset
, destval
);
11912 case 2: /* call word ptr ... */
11913 destval
= fetch_data_word(destoffset
);
11915 push_word(M
.x86
.R_IP
);
11916 M
.x86
.R_IP
= destval
;
11918 case 3: /* call far ptr ... */
11919 destval
= fetch_data_word(destoffset
);
11920 destval2
= fetch_data_word(destoffset
+ 2);
11922 push_word(M
.x86
.R_CS
);
11923 M
.x86
.R_CS
= destval2
;
11924 push_word(M
.x86
.R_IP
);
11925 M
.x86
.R_IP
= destval
;
11927 case 4: /* jmp word ptr ... */
11928 destval
= fetch_data_word(destoffset
);
11930 M
.x86
.R_IP
= destval
;
11932 case 5: /* jmp far ptr ... */
11933 destval
= fetch_data_word(destoffset
);
11934 destval2
= fetch_data_word(destoffset
+ 2);
11936 M
.x86
.R_IP
= destval
;
11937 M
.x86
.R_CS
= destval2
;
11939 case 6: /* push word ptr ... */
11940 if (M
.x86
.mode
& SYSMODE_PREFIX_DATA
) {
11943 destval
= fetch_data_long(destoffset
);
11945 push_long(destval
);
11950 destval
= fetch_data_word(destoffset
);
11952 push_word(destval
);
11960 if (M
.x86
.mode
& SYSMODE_PREFIX_DATA
) {
11963 destreg
= DECODE_RM_LONG_REGISTER(rl
);
11964 DECODE_PRINTF("\n");
11966 *destreg
= inc_long(*destreg
);
11971 destreg
= DECODE_RM_WORD_REGISTER(rl
);
11972 DECODE_PRINTF("\n");
11974 *destreg
= inc_word(*destreg
);
11978 if (M
.x86
.mode
& SYSMODE_PREFIX_DATA
) {
11981 destreg
= DECODE_RM_LONG_REGISTER(rl
);
11982 DECODE_PRINTF("\n");
11984 *destreg
= dec_long(*destreg
);
11989 destreg
= DECODE_RM_WORD_REGISTER(rl
);
11990 DECODE_PRINTF("\n");
11992 *destreg
= dec_word(*destreg
);
11995 case 2: /* call word ptr ... */
11996 destreg
= DECODE_RM_WORD_REGISTER(rl
);
11997 DECODE_PRINTF("\n");
11999 push_word(M
.x86
.R_IP
);
12000 M
.x86
.R_IP
= *destreg
;
12002 case 3: /* jmp far ptr ... */
12003 DECODE_PRINTF("OPERATION UNDEFINED 0XFF \n");
12008 case 4: /* jmp ... */
12009 destreg
= DECODE_RM_WORD_REGISTER(rl
);
12010 DECODE_PRINTF("\n");
12012 M
.x86
.R_IP
= (u16
) (*destreg
);
12014 case 5: /* jmp far ptr ... */
12015 DECODE_PRINTF("OPERATION UNDEFINED 0XFF \n");
12020 if (M
.x86
.mode
& SYSMODE_PREFIX_DATA
) {
12023 destreg
= DECODE_RM_LONG_REGISTER(rl
);
12024 DECODE_PRINTF("\n");
12026 push_long(*destreg
);
12031 destreg
= DECODE_RM_WORD_REGISTER(rl
);
12032 DECODE_PRINTF("\n");
12034 push_word(*destreg
);
12040 DECODE_CLEAR_SEGOVR();
12044 /***************************************************************************
12045 * Single byte operation code table:
12046 **************************************************************************/
12047 void (*x86emu_optab
[256]) (u8
) = {
12048 /* 0x00 */ x86emuOp_add_byte_RM_R
,
12049 /* 0x01 */ x86emuOp_add_word_RM_R
,
12050 /* 0x02 */ x86emuOp_add_byte_R_RM
,
12051 /* 0x03 */ x86emuOp_add_word_R_RM
,
12052 /* 0x04 */ x86emuOp_add_byte_AL_IMM
,
12053 /* 0x05 */ x86emuOp_add_word_AX_IMM
,
12054 /* 0x06 */ x86emuOp_push_ES
,
12055 /* 0x07 */ x86emuOp_pop_ES
,
12056 /* 0x08 */ x86emuOp_or_byte_RM_R
,
12057 /* 0x09 */ x86emuOp_or_word_RM_R
,
12058 /* 0x0a */ x86emuOp_or_byte_R_RM
,
12059 /* 0x0b */ x86emuOp_or_word_R_RM
,
12060 /* 0x0c */ x86emuOp_or_byte_AL_IMM
,
12061 /* 0x0d */ x86emuOp_or_word_AX_IMM
,
12062 /* 0x0e */ x86emuOp_push_CS
,
12063 /* 0x0f */ x86emuOp_two_byte
,
12064 /* 0x10 */ x86emuOp_adc_byte_RM_R
,
12065 /* 0x11 */ x86emuOp_adc_word_RM_R
,
12066 /* 0x12 */ x86emuOp_adc_byte_R_RM
,
12067 /* 0x13 */ x86emuOp_adc_word_R_RM
,
12068 /* 0x14 */ x86emuOp_adc_byte_AL_IMM
,
12069 /* 0x15 */ x86emuOp_adc_word_AX_IMM
,
12070 /* 0x16 */ x86emuOp_push_SS
,
12071 /* 0x17 */ x86emuOp_pop_SS
,
12072 /* 0x18 */ x86emuOp_sbb_byte_RM_R
,
12073 /* 0x19 */ x86emuOp_sbb_word_RM_R
,
12074 /* 0x1a */ x86emuOp_sbb_byte_R_RM
,
12075 /* 0x1b */ x86emuOp_sbb_word_R_RM
,
12076 /* 0x1c */ x86emuOp_sbb_byte_AL_IMM
,
12077 /* 0x1d */ x86emuOp_sbb_word_AX_IMM
,
12078 /* 0x1e */ x86emuOp_push_DS
,
12079 /* 0x1f */ x86emuOp_pop_DS
,
12080 /* 0x20 */ x86emuOp_and_byte_RM_R
,
12081 /* 0x21 */ x86emuOp_and_word_RM_R
,
12082 /* 0x22 */ x86emuOp_and_byte_R_RM
,
12083 /* 0x23 */ x86emuOp_and_word_R_RM
,
12084 /* 0x24 */ x86emuOp_and_byte_AL_IMM
,
12085 /* 0x25 */ x86emuOp_and_word_AX_IMM
,
12086 /* 0x26 */ x86emuOp_segovr_ES
,
12087 /* 0x27 */ x86emuOp_daa
,
12088 /* 0x28 */ x86emuOp_sub_byte_RM_R
,
12089 /* 0x29 */ x86emuOp_sub_word_RM_R
,
12090 /* 0x2a */ x86emuOp_sub_byte_R_RM
,
12091 /* 0x2b */ x86emuOp_sub_word_R_RM
,
12092 /* 0x2c */ x86emuOp_sub_byte_AL_IMM
,
12093 /* 0x2d */ x86emuOp_sub_word_AX_IMM
,
12094 /* 0x2e */ x86emuOp_segovr_CS
,
12095 /* 0x2f */ x86emuOp_das
,
12096 /* 0x30 */ x86emuOp_xor_byte_RM_R
,
12097 /* 0x31 */ x86emuOp_xor_word_RM_R
,
12098 /* 0x32 */ x86emuOp_xor_byte_R_RM
,
12099 /* 0x33 */ x86emuOp_xor_word_R_RM
,
12100 /* 0x34 */ x86emuOp_xor_byte_AL_IMM
,
12101 /* 0x35 */ x86emuOp_xor_word_AX_IMM
,
12102 /* 0x36 */ x86emuOp_segovr_SS
,
12103 /* 0x37 */ x86emuOp_aaa
,
12104 /* 0x38 */ x86emuOp_cmp_byte_RM_R
,
12105 /* 0x39 */ x86emuOp_cmp_word_RM_R
,
12106 /* 0x3a */ x86emuOp_cmp_byte_R_RM
,
12107 /* 0x3b */ x86emuOp_cmp_word_R_RM
,
12108 /* 0x3c */ x86emuOp_cmp_byte_AL_IMM
,
12109 /* 0x3d */ x86emuOp_cmp_word_AX_IMM
,
12110 /* 0x3e */ x86emuOp_segovr_DS
,
12111 /* 0x3f */ x86emuOp_aas
,
12112 /* 0x40 */ x86emuOp_inc_AX
,
12113 /* 0x41 */ x86emuOp_inc_CX
,
12114 /* 0x42 */ x86emuOp_inc_DX
,
12115 /* 0x43 */ x86emuOp_inc_BX
,
12116 /* 0x44 */ x86emuOp_inc_SP
,
12117 /* 0x45 */ x86emuOp_inc_BP
,
12118 /* 0x46 */ x86emuOp_inc_SI
,
12119 /* 0x47 */ x86emuOp_inc_DI
,
12120 /* 0x48 */ x86emuOp_dec_AX
,
12121 /* 0x49 */ x86emuOp_dec_CX
,
12122 /* 0x4a */ x86emuOp_dec_DX
,
12123 /* 0x4b */ x86emuOp_dec_BX
,
12124 /* 0x4c */ x86emuOp_dec_SP
,
12125 /* 0x4d */ x86emuOp_dec_BP
,
12126 /* 0x4e */ x86emuOp_dec_SI
,
12127 /* 0x4f */ x86emuOp_dec_DI
,
12128 /* 0x50 */ x86emuOp_push_AX
,
12129 /* 0x51 */ x86emuOp_push_CX
,
12130 /* 0x52 */ x86emuOp_push_DX
,
12131 /* 0x53 */ x86emuOp_push_BX
,
12132 /* 0x54 */ x86emuOp_push_SP
,
12133 /* 0x55 */ x86emuOp_push_BP
,
12134 /* 0x56 */ x86emuOp_push_SI
,
12135 /* 0x57 */ x86emuOp_push_DI
,
12136 /* 0x58 */ x86emuOp_pop_AX
,
12137 /* 0x59 */ x86emuOp_pop_CX
,
12138 /* 0x5a */ x86emuOp_pop_DX
,
12139 /* 0x5b */ x86emuOp_pop_BX
,
12140 /* 0x5c */ x86emuOp_pop_SP
,
12141 /* 0x5d */ x86emuOp_pop_BP
,
12142 /* 0x5e */ x86emuOp_pop_SI
,
12143 /* 0x5f */ x86emuOp_pop_DI
,
12144 /* 0x60 */ x86emuOp_push_all
,
12145 /* 0x61 */ x86emuOp_pop_all
,
12146 /* 0x62 */ x86emuOp_illegal_op
,
12148 /* 0x63 */ x86emuOp_illegal_op
,
12150 /* 0x64 */ x86emuOp_segovr_FS
,
12151 /* 0x65 */ x86emuOp_segovr_GS
,
12152 /* 0x66 */ x86emuOp_prefix_data
,
12153 /* 0x67 */ x86emuOp_prefix_addr
,
12154 /* 0x68 */ x86emuOp_push_word_IMM
,
12155 /* 0x69 */ x86emuOp_imul_word_IMM
,
12156 /* 0x6a */ x86emuOp_push_byte_IMM
,
12157 /* 0x6b */ x86emuOp_imul_byte_IMM
,
12158 /* 0x6c */ x86emuOp_ins_byte
,
12159 /* 0x6d */ x86emuOp_ins_word
,
12160 /* 0x6e */ x86emuOp_outs_byte
,
12161 /* 0x6f */ x86emuOp_outs_word
,
12162 /* 0x70 */ x86emuOp_jump_near_O
,
12163 /* 0x71 */ x86emuOp_jump_near_NO
,
12164 /* 0x72 */ x86emuOp_jump_near_B
,
12165 /* 0x73 */ x86emuOp_jump_near_NB
,
12166 /* 0x74 */ x86emuOp_jump_near_Z
,
12167 /* 0x75 */ x86emuOp_jump_near_NZ
,
12168 /* 0x76 */ x86emuOp_jump_near_BE
,
12169 /* 0x77 */ x86emuOp_jump_near_NBE
,
12170 /* 0x78 */ x86emuOp_jump_near_S
,
12171 /* 0x79 */ x86emuOp_jump_near_NS
,
12172 /* 0x7a */ x86emuOp_jump_near_P
,
12173 /* 0x7b */ x86emuOp_jump_near_NP
,
12174 /* 0x7c */ x86emuOp_jump_near_L
,
12175 /* 0x7d */ x86emuOp_jump_near_NL
,
12176 /* 0x7e */ x86emuOp_jump_near_LE
,
12177 /* 0x7f */ x86emuOp_jump_near_NLE
,
12178 /* 0x80 */ x86emuOp_opc80_byte_RM_IMM
,
12179 /* 0x81 */ x86emuOp_opc81_word_RM_IMM
,
12180 /* 0x82 */ x86emuOp_opc82_byte_RM_IMM
,
12181 /* 0x83 */ x86emuOp_opc83_word_RM_IMM
,
12182 /* 0x84 */ x86emuOp_test_byte_RM_R
,
12183 /* 0x85 */ x86emuOp_test_word_RM_R
,
12184 /* 0x86 */ x86emuOp_xchg_byte_RM_R
,
12185 /* 0x87 */ x86emuOp_xchg_word_RM_R
,
12186 /* 0x88 */ x86emuOp_mov_byte_RM_R
,
12187 /* 0x89 */ x86emuOp_mov_word_RM_R
,
12188 /* 0x8a */ x86emuOp_mov_byte_R_RM
,
12189 /* 0x8b */ x86emuOp_mov_word_R_RM
,
12190 /* 0x8c */ x86emuOp_mov_word_RM_SR
,
12191 /* 0x8d */ x86emuOp_lea_word_R_M
,
12192 /* 0x8e */ x86emuOp_mov_word_SR_RM
,
12193 /* 0x8f */ x86emuOp_pop_RM
,
12194 /* 0x90 */ x86emuOp_nop
,
12195 /* 0x91 */ x86emuOp_xchg_word_AX_CX
,
12196 /* 0x92 */ x86emuOp_xchg_word_AX_DX
,
12197 /* 0x93 */ x86emuOp_xchg_word_AX_BX
,
12198 /* 0x94 */ x86emuOp_xchg_word_AX_SP
,
12199 /* 0x95 */ x86emuOp_xchg_word_AX_BP
,
12200 /* 0x96 */ x86emuOp_xchg_word_AX_SI
,
12201 /* 0x97 */ x86emuOp_xchg_word_AX_DI
,
12202 /* 0x98 */ x86emuOp_cbw
,
12203 /* 0x99 */ x86emuOp_cwd
,
12204 /* 0x9a */ x86emuOp_call_far_IMM
,
12205 /* 0x9b */ x86emuOp_wait
,
12206 /* 0x9c */ x86emuOp_pushf_word
,
12207 /* 0x9d */ x86emuOp_popf_word
,
12208 /* 0x9e */ x86emuOp_sahf
,
12209 /* 0x9f */ x86emuOp_lahf
,
12210 /* 0xa0 */ x86emuOp_mov_AL_M_IMM
,
12211 /* 0xa1 */ x86emuOp_mov_AX_M_IMM
,
12212 /* 0xa2 */ x86emuOp_mov_M_AL_IMM
,
12213 /* 0xa3 */ x86emuOp_mov_M_AX_IMM
,
12214 /* 0xa4 */ x86emuOp_movs_byte
,
12215 /* 0xa5 */ x86emuOp_movs_word
,
12216 /* 0xa6 */ x86emuOp_cmps_byte
,
12217 /* 0xa7 */ x86emuOp_cmps_word
,
12218 /* 0xa8 */ x86emuOp_test_AL_IMM
,
12219 /* 0xa9 */ x86emuOp_test_AX_IMM
,
12220 /* 0xaa */ x86emuOp_stos_byte
,
12221 /* 0xab */ x86emuOp_stos_word
,
12222 /* 0xac */ x86emuOp_lods_byte
,
12223 /* 0xad */ x86emuOp_lods_word
,
12224 /* 0xac */ x86emuOp_scas_byte
,
12225 /* 0xad */ x86emuOp_scas_word
,
12226 /* 0xb0 */ x86emuOp_mov_byte_AL_IMM
,
12227 /* 0xb1 */ x86emuOp_mov_byte_CL_IMM
,
12228 /* 0xb2 */ x86emuOp_mov_byte_DL_IMM
,
12229 /* 0xb3 */ x86emuOp_mov_byte_BL_IMM
,
12230 /* 0xb4 */ x86emuOp_mov_byte_AH_IMM
,
12231 /* 0xb5 */ x86emuOp_mov_byte_CH_IMM
,
12232 /* 0xb6 */ x86emuOp_mov_byte_DH_IMM
,
12233 /* 0xb7 */ x86emuOp_mov_byte_BH_IMM
,
12234 /* 0xb8 */ x86emuOp_mov_word_AX_IMM
,
12235 /* 0xb9 */ x86emuOp_mov_word_CX_IMM
,
12236 /* 0xba */ x86emuOp_mov_word_DX_IMM
,
12237 /* 0xbb */ x86emuOp_mov_word_BX_IMM
,
12238 /* 0xbc */ x86emuOp_mov_word_SP_IMM
,
12239 /* 0xbd */ x86emuOp_mov_word_BP_IMM
,
12240 /* 0xbe */ x86emuOp_mov_word_SI_IMM
,
12241 /* 0xbf */ x86emuOp_mov_word_DI_IMM
,
12242 /* 0xc0 */ x86emuOp_opcC0_byte_RM_MEM
,
12243 /* 0xc1 */ x86emuOp_opcC1_word_RM_MEM
,
12244 /* 0xc2 */ x86emuOp_ret_near_IMM
,
12245 /* 0xc3 */ x86emuOp_ret_near
,
12246 /* 0xc4 */ x86emuOp_les_R_IMM
,
12247 /* 0xc5 */ x86emuOp_lds_R_IMM
,
12248 /* 0xc6 */ x86emuOp_mov_byte_RM_IMM
,
12249 /* 0xc7 */ x86emuOp_mov_word_RM_IMM
,
12250 /* 0xc8 */ x86emuOp_enter
,
12251 /* 0xc9 */ x86emuOp_leave
,
12252 /* 0xca */ x86emuOp_ret_far_IMM
,
12253 /* 0xcb */ x86emuOp_ret_far
,
12254 /* 0xcc */ x86emuOp_int3
,
12255 /* 0xcd */ x86emuOp_int_IMM
,
12256 /* 0xce */ x86emuOp_into
,
12257 /* 0xcf */ x86emuOp_iret
,
12258 /* 0xd0 */ x86emuOp_opcD0_byte_RM_1
,
12259 /* 0xd1 */ x86emuOp_opcD1_word_RM_1
,
12260 /* 0xd2 */ x86emuOp_opcD2_byte_RM_CL
,
12261 /* 0xd3 */ x86emuOp_opcD3_word_RM_CL
,
12262 /* 0xd4 */ x86emuOp_aam
,
12263 /* 0xd5 */ x86emuOp_aad
,
12264 /* 0xd6 */ x86emuOp_illegal_op
,
12265 /* Undocumented SETALC instruction */
12266 /* 0xd7 */ x86emuOp_xlat
,
12267 /* 0xd8 */ x86emuOp_esc_coprocess_d8
,
12268 /* 0xd9 */ x86emuOp_esc_coprocess_d9
,
12269 /* 0xda */ x86emuOp_esc_coprocess_da
,
12270 /* 0xdb */ x86emuOp_esc_coprocess_db
,
12271 /* 0xdc */ x86emuOp_esc_coprocess_dc
,
12272 /* 0xdd */ x86emuOp_esc_coprocess_dd
,
12273 /* 0xde */ x86emuOp_esc_coprocess_de
,
12274 /* 0xdf */ x86emuOp_esc_coprocess_df
,
12275 /* 0xe0 */ x86emuOp_loopne
,
12276 /* 0xe1 */ x86emuOp_loope
,
12277 /* 0xe2 */ x86emuOp_loop
,
12278 /* 0xe3 */ x86emuOp_jcxz
,
12279 /* 0xe4 */ x86emuOp_in_byte_AL_IMM
,
12280 /* 0xe5 */ x86emuOp_in_word_AX_IMM
,
12281 /* 0xe6 */ x86emuOp_out_byte_IMM_AL
,
12282 /* 0xe7 */ x86emuOp_out_word_IMM_AX
,
12283 /* 0xe8 */ x86emuOp_call_near_IMM
,
12284 /* 0xe9 */ x86emuOp_jump_near_IMM
,
12285 /* 0xea */ x86emuOp_jump_far_IMM
,
12286 /* 0xeb */ x86emuOp_jump_byte_IMM
,
12287 /* 0xec */ x86emuOp_in_byte_AL_DX
,
12288 /* 0xed */ x86emuOp_in_word_AX_DX
,
12289 /* 0xee */ x86emuOp_out_byte_DX_AL
,
12290 /* 0xef */ x86emuOp_out_word_DX_AX
,
12291 /* 0xf0 */ x86emuOp_lock
,
12292 /* 0xf1 */ x86emuOp_illegal_op
,
12293 /* 0xf2 */ x86emuOp_repne
,
12294 /* 0xf3 */ x86emuOp_repe
,
12295 /* 0xf4 */ x86emuOp_halt
,
12296 /* 0xf5 */ x86emuOp_cmc
,
12297 /* 0xf6 */ x86emuOp_opcF6_byte_RM
,
12298 /* 0xf7 */ x86emuOp_opcF7_word_RM
,
12299 /* 0xf8 */ x86emuOp_clc
,
12300 /* 0xf9 */ x86emuOp_stc
,
12301 /* 0xfa */ x86emuOp_cli
,
12302 /* 0xfb */ x86emuOp_sti
,
12303 /* 0xfc */ x86emuOp_cld
,
12304 /* 0xfd */ x86emuOp_std
,
12305 /* 0xfe */ x86emuOp_opcFE_byte_RM
,
12306 /* 0xff */ x86emuOp_opcFF_word_RM
,