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 ****************************************************************************/
84 void x86emuOp_illegal_op(
88 DECODE_PRINTF("ILLEGAL X86 OPCODE\n");
90 printk("%04x:%04x: %02X ILLEGAL X86 OPCODE!\n",
91 M.x86.R_CS, M.x86.R_IP-1,op1);
96 /****************************************************************************
99 ****************************************************************************/
100 void x86emuOp_add_byte_RM_R(u8 X86EMU_UNUSED(op1))
104 u8 *destreg, *srcreg;
108 DECODE_PRINTF("ADD\t");
109 FETCH_DECODE_MODRM(mod, rh, rl);
112 destoffset = decode_rm00_address(rl);
114 destval = fetch_data_byte(destoffset);
115 srcreg = DECODE_RM_BYTE_REGISTER(rh);
118 destval = add_byte(destval, *srcreg);
119 store_data_byte(destoffset, destval);
122 destoffset = decode_rm01_address(rl);
124 destval = fetch_data_byte(destoffset);
125 srcreg = DECODE_RM_BYTE_REGISTER(rh);
128 destval = add_byte(destval, *srcreg);
129 store_data_byte(destoffset, destval);
132 destoffset = decode_rm10_address(rl);
134 destval = fetch_data_byte(destoffset);
135 srcreg = DECODE_RM_BYTE_REGISTER(rh);
138 destval = add_byte(destval, *srcreg);
139 store_data_byte(destoffset, destval);
141 case 3: /* register to register */
142 destreg = DECODE_RM_BYTE_REGISTER(rl);
144 srcreg = DECODE_RM_BYTE_REGISTER(rh);
147 *destreg = add_byte(*destreg, *srcreg);
150 DECODE_CLEAR_SEGOVR();
154 /****************************************************************************
157 ****************************************************************************/
158 void x86emuOp_add_word_RM_R(u8 X86EMU_UNUSED(op1))
164 DECODE_PRINTF("ADD\t");
165 FETCH_DECODE_MODRM(mod, rh, rl);
168 if (M.x86.mode & SYSMODE_PREFIX_DATA) {
172 destoffset = decode_rm00_address(rl);
174 destval = fetch_data_long(destoffset);
175 srcreg = DECODE_RM_LONG_REGISTER(rh);
178 destval = add_long(destval, *srcreg);
179 store_data_long(destoffset, destval);
184 destoffset = decode_rm00_address(rl);
186 destval = fetch_data_word(destoffset);
187 srcreg = DECODE_RM_WORD_REGISTER(rh);
190 destval = add_word(destval, *srcreg);
191 store_data_word(destoffset, destval);
195 if (M.x86.mode & SYSMODE_PREFIX_DATA) {
199 destoffset = decode_rm01_address(rl);
201 destval = fetch_data_long(destoffset);
202 srcreg = DECODE_RM_LONG_REGISTER(rh);
205 destval = add_long(destval, *srcreg);
206 store_data_long(destoffset, destval);
211 destoffset = decode_rm01_address(rl);
213 destval = fetch_data_word(destoffset);
214 srcreg = DECODE_RM_WORD_REGISTER(rh);
217 destval = add_word(destval, *srcreg);
218 store_data_word(destoffset, destval);
222 if (M.x86.mode & SYSMODE_PREFIX_DATA) {
226 destoffset = decode_rm10_address(rl);
228 destval = fetch_data_long(destoffset);
229 srcreg = DECODE_RM_LONG_REGISTER(rh);
232 destval = add_long(destval, *srcreg);
233 store_data_long(destoffset, destval);
238 destoffset = decode_rm10_address(rl);
240 destval = fetch_data_word(destoffset);
241 srcreg = DECODE_RM_WORD_REGISTER(rh);
244 destval = add_word(destval, *srcreg);
245 store_data_word(destoffset, destval);
248 case 3: /* register to register */
249 if (M.x86.mode & SYSMODE_PREFIX_DATA) {
250 u32 *destreg,*srcreg;
252 destreg = DECODE_RM_LONG_REGISTER(rl);
254 srcreg = DECODE_RM_LONG_REGISTER(rh);
257 *destreg = add_long(*destreg, *srcreg);
259 u16 *destreg,*srcreg;
261 destreg = DECODE_RM_WORD_REGISTER(rl);
263 srcreg = DECODE_RM_WORD_REGISTER(rh);
266 *destreg = add_word(*destreg, *srcreg);
270 DECODE_CLEAR_SEGOVR();
274 /****************************************************************************
277 ****************************************************************************/
278 void x86emuOp_add_byte_R_RM(u8 X86EMU_UNUSED(op1))
281 u8 *destreg, *srcreg;
286 DECODE_PRINTF("ADD\t");
287 FETCH_DECODE_MODRM(mod, rh, rl);
290 destreg = DECODE_RM_BYTE_REGISTER(rh);
292 srcoffset = decode_rm00_address(rl);
293 srcval = fetch_data_byte(srcoffset);
296 *destreg = add_byte(*destreg, srcval);
299 destreg = DECODE_RM_BYTE_REGISTER(rh);
301 srcoffset = decode_rm01_address(rl);
302 srcval = fetch_data_byte(srcoffset);
305 *destreg = add_byte(*destreg, srcval);
308 destreg = DECODE_RM_BYTE_REGISTER(rh);
310 srcoffset = decode_rm10_address(rl);
311 srcval = fetch_data_byte(srcoffset);
314 *destreg = add_byte(*destreg, srcval);
316 case 3: /* register to register */
317 destreg = DECODE_RM_BYTE_REGISTER(rh);
319 srcreg = DECODE_RM_BYTE_REGISTER(rl);
322 *destreg = add_byte(*destreg, *srcreg);
325 DECODE_CLEAR_SEGOVR();
329 /****************************************************************************
332 ****************************************************************************/
333 void x86emuOp_add_word_R_RM(u8 X86EMU_UNUSED(op1))
339 DECODE_PRINTF("ADD\t");
340 FETCH_DECODE_MODRM(mod, rh, rl);
343 if (M.x86.mode & SYSMODE_PREFIX_DATA) {
347 destreg = DECODE_RM_LONG_REGISTER(rh);
349 srcoffset = decode_rm00_address(rl);
350 srcval = fetch_data_long(srcoffset);
353 *destreg = add_long(*destreg, srcval);
358 destreg = DECODE_RM_WORD_REGISTER(rh);
360 srcoffset = decode_rm00_address(rl);
361 srcval = fetch_data_word(srcoffset);
364 *destreg = add_word(*destreg, srcval);
368 if (M.x86.mode & SYSMODE_PREFIX_DATA) {
372 destreg = DECODE_RM_LONG_REGISTER(rh);
374 srcoffset = decode_rm01_address(rl);
375 srcval = fetch_data_long(srcoffset);
378 *destreg = add_long(*destreg, srcval);
383 destreg = DECODE_RM_WORD_REGISTER(rh);
385 srcoffset = decode_rm01_address(rl);
386 srcval = fetch_data_word(srcoffset);
389 *destreg = add_word(*destreg, srcval);
393 if (M.x86.mode & SYSMODE_PREFIX_DATA) {
397 destreg = DECODE_RM_LONG_REGISTER(rh);
399 srcoffset = decode_rm10_address(rl);
400 srcval = fetch_data_long(srcoffset);
403 *destreg = add_long(*destreg, srcval);
408 destreg = DECODE_RM_WORD_REGISTER(rh);
410 srcoffset = decode_rm10_address(rl);
411 srcval = fetch_data_word(srcoffset);
414 *destreg = add_word(*destreg, srcval);
417 case 3: /* register to register */
418 if (M.x86.mode & SYSMODE_PREFIX_DATA) {
419 u32 *destreg,*srcreg;
421 destreg = DECODE_RM_LONG_REGISTER(rh);
423 srcreg = DECODE_RM_LONG_REGISTER(rl);
426 *destreg = add_long(*destreg, *srcreg);
428 u16 *destreg,*srcreg;
430 destreg = DECODE_RM_WORD_REGISTER(rh);
432 srcreg = DECODE_RM_WORD_REGISTER(rl);
435 *destreg = add_word(*destreg, *srcreg);
439 DECODE_CLEAR_SEGOVR();
443 /****************************************************************************
446 ****************************************************************************/
447 void x86emuOp_add_byte_AL_IMM(u8 X86EMU_UNUSED(op1))
452 DECODE_PRINTF("ADD\tAL,");
453 srcval = fetch_byte_imm();
454 DECODE_PRINTF2("%x\n", srcval);
456 M.x86.R_AL = add_byte(M.x86.R_AL, srcval);
457 DECODE_CLEAR_SEGOVR();
461 /****************************************************************************
464 ****************************************************************************/
465 void x86emuOp_add_word_AX_IMM(u8 X86EMU_UNUSED(op1))
470 if (M.x86.mode & SYSMODE_PREFIX_DATA) {
471 DECODE_PRINTF("ADD\tEAX,");
472 srcval = fetch_long_imm();
474 DECODE_PRINTF("ADD\tAX,");
475 srcval = fetch_word_imm();
477 DECODE_PRINTF2("%x\n", srcval);
479 if (M.x86.mode & SYSMODE_PREFIX_DATA) {
480 M.x86.R_EAX = add_long(M.x86.R_EAX, srcval);
482 M.x86.R_AX = add_word(M.x86.R_AX, (u16)srcval);
484 DECODE_CLEAR_SEGOVR();
488 /****************************************************************************
491 ****************************************************************************/
492 void x86emuOp_push_ES(u8 X86EMU_UNUSED(op1))
495 DECODE_PRINTF("PUSH\tES\n");
497 push_word(M.x86.R_ES);
498 DECODE_CLEAR_SEGOVR();
502 /****************************************************************************
505 ****************************************************************************/
506 void x86emuOp_pop_ES(u8 X86EMU_UNUSED(op1))
509 DECODE_PRINTF("POP\tES\n");
511 M.x86.R_ES = pop_word();
512 DECODE_CLEAR_SEGOVR();
516 /****************************************************************************
519 ****************************************************************************/
520 void x86emuOp_or_byte_RM_R(u8 X86EMU_UNUSED(op1))
523 u8 *destreg, *srcreg;
528 DECODE_PRINTF("OR\t");
529 FETCH_DECODE_MODRM(mod, rh, rl);
532 destoffset = decode_rm00_address(rl);
534 destval = fetch_data_byte(destoffset);
535 srcreg = DECODE_RM_BYTE_REGISTER(rh);
538 destval = or_byte(destval, *srcreg);
539 store_data_byte(destoffset, destval);
542 destoffset = decode_rm01_address(rl);
544 destval = fetch_data_byte(destoffset);
545 srcreg = DECODE_RM_BYTE_REGISTER(rh);
548 destval = or_byte(destval, *srcreg);
549 store_data_byte(destoffset, destval);
552 destoffset = decode_rm10_address(rl);
554 destval = fetch_data_byte(destoffset);
555 srcreg = DECODE_RM_BYTE_REGISTER(rh);
558 destval = or_byte(destval, *srcreg);
559 store_data_byte(destoffset, destval);
561 case 3: /* register to register */
562 destreg = DECODE_RM_BYTE_REGISTER(rl);
564 srcreg = DECODE_RM_BYTE_REGISTER(rh);
567 *destreg = or_byte(*destreg, *srcreg);
570 DECODE_CLEAR_SEGOVR();
574 /****************************************************************************
577 ****************************************************************************/
578 void x86emuOp_or_word_RM_R(u8 X86EMU_UNUSED(op1))
584 DECODE_PRINTF("OR\t");
585 FETCH_DECODE_MODRM(mod, rh, rl);
588 if (M.x86.mode & SYSMODE_PREFIX_DATA) {
592 destoffset = decode_rm00_address(rl);
594 destval = fetch_data_long(destoffset);
595 srcreg = DECODE_RM_LONG_REGISTER(rh);
598 destval = or_long(destval, *srcreg);
599 store_data_long(destoffset, destval);
604 destoffset = decode_rm00_address(rl);
606 destval = fetch_data_word(destoffset);
607 srcreg = DECODE_RM_WORD_REGISTER(rh);
610 destval = or_word(destval, *srcreg);
611 store_data_word(destoffset, destval);
615 if (M.x86.mode & SYSMODE_PREFIX_DATA) {
619 destoffset = decode_rm01_address(rl);
621 destval = fetch_data_long(destoffset);
622 srcreg = DECODE_RM_LONG_REGISTER(rh);
625 destval = or_long(destval, *srcreg);
626 store_data_long(destoffset, destval);
631 destoffset = decode_rm01_address(rl);
633 destval = fetch_data_word(destoffset);
634 srcreg = DECODE_RM_WORD_REGISTER(rh);
637 destval = or_word(destval, *srcreg);
638 store_data_word(destoffset, destval);
642 if (M.x86.mode & SYSMODE_PREFIX_DATA) {
646 destoffset = decode_rm10_address(rl);
648 destval = fetch_data_long(destoffset);
649 srcreg = DECODE_RM_LONG_REGISTER(rh);
652 destval = or_long(destval, *srcreg);
653 store_data_long(destoffset, destval);
658 destoffset = decode_rm10_address(rl);
660 destval = fetch_data_word(destoffset);
661 srcreg = DECODE_RM_WORD_REGISTER(rh);
664 destval = or_word(destval, *srcreg);
665 store_data_word(destoffset, destval);
668 case 3: /* register to register */
669 if (M.x86.mode & SYSMODE_PREFIX_DATA) {
670 u32 *destreg,*srcreg;
672 destreg = DECODE_RM_LONG_REGISTER(rl);
674 srcreg = DECODE_RM_LONG_REGISTER(rh);
677 *destreg = or_long(*destreg, *srcreg);
679 u16 *destreg,*srcreg;
681 destreg = DECODE_RM_WORD_REGISTER(rl);
683 srcreg = DECODE_RM_WORD_REGISTER(rh);
686 *destreg = or_word(*destreg, *srcreg);
690 DECODE_CLEAR_SEGOVR();
694 /****************************************************************************
697 ****************************************************************************/
698 void x86emuOp_or_byte_R_RM(u8 X86EMU_UNUSED(op1))
701 u8 *destreg, *srcreg;
706 DECODE_PRINTF("OR\t");
707 FETCH_DECODE_MODRM(mod, rh, rl);
710 destreg = DECODE_RM_BYTE_REGISTER(rh);
712 srcoffset = decode_rm00_address(rl);
713 srcval = fetch_data_byte(srcoffset);
716 *destreg = or_byte(*destreg, srcval);
719 destreg = DECODE_RM_BYTE_REGISTER(rh);
721 srcoffset = decode_rm01_address(rl);
722 srcval = fetch_data_byte(srcoffset);
725 *destreg = or_byte(*destreg, srcval);
728 destreg = DECODE_RM_BYTE_REGISTER(rh);
730 srcoffset = decode_rm10_address(rl);
731 srcval = fetch_data_byte(srcoffset);
734 *destreg = or_byte(*destreg, srcval);
736 case 3: /* register to register */
737 destreg = DECODE_RM_BYTE_REGISTER(rh);
739 srcreg = DECODE_RM_BYTE_REGISTER(rl);
742 *destreg = or_byte(*destreg, *srcreg);
745 DECODE_CLEAR_SEGOVR();
749 /****************************************************************************
752 ****************************************************************************/
753 void x86emuOp_or_word_R_RM(u8 X86EMU_UNUSED(op1))
759 DECODE_PRINTF("OR\t");
760 FETCH_DECODE_MODRM(mod, rh, rl);
763 if (M.x86.mode & SYSMODE_PREFIX_DATA) {
767 destreg = DECODE_RM_LONG_REGISTER(rh);
769 srcoffset = decode_rm00_address(rl);
770 srcval = fetch_data_long(srcoffset);
773 *destreg = or_long(*destreg, srcval);
778 destreg = DECODE_RM_WORD_REGISTER(rh);
780 srcoffset = decode_rm00_address(rl);
781 srcval = fetch_data_word(srcoffset);
784 *destreg = or_word(*destreg, srcval);
788 if (M.x86.mode & SYSMODE_PREFIX_DATA) {
792 destreg = DECODE_RM_LONG_REGISTER(rh);
794 srcoffset = decode_rm01_address(rl);
795 srcval = fetch_data_long(srcoffset);
798 *destreg = or_long(*destreg, srcval);
803 destreg = DECODE_RM_WORD_REGISTER(rh);
805 srcoffset = decode_rm01_address(rl);
806 srcval = fetch_data_word(srcoffset);
809 *destreg = or_word(*destreg, srcval);
813 if (M.x86.mode & SYSMODE_PREFIX_DATA) {
817 destreg = DECODE_RM_LONG_REGISTER(rh);
819 srcoffset = decode_rm10_address(rl);
820 srcval = fetch_data_long(srcoffset);
823 *destreg = or_long(*destreg, srcval);
828 destreg = DECODE_RM_WORD_REGISTER(rh);
830 srcoffset = decode_rm10_address(rl);
831 srcval = fetch_data_word(srcoffset);
834 *destreg = or_word(*destreg, srcval);
837 case 3: /* register to register */
838 if (M.x86.mode & SYSMODE_PREFIX_DATA) {
839 u32 *destreg,*srcreg;
841 destreg = DECODE_RM_LONG_REGISTER(rh);
843 srcreg = DECODE_RM_LONG_REGISTER(rl);
846 *destreg = or_long(*destreg, *srcreg);
848 u16 *destreg,*srcreg;
850 destreg = DECODE_RM_WORD_REGISTER(rh);
852 srcreg = DECODE_RM_WORD_REGISTER(rl);
855 *destreg = or_word(*destreg, *srcreg);
859 DECODE_CLEAR_SEGOVR();
863 /****************************************************************************
866 ****************************************************************************/
867 void x86emuOp_or_byte_AL_IMM(u8 X86EMU_UNUSED(op1))
872 DECODE_PRINTF("OR\tAL,");
873 srcval = fetch_byte_imm();
874 DECODE_PRINTF2("%x\n", srcval);
876 M.x86.R_AL = or_byte(M.x86.R_AL, srcval);
877 DECODE_CLEAR_SEGOVR();
881 /****************************************************************************
884 ****************************************************************************/
885 void x86emuOp_or_word_AX_IMM(u8 X86EMU_UNUSED(op1))
890 if (M.x86.mode & SYSMODE_PREFIX_DATA) {
891 DECODE_PRINTF("OR\tEAX,");
892 srcval = fetch_long_imm();
894 DECODE_PRINTF("OR\tAX,");
895 srcval = fetch_word_imm();
897 DECODE_PRINTF2("%x\n", srcval);
899 if (M.x86.mode & SYSMODE_PREFIX_DATA) {
900 M.x86.R_EAX = or_long(M.x86.R_EAX, srcval);
902 M.x86.R_AX = or_word(M.x86.R_AX, (u16)srcval);
904 DECODE_CLEAR_SEGOVR();
908 /****************************************************************************
911 ****************************************************************************/
912 void x86emuOp_push_CS(u8 X86EMU_UNUSED(op1))
915 DECODE_PRINTF("PUSH\tCS\n");
917 push_word(M.x86.R_CS);
918 DECODE_CLEAR_SEGOVR();
922 /****************************************************************************
924 Handles opcode 0x0f. Escape for two-byte opcode (286 or better)
925 ****************************************************************************/
926 void x86emuOp_two_byte(u8 X86EMU_UNUSED(op1))
928 u8 op2 = (*sys_rdb)(((u32)M.x86.R_CS << 4) + (M.x86.R_IP++));
929 INC_DECODED_INST_LEN(1);
930 (*x86emu_optab2[op2])(op2);
933 /****************************************************************************
936 ****************************************************************************/
937 void x86emuOp_adc_byte_RM_R(u8 X86EMU_UNUSED(op1))
940 u8 *destreg, *srcreg;
945 DECODE_PRINTF("ADC\t");
946 FETCH_DECODE_MODRM(mod, rh, rl);
949 destoffset = decode_rm00_address(rl);
951 destval = fetch_data_byte(destoffset);
952 srcreg = DECODE_RM_BYTE_REGISTER(rh);
955 destval = adc_byte(destval, *srcreg);
956 store_data_byte(destoffset, destval);
959 destoffset = decode_rm01_address(rl);
961 destval = fetch_data_byte(destoffset);
962 srcreg = DECODE_RM_BYTE_REGISTER(rh);
965 destval = adc_byte(destval, *srcreg);
966 store_data_byte(destoffset, destval);
969 destoffset = decode_rm10_address(rl);
971 destval = fetch_data_byte(destoffset);
972 srcreg = DECODE_RM_BYTE_REGISTER(rh);
975 destval = adc_byte(destval, *srcreg);
976 store_data_byte(destoffset, destval);
978 case 3: /* register to register */
979 destreg = DECODE_RM_BYTE_REGISTER(rl);
981 srcreg = DECODE_RM_BYTE_REGISTER(rh);
984 *destreg = adc_byte(*destreg, *srcreg);
987 DECODE_CLEAR_SEGOVR();
991 /****************************************************************************
994 ****************************************************************************/
995 void x86emuOp_adc_word_RM_R(u8 X86EMU_UNUSED(op1))
1001 DECODE_PRINTF("ADC\t");
1002 FETCH_DECODE_MODRM(mod, rh, rl);
1005 if (M.x86.mode & SYSMODE_PREFIX_DATA) {
1009 destoffset = decode_rm00_address(rl);
1011 destval = fetch_data_long(destoffset);
1012 srcreg = DECODE_RM_LONG_REGISTER(rh);
1013 DECODE_PRINTF("\n");
1015 destval = adc_long(destval, *srcreg);
1016 store_data_long(destoffset, destval);
1021 destoffset = decode_rm00_address(rl);
1023 destval = fetch_data_word(destoffset);
1024 srcreg = DECODE_RM_WORD_REGISTER(rh);
1025 DECODE_PRINTF("\n");
1027 destval = adc_word(destval, *srcreg);
1028 store_data_word(destoffset, destval);
1032 if (M.x86.mode & SYSMODE_PREFIX_DATA) {
1036 destoffset = decode_rm01_address(rl);
1038 destval = fetch_data_long(destoffset);
1039 srcreg = DECODE_RM_LONG_REGISTER(rh);
1040 DECODE_PRINTF("\n");
1042 destval = adc_long(destval, *srcreg);
1043 store_data_long(destoffset, destval);
1048 destoffset = decode_rm01_address(rl);
1050 destval = fetch_data_word(destoffset);
1051 srcreg = DECODE_RM_WORD_REGISTER(rh);
1052 DECODE_PRINTF("\n");
1054 destval = adc_word(destval, *srcreg);
1055 store_data_word(destoffset, destval);
1059 if (M.x86.mode & SYSMODE_PREFIX_DATA) {
1063 destoffset = decode_rm10_address(rl);
1065 destval = fetch_data_long(destoffset);
1066 srcreg = DECODE_RM_LONG_REGISTER(rh);
1067 DECODE_PRINTF("\n");
1069 destval = adc_long(destval, *srcreg);
1070 store_data_long(destoffset, destval);
1075 destoffset = decode_rm10_address(rl);
1077 destval = fetch_data_word(destoffset);
1078 srcreg = DECODE_RM_WORD_REGISTER(rh);
1079 DECODE_PRINTF("\n");
1081 destval = adc_word(destval, *srcreg);
1082 store_data_word(destoffset, destval);
1085 case 3: /* register to register */
1086 if (M.x86.mode & SYSMODE_PREFIX_DATA) {
1087 u32 *destreg,*srcreg;
1089 destreg = DECODE_RM_LONG_REGISTER(rl);
1091 srcreg = DECODE_RM_LONG_REGISTER(rh);
1092 DECODE_PRINTF("\n");
1094 *destreg = adc_long(*destreg, *srcreg);
1096 u16 *destreg,*srcreg;
1098 destreg = DECODE_RM_WORD_REGISTER(rl);
1100 srcreg = DECODE_RM_WORD_REGISTER(rh);
1101 DECODE_PRINTF("\n");
1103 *destreg = adc_word(*destreg, *srcreg);
1107 DECODE_CLEAR_SEGOVR();
1111 /****************************************************************************
1114 ****************************************************************************/
1115 void x86emuOp_adc_byte_R_RM(u8 X86EMU_UNUSED(op1))
1118 u8 *destreg, *srcreg;
1123 DECODE_PRINTF("ADC\t");
1124 FETCH_DECODE_MODRM(mod, rh, rl);
1127 destreg = DECODE_RM_BYTE_REGISTER(rh);
1129 srcoffset = decode_rm00_address(rl);
1130 srcval = fetch_data_byte(srcoffset);
1131 DECODE_PRINTF("\n");
1133 *destreg = adc_byte(*destreg, srcval);
1136 destreg = DECODE_RM_BYTE_REGISTER(rh);
1138 srcoffset = decode_rm01_address(rl);
1139 srcval = fetch_data_byte(srcoffset);
1140 DECODE_PRINTF("\n");
1142 *destreg = adc_byte(*destreg, srcval);
1145 destreg = DECODE_RM_BYTE_REGISTER(rh);
1147 srcoffset = decode_rm10_address(rl);
1148 srcval = fetch_data_byte(srcoffset);
1149 DECODE_PRINTF("\n");
1151 *destreg = adc_byte(*destreg, srcval);
1153 case 3: /* register to register */
1154 destreg = DECODE_RM_BYTE_REGISTER(rh);
1156 srcreg = DECODE_RM_BYTE_REGISTER(rl);
1157 DECODE_PRINTF("\n");
1159 *destreg = adc_byte(*destreg, *srcreg);
1162 DECODE_CLEAR_SEGOVR();
1166 /****************************************************************************
1169 ****************************************************************************/
1170 void x86emuOp_adc_word_R_RM(u8 X86EMU_UNUSED(op1))
1176 DECODE_PRINTF("ADC\t");
1177 FETCH_DECODE_MODRM(mod, rh, rl);
1180 if (M.x86.mode & SYSMODE_PREFIX_DATA) {
1184 destreg = DECODE_RM_LONG_REGISTER(rh);
1186 srcoffset = decode_rm00_address(rl);
1187 srcval = fetch_data_long(srcoffset);
1188 DECODE_PRINTF("\n");
1190 *destreg = adc_long(*destreg, srcval);
1195 destreg = DECODE_RM_WORD_REGISTER(rh);
1197 srcoffset = decode_rm00_address(rl);
1198 srcval = fetch_data_word(srcoffset);
1199 DECODE_PRINTF("\n");
1201 *destreg = adc_word(*destreg, srcval);
1205 if (M.x86.mode & SYSMODE_PREFIX_DATA) {
1209 destreg = DECODE_RM_LONG_REGISTER(rh);
1211 srcoffset = decode_rm01_address(rl);
1212 srcval = fetch_data_long(srcoffset);
1213 DECODE_PRINTF("\n");
1215 *destreg = adc_long(*destreg, srcval);
1220 destreg = DECODE_RM_WORD_REGISTER(rh);
1222 srcoffset = decode_rm01_address(rl);
1223 srcval = fetch_data_word(srcoffset);
1224 DECODE_PRINTF("\n");
1226 *destreg = adc_word(*destreg, srcval);
1230 if (M.x86.mode & SYSMODE_PREFIX_DATA) {
1234 destreg = DECODE_RM_LONG_REGISTER(rh);
1236 srcoffset = decode_rm10_address(rl);
1237 srcval = fetch_data_long(srcoffset);
1238 DECODE_PRINTF("\n");
1240 *destreg = adc_long(*destreg, srcval);
1245 destreg = DECODE_RM_WORD_REGISTER(rh);
1247 srcoffset = decode_rm10_address(rl);
1248 srcval = fetch_data_word(srcoffset);
1249 DECODE_PRINTF("\n");
1251 *destreg = adc_word(*destreg, srcval);
1254 case 3: /* register to register */
1255 if (M.x86.mode & SYSMODE_PREFIX_DATA) {
1256 u32 *destreg,*srcreg;
1258 destreg = DECODE_RM_LONG_REGISTER(rh);
1260 srcreg = DECODE_RM_LONG_REGISTER(rl);
1261 DECODE_PRINTF("\n");
1263 *destreg = adc_long(*destreg, *srcreg);
1265 u16 *destreg,*srcreg;
1267 destreg = DECODE_RM_WORD_REGISTER(rh);
1269 srcreg = DECODE_RM_WORD_REGISTER(rl);
1270 DECODE_PRINTF("\n");
1272 *destreg = adc_word(*destreg, *srcreg);
1276 DECODE_CLEAR_SEGOVR();
1280 /****************************************************************************
1283 ****************************************************************************/
1284 void x86emuOp_adc_byte_AL_IMM(u8 X86EMU_UNUSED(op1))
1289 DECODE_PRINTF("ADC\tAL,");
1290 srcval = fetch_byte_imm();
1291 DECODE_PRINTF2("%x\n", srcval);
1293 M.x86.R_AL = adc_byte(M.x86.R_AL, srcval);
1294 DECODE_CLEAR_SEGOVR();
1298 /****************************************************************************
1301 ****************************************************************************/
1302 void x86emuOp_adc_word_AX_IMM(u8 X86EMU_UNUSED(op1))
1307 if (M.x86.mode & SYSMODE_PREFIX_DATA) {
1308 DECODE_PRINTF("ADC\tEAX,");
1309 srcval = fetch_long_imm();
1311 DECODE_PRINTF("ADC\tAX,");
1312 srcval = fetch_word_imm();
1314 DECODE_PRINTF2("%x\n", srcval);
1316 if (M.x86.mode & SYSMODE_PREFIX_DATA) {
1317 M.x86.R_EAX = adc_long(M.x86.R_EAX, srcval);
1319 M.x86.R_AX = adc_word(M.x86.R_AX, (u16)srcval);
1321 DECODE_CLEAR_SEGOVR();
1325 /****************************************************************************
1328 ****************************************************************************/
1329 void x86emuOp_push_SS(u8 X86EMU_UNUSED(op1))
1332 DECODE_PRINTF("PUSH\tSS\n");
1334 push_word(M.x86.R_SS);
1335 DECODE_CLEAR_SEGOVR();
1339 /****************************************************************************
1342 ****************************************************************************/
1343 void x86emuOp_pop_SS(u8 X86EMU_UNUSED(op1))
1346 DECODE_PRINTF("POP\tSS\n");
1348 M.x86.R_SS = pop_word();
1349 DECODE_CLEAR_SEGOVR();
1353 /****************************************************************************
1356 ****************************************************************************/
1357 void x86emuOp_sbb_byte_RM_R(u8 X86EMU_UNUSED(op1))
1360 u8 *destreg, *srcreg;
1365 DECODE_PRINTF("SBB\t");
1366 FETCH_DECODE_MODRM(mod, rh, rl);
1369 destoffset = decode_rm00_address(rl);
1371 destval = fetch_data_byte(destoffset);
1372 srcreg = DECODE_RM_BYTE_REGISTER(rh);
1373 DECODE_PRINTF("\n");
1375 destval = sbb_byte(destval, *srcreg);
1376 store_data_byte(destoffset, destval);
1379 destoffset = decode_rm01_address(rl);
1381 destval = fetch_data_byte(destoffset);
1382 srcreg = DECODE_RM_BYTE_REGISTER(rh);
1383 DECODE_PRINTF("\n");
1385 destval = sbb_byte(destval, *srcreg);
1386 store_data_byte(destoffset, destval);
1389 destoffset = decode_rm10_address(rl);
1391 destval = fetch_data_byte(destoffset);
1392 srcreg = DECODE_RM_BYTE_REGISTER(rh);
1393 DECODE_PRINTF("\n");
1395 destval = sbb_byte(destval, *srcreg);
1396 store_data_byte(destoffset, destval);
1398 case 3: /* register to register */
1399 destreg = DECODE_RM_BYTE_REGISTER(rl);
1401 srcreg = DECODE_RM_BYTE_REGISTER(rh);
1402 DECODE_PRINTF("\n");
1404 *destreg = sbb_byte(*destreg, *srcreg);
1407 DECODE_CLEAR_SEGOVR();
1411 /****************************************************************************
1414 ****************************************************************************/
1415 void x86emuOp_sbb_word_RM_R(u8 X86EMU_UNUSED(op1))
1421 DECODE_PRINTF("SBB\t");
1422 FETCH_DECODE_MODRM(mod, rh, rl);
1425 if (M.x86.mode & SYSMODE_PREFIX_DATA) {
1429 destoffset = decode_rm00_address(rl);
1431 destval = fetch_data_long(destoffset);
1432 srcreg = DECODE_RM_LONG_REGISTER(rh);
1433 DECODE_PRINTF("\n");
1435 destval = sbb_long(destval, *srcreg);
1436 store_data_long(destoffset, destval);
1441 destoffset = decode_rm00_address(rl);
1443 destval = fetch_data_word(destoffset);
1444 srcreg = DECODE_RM_WORD_REGISTER(rh);
1445 DECODE_PRINTF("\n");
1447 destval = sbb_word(destval, *srcreg);
1448 store_data_word(destoffset, destval);
1452 if (M.x86.mode & SYSMODE_PREFIX_DATA) {
1456 destoffset = decode_rm01_address(rl);
1458 destval = fetch_data_long(destoffset);
1459 srcreg = DECODE_RM_LONG_REGISTER(rh);
1460 DECODE_PRINTF("\n");
1462 destval = sbb_long(destval, *srcreg);
1463 store_data_long(destoffset, destval);
1468 destoffset = decode_rm01_address(rl);
1470 destval = fetch_data_word(destoffset);
1471 srcreg = DECODE_RM_WORD_REGISTER(rh);
1472 DECODE_PRINTF("\n");
1474 destval = sbb_word(destval, *srcreg);
1475 store_data_word(destoffset, destval);
1479 if (M.x86.mode & SYSMODE_PREFIX_DATA) {
1483 destoffset = decode_rm10_address(rl);
1485 destval = fetch_data_long(destoffset);
1486 srcreg = DECODE_RM_LONG_REGISTER(rh);
1487 DECODE_PRINTF("\n");
1489 destval = sbb_long(destval, *srcreg);
1490 store_data_long(destoffset, destval);
1495 destoffset = decode_rm10_address(rl);
1497 destval = fetch_data_word(destoffset);
1498 srcreg = DECODE_RM_WORD_REGISTER(rh);
1499 DECODE_PRINTF("\n");
1501 destval = sbb_word(destval, *srcreg);
1502 store_data_word(destoffset, destval);
1505 case 3: /* register to register */
1506 if (M.x86.mode & SYSMODE_PREFIX_DATA) {
1507 u32 *destreg,*srcreg;
1509 destreg = DECODE_RM_LONG_REGISTER(rl);
1511 srcreg = DECODE_RM_LONG_REGISTER(rh);
1512 DECODE_PRINTF("\n");
1514 *destreg = sbb_long(*destreg, *srcreg);
1516 u16 *destreg,*srcreg;
1518 destreg = DECODE_RM_WORD_REGISTER(rl);
1520 srcreg = DECODE_RM_WORD_REGISTER(rh);
1521 DECODE_PRINTF("\n");
1523 *destreg = sbb_word(*destreg, *srcreg);
1527 DECODE_CLEAR_SEGOVR();
1531 /****************************************************************************
1534 ****************************************************************************/
1535 void x86emuOp_sbb_byte_R_RM(u8 X86EMU_UNUSED(op1))
1538 u8 *destreg, *srcreg;
1543 DECODE_PRINTF("SBB\t");
1544 FETCH_DECODE_MODRM(mod, rh, rl);
1547 destreg = DECODE_RM_BYTE_REGISTER(rh);
1549 srcoffset = decode_rm00_address(rl);
1550 srcval = fetch_data_byte(srcoffset);
1551 DECODE_PRINTF("\n");
1553 *destreg = sbb_byte(*destreg, srcval);
1556 destreg = DECODE_RM_BYTE_REGISTER(rh);
1558 srcoffset = decode_rm01_address(rl);
1559 srcval = fetch_data_byte(srcoffset);
1560 DECODE_PRINTF("\n");
1562 *destreg = sbb_byte(*destreg, srcval);
1565 destreg = DECODE_RM_BYTE_REGISTER(rh);
1567 srcoffset = decode_rm10_address(rl);
1568 srcval = fetch_data_byte(srcoffset);
1569 DECODE_PRINTF("\n");
1571 *destreg = sbb_byte(*destreg, srcval);
1573 case 3: /* register to register */
1574 destreg = DECODE_RM_BYTE_REGISTER(rh);
1576 srcreg = DECODE_RM_BYTE_REGISTER(rl);
1577 DECODE_PRINTF("\n");
1579 *destreg = sbb_byte(*destreg, *srcreg);
1582 DECODE_CLEAR_SEGOVR();
1586 /****************************************************************************
1589 ****************************************************************************/
1590 void x86emuOp_sbb_word_R_RM(u8 X86EMU_UNUSED(op1))
1596 DECODE_PRINTF("SBB\t");
1597 FETCH_DECODE_MODRM(mod, rh, rl);
1600 if (M.x86.mode & SYSMODE_PREFIX_DATA) {
1604 destreg = DECODE_RM_LONG_REGISTER(rh);
1606 srcoffset = decode_rm00_address(rl);
1607 srcval = fetch_data_long(srcoffset);
1608 DECODE_PRINTF("\n");
1610 *destreg = sbb_long(*destreg, srcval);
1615 destreg = DECODE_RM_WORD_REGISTER(rh);
1617 srcoffset = decode_rm00_address(rl);
1618 srcval = fetch_data_word(srcoffset);
1619 DECODE_PRINTF("\n");
1621 *destreg = sbb_word(*destreg, srcval);
1625 if (M.x86.mode & SYSMODE_PREFIX_DATA) {
1629 destreg = DECODE_RM_LONG_REGISTER(rh);
1631 srcoffset = decode_rm01_address(rl);
1632 srcval = fetch_data_long(srcoffset);
1633 DECODE_PRINTF("\n");
1635 *destreg = sbb_long(*destreg, srcval);
1640 destreg = DECODE_RM_WORD_REGISTER(rh);
1642 srcoffset = decode_rm01_address(rl);
1643 srcval = fetch_data_word(srcoffset);
1644 DECODE_PRINTF("\n");
1646 *destreg = sbb_word(*destreg, srcval);
1650 if (M.x86.mode & SYSMODE_PREFIX_DATA) {
1654 destreg = DECODE_RM_LONG_REGISTER(rh);
1656 srcoffset = decode_rm10_address(rl);
1657 srcval = fetch_data_long(srcoffset);
1658 DECODE_PRINTF("\n");
1660 *destreg = sbb_long(*destreg, srcval);
1665 destreg = DECODE_RM_WORD_REGISTER(rh);
1667 srcoffset = decode_rm10_address(rl);
1668 srcval = fetch_data_word(srcoffset);
1669 DECODE_PRINTF("\n");
1671 *destreg = sbb_word(*destreg, srcval);
1674 case 3: /* register to register */
1675 if (M.x86.mode & SYSMODE_PREFIX_DATA) {
1676 u32 *destreg,*srcreg;
1678 destreg = DECODE_RM_LONG_REGISTER(rh);
1680 srcreg = DECODE_RM_LONG_REGISTER(rl);
1681 DECODE_PRINTF("\n");
1683 *destreg = sbb_long(*destreg, *srcreg);
1685 u16 *destreg,*srcreg;
1687 destreg = DECODE_RM_WORD_REGISTER(rh);
1689 srcreg = DECODE_RM_WORD_REGISTER(rl);
1690 DECODE_PRINTF("\n");
1692 *destreg = sbb_word(*destreg, *srcreg);
1696 DECODE_CLEAR_SEGOVR();
1700 /****************************************************************************
1703 ****************************************************************************/
1704 void x86emuOp_sbb_byte_AL_IMM(u8 X86EMU_UNUSED(op1))
1709 DECODE_PRINTF("SBB\tAL,");
1710 srcval = fetch_byte_imm();
1711 DECODE_PRINTF2("%x\n", srcval);
1713 M.x86.R_AL = sbb_byte(M.x86.R_AL, srcval);
1714 DECODE_CLEAR_SEGOVR();
1718 /****************************************************************************
1721 ****************************************************************************/
1722 void x86emuOp_sbb_word_AX_IMM(u8 X86EMU_UNUSED(op1))
1727 if (M.x86.mode & SYSMODE_PREFIX_DATA) {
1728 DECODE_PRINTF("SBB\tEAX,");
1729 srcval = fetch_long_imm();
1731 DECODE_PRINTF("SBB\tAX,");
1732 srcval = fetch_word_imm();
1734 DECODE_PRINTF2("%x\n", srcval);
1736 if (M.x86.mode & SYSMODE_PREFIX_DATA) {
1737 M.x86.R_EAX = sbb_long(M.x86.R_EAX, srcval);
1739 M.x86.R_AX = sbb_word(M.x86.R_AX, (u16)srcval);
1741 DECODE_CLEAR_SEGOVR();
1745 /****************************************************************************
1748 ****************************************************************************/
1749 void x86emuOp_push_DS(u8 X86EMU_UNUSED(op1))
1752 DECODE_PRINTF("PUSH\tDS\n");
1754 push_word(M.x86.R_DS);
1755 DECODE_CLEAR_SEGOVR();
1759 /****************************************************************************
1762 ****************************************************************************/
1763 void x86emuOp_pop_DS(u8 X86EMU_UNUSED(op1))
1766 DECODE_PRINTF("POP\tDS\n");
1768 M.x86.R_DS = pop_word();
1769 DECODE_CLEAR_SEGOVR();
1773 /****************************************************************************
1776 ****************************************************************************/
1777 void x86emuOp_and_byte_RM_R(u8 X86EMU_UNUSED(op1))
1780 u8 *destreg, *srcreg;
1785 DECODE_PRINTF("AND\t");
1786 FETCH_DECODE_MODRM(mod, rh, rl);
1790 destoffset = decode_rm00_address(rl);
1792 destval = fetch_data_byte(destoffset);
1793 srcreg = DECODE_RM_BYTE_REGISTER(rh);
1794 DECODE_PRINTF("\n");
1796 destval = and_byte(destval, *srcreg);
1797 store_data_byte(destoffset, destval);
1801 destoffset = decode_rm01_address(rl);
1803 destval = fetch_data_byte(destoffset);
1804 srcreg = DECODE_RM_BYTE_REGISTER(rh);
1805 DECODE_PRINTF("\n");
1807 destval = and_byte(destval, *srcreg);
1808 store_data_byte(destoffset, destval);
1812 destoffset = decode_rm10_address(rl);
1814 destval = fetch_data_byte(destoffset);
1815 srcreg = DECODE_RM_BYTE_REGISTER(rh);
1816 DECODE_PRINTF("\n");
1818 destval = and_byte(destval, *srcreg);
1819 store_data_byte(destoffset, destval);
1822 case 3: /* register to register */
1823 destreg = DECODE_RM_BYTE_REGISTER(rl);
1825 srcreg = DECODE_RM_BYTE_REGISTER(rh);
1826 DECODE_PRINTF("\n");
1828 *destreg = and_byte(*destreg, *srcreg);
1831 DECODE_CLEAR_SEGOVR();
1835 /****************************************************************************
1838 ****************************************************************************/
1839 void x86emuOp_and_word_RM_R(u8 X86EMU_UNUSED(op1))
1845 DECODE_PRINTF("AND\t");
1846 FETCH_DECODE_MODRM(mod, rh, rl);
1849 if (M.x86.mode & SYSMODE_PREFIX_DATA) {
1853 destoffset = decode_rm00_address(rl);
1855 destval = fetch_data_long(destoffset);
1856 srcreg = DECODE_RM_LONG_REGISTER(rh);
1857 DECODE_PRINTF("\n");
1859 destval = and_long(destval, *srcreg);
1860 store_data_long(destoffset, destval);
1865 destoffset = decode_rm00_address(rl);
1867 destval = fetch_data_word(destoffset);
1868 srcreg = DECODE_RM_WORD_REGISTER(rh);
1869 DECODE_PRINTF("\n");
1871 destval = and_word(destval, *srcreg);
1872 store_data_word(destoffset, destval);
1876 if (M.x86.mode & SYSMODE_PREFIX_DATA) {
1880 destoffset = decode_rm01_address(rl);
1882 destval = fetch_data_long(destoffset);
1883 srcreg = DECODE_RM_LONG_REGISTER(rh);
1884 DECODE_PRINTF("\n");
1886 destval = and_long(destval, *srcreg);
1887 store_data_long(destoffset, destval);
1892 destoffset = decode_rm01_address(rl);
1894 destval = fetch_data_word(destoffset);
1895 srcreg = DECODE_RM_WORD_REGISTER(rh);
1896 DECODE_PRINTF("\n");
1898 destval = and_word(destval, *srcreg);
1899 store_data_word(destoffset, destval);
1903 if (M.x86.mode & SYSMODE_PREFIX_DATA) {
1907 destoffset = decode_rm10_address(rl);
1909 destval = fetch_data_long(destoffset);
1910 srcreg = DECODE_RM_LONG_REGISTER(rh);
1911 DECODE_PRINTF("\n");
1913 destval = and_long(destval, *srcreg);
1914 store_data_long(destoffset, destval);
1919 destoffset = decode_rm10_address(rl);
1921 destval = fetch_data_word(destoffset);
1922 srcreg = DECODE_RM_WORD_REGISTER(rh);
1923 DECODE_PRINTF("\n");
1925 destval = and_word(destval, *srcreg);
1926 store_data_word(destoffset, destval);
1929 case 3: /* register to register */
1930 if (M.x86.mode & SYSMODE_PREFIX_DATA) {
1931 u32 *destreg,*srcreg;
1933 destreg = DECODE_RM_LONG_REGISTER(rl);
1935 srcreg = DECODE_RM_LONG_REGISTER(rh);
1936 DECODE_PRINTF("\n");
1938 *destreg = and_long(*destreg, *srcreg);
1940 u16 *destreg,*srcreg;
1942 destreg = DECODE_RM_WORD_REGISTER(rl);
1944 srcreg = DECODE_RM_WORD_REGISTER(rh);
1945 DECODE_PRINTF("\n");
1947 *destreg = and_word(*destreg, *srcreg);
1951 DECODE_CLEAR_SEGOVR();
1955 /****************************************************************************
1958 ****************************************************************************/
1959 void x86emuOp_and_byte_R_RM(u8 X86EMU_UNUSED(op1))
1962 u8 *destreg, *srcreg;
1967 DECODE_PRINTF("AND\t");
1968 FETCH_DECODE_MODRM(mod, rh, rl);
1971 destreg = DECODE_RM_BYTE_REGISTER(rh);
1973 srcoffset = decode_rm00_address(rl);
1974 srcval = fetch_data_byte(srcoffset);
1975 DECODE_PRINTF("\n");
1977 *destreg = and_byte(*destreg, srcval);
1980 destreg = DECODE_RM_BYTE_REGISTER(rh);
1982 srcoffset = decode_rm01_address(rl);
1983 srcval = fetch_data_byte(srcoffset);
1984 DECODE_PRINTF("\n");
1986 *destreg = and_byte(*destreg, srcval);
1989 destreg = DECODE_RM_BYTE_REGISTER(rh);
1991 srcoffset = decode_rm10_address(rl);
1992 srcval = fetch_data_byte(srcoffset);
1993 DECODE_PRINTF("\n");
1995 *destreg = and_byte(*destreg, srcval);
1997 case 3: /* register to register */
1998 destreg = DECODE_RM_BYTE_REGISTER(rh);
2000 srcreg = DECODE_RM_BYTE_REGISTER(rl);
2001 DECODE_PRINTF("\n");
2003 *destreg = and_byte(*destreg, *srcreg);
2006 DECODE_CLEAR_SEGOVR();
2010 /****************************************************************************
2013 ****************************************************************************/
2014 void x86emuOp_and_word_R_RM(u8 X86EMU_UNUSED(op1))
2020 DECODE_PRINTF("AND\t");
2021 FETCH_DECODE_MODRM(mod, rh, rl);
2024 if (M.x86.mode & SYSMODE_PREFIX_DATA) {
2028 destreg = DECODE_RM_LONG_REGISTER(rh);
2030 srcoffset = decode_rm00_address(rl);
2031 srcval = fetch_data_long(srcoffset);
2032 DECODE_PRINTF("\n");
2034 *destreg = and_long(*destreg, srcval);
2039 destreg = DECODE_RM_WORD_REGISTER(rh);
2041 srcoffset = decode_rm00_address(rl);
2042 srcval = fetch_data_word(srcoffset);
2043 DECODE_PRINTF("\n");
2045 *destreg = and_word(*destreg, srcval);
2049 if (M.x86.mode & SYSMODE_PREFIX_DATA) {
2053 destreg = DECODE_RM_LONG_REGISTER(rh);
2055 srcoffset = decode_rm01_address(rl);
2056 srcval = fetch_data_long(srcoffset);
2057 DECODE_PRINTF("\n");
2059 *destreg = and_long(*destreg, srcval);
2065 destreg = DECODE_RM_WORD_REGISTER(rh);
2067 srcoffset = decode_rm01_address(rl);
2068 srcval = fetch_data_word(srcoffset);
2069 DECODE_PRINTF("\n");
2071 *destreg = and_word(*destreg, srcval);
2075 if (M.x86.mode & SYSMODE_PREFIX_DATA) {
2079 destreg = DECODE_RM_LONG_REGISTER(rh);
2081 srcoffset = decode_rm10_address(rl);
2082 srcval = fetch_data_long(srcoffset);
2083 DECODE_PRINTF("\n");
2085 *destreg = and_long(*destreg, srcval);
2090 destreg = DECODE_RM_WORD_REGISTER(rh);
2092 srcoffset = decode_rm10_address(rl);
2093 srcval = fetch_data_word(srcoffset);
2094 DECODE_PRINTF("\n");
2096 *destreg = and_word(*destreg, srcval);
2099 case 3: /* register to register */
2100 if (M.x86.mode & SYSMODE_PREFIX_DATA) {
2101 u32 *destreg,*srcreg;
2103 destreg = DECODE_RM_LONG_REGISTER(rh);
2105 srcreg = DECODE_RM_LONG_REGISTER(rl);
2106 DECODE_PRINTF("\n");
2108 *destreg = and_long(*destreg, *srcreg);
2110 u16 *destreg,*srcreg;
2112 destreg = DECODE_RM_WORD_REGISTER(rh);
2114 srcreg = DECODE_RM_WORD_REGISTER(rl);
2115 DECODE_PRINTF("\n");
2117 *destreg = and_word(*destreg, *srcreg);
2121 DECODE_CLEAR_SEGOVR();
2125 /****************************************************************************
2128 ****************************************************************************/
2129 void x86emuOp_and_byte_AL_IMM(u8 X86EMU_UNUSED(op1))
2134 DECODE_PRINTF("AND\tAL,");
2135 srcval = fetch_byte_imm();
2136 DECODE_PRINTF2("%x\n", srcval);
2138 M.x86.R_AL = and_byte(M.x86.R_AL, srcval);
2139 DECODE_CLEAR_SEGOVR();
2143 /****************************************************************************
2146 ****************************************************************************/
2147 void x86emuOp_and_word_AX_IMM(u8 X86EMU_UNUSED(op1))
2152 if (M.x86.mode & SYSMODE_PREFIX_DATA) {
2153 DECODE_PRINTF("AND\tEAX,");
2154 srcval = fetch_long_imm();
2156 DECODE_PRINTF("AND\tAX,");
2157 srcval = fetch_word_imm();
2159 DECODE_PRINTF2("%x\n", srcval);
2161 if (M.x86.mode & SYSMODE_PREFIX_DATA) {
2162 M.x86.R_EAX = and_long(M.x86.R_EAX, srcval);
2164 M.x86.R_AX = and_word(M.x86.R_AX, (u16)srcval);
2166 DECODE_CLEAR_SEGOVR();
2170 /****************************************************************************
2173 ****************************************************************************/
2174 void x86emuOp_segovr_ES(u8 X86EMU_UNUSED(op1))
2177 DECODE_PRINTF("ES:\n");
2179 M.x86.mode |= SYSMODE_SEGOVR_ES;
2181 * note the lack of DECODE_CLEAR_SEGOVR(r) since, here is one of 4
2182 * opcode subroutines we do not want to do this.
2187 /****************************************************************************
2190 ****************************************************************************/
2191 void x86emuOp_daa(u8 X86EMU_UNUSED(op1))
2194 DECODE_PRINTF("DAA\n");
2196 M.x86.R_AL = daa_byte(M.x86.R_AL);
2197 DECODE_CLEAR_SEGOVR();
2201 /****************************************************************************
2204 ****************************************************************************/
2205 void x86emuOp_sub_byte_RM_R(u8 X86EMU_UNUSED(op1))
2208 u8 *destreg, *srcreg;
2213 DECODE_PRINTF("SUB\t");
2214 FETCH_DECODE_MODRM(mod, rh, rl);
2217 destoffset = decode_rm00_address(rl);
2219 destval = fetch_data_byte(destoffset);
2220 srcreg = DECODE_RM_BYTE_REGISTER(rh);
2221 DECODE_PRINTF("\n");
2223 destval = sub_byte(destval, *srcreg);
2224 store_data_byte(destoffset, destval);
2227 destoffset = decode_rm01_address(rl);
2229 destval = fetch_data_byte(destoffset);
2230 srcreg = DECODE_RM_BYTE_REGISTER(rh);
2231 DECODE_PRINTF("\n");
2233 destval = sub_byte(destval, *srcreg);
2234 store_data_byte(destoffset, destval);
2237 destoffset = decode_rm10_address(rl);
2239 destval = fetch_data_byte(destoffset);
2240 srcreg = DECODE_RM_BYTE_REGISTER(rh);
2241 DECODE_PRINTF("\n");
2243 destval = sub_byte(destval, *srcreg);
2244 store_data_byte(destoffset, destval);
2246 case 3: /* register to register */
2247 destreg = DECODE_RM_BYTE_REGISTER(rl);
2249 srcreg = DECODE_RM_BYTE_REGISTER(rh);
2250 DECODE_PRINTF("\n");
2252 *destreg = sub_byte(*destreg, *srcreg);
2255 DECODE_CLEAR_SEGOVR();
2259 /****************************************************************************
2262 ****************************************************************************/
2263 void x86emuOp_sub_word_RM_R(u8 X86EMU_UNUSED(op1))
2269 DECODE_PRINTF("SUB\t");
2270 FETCH_DECODE_MODRM(mod, rh, rl);
2273 if (M.x86.mode & SYSMODE_PREFIX_DATA) {
2277 destoffset = decode_rm00_address(rl);
2279 destval = fetch_data_long(destoffset);
2280 srcreg = DECODE_RM_LONG_REGISTER(rh);
2281 DECODE_PRINTF("\n");
2283 destval = sub_long(destval, *srcreg);
2284 store_data_long(destoffset, destval);
2289 destoffset = decode_rm00_address(rl);
2291 destval = fetch_data_word(destoffset);
2292 srcreg = DECODE_RM_WORD_REGISTER(rh);
2293 DECODE_PRINTF("\n");
2295 destval = sub_word(destval, *srcreg);
2296 store_data_word(destoffset, destval);
2300 if (M.x86.mode & SYSMODE_PREFIX_DATA) {
2304 destoffset = decode_rm01_address(rl);
2306 destval = fetch_data_long(destoffset);
2307 srcreg = DECODE_RM_LONG_REGISTER(rh);
2308 DECODE_PRINTF("\n");
2310 destval = sub_long(destval, *srcreg);
2311 store_data_long(destoffset, destval);
2316 destoffset = decode_rm01_address(rl);
2318 destval = fetch_data_word(destoffset);
2319 srcreg = DECODE_RM_WORD_REGISTER(rh);
2320 DECODE_PRINTF("\n");
2322 destval = sub_word(destval, *srcreg);
2323 store_data_word(destoffset, destval);
2327 if (M.x86.mode & SYSMODE_PREFIX_DATA) {
2331 destoffset = decode_rm10_address(rl);
2333 destval = fetch_data_long(destoffset);
2334 srcreg = DECODE_RM_LONG_REGISTER(rh);
2335 DECODE_PRINTF("\n");
2337 destval = sub_long(destval, *srcreg);
2338 store_data_long(destoffset, destval);
2343 destoffset = decode_rm10_address(rl);
2345 destval = fetch_data_word(destoffset);
2346 srcreg = DECODE_RM_WORD_REGISTER(rh);
2347 DECODE_PRINTF("\n");
2349 destval = sub_word(destval, *srcreg);
2350 store_data_word(destoffset, destval);
2353 case 3: /* register to register */
2354 if (M.x86.mode & SYSMODE_PREFIX_DATA) {
2355 u32 *destreg,*srcreg;
2357 destreg = DECODE_RM_LONG_REGISTER(rl);
2359 srcreg = DECODE_RM_LONG_REGISTER(rh);
2360 DECODE_PRINTF("\n");
2362 *destreg = sub_long(*destreg, *srcreg);
2364 u16 *destreg,*srcreg;
2366 destreg = DECODE_RM_WORD_REGISTER(rl);
2368 srcreg = DECODE_RM_WORD_REGISTER(rh);
2369 DECODE_PRINTF("\n");
2371 *destreg = sub_word(*destreg, *srcreg);
2375 DECODE_CLEAR_SEGOVR();
2379 /****************************************************************************
2382 ****************************************************************************/
2383 void x86emuOp_sub_byte_R_RM(u8 X86EMU_UNUSED(op1))
2386 u8 *destreg, *srcreg;
2391 DECODE_PRINTF("SUB\t");
2392 FETCH_DECODE_MODRM(mod, rh, rl);
2395 destreg = DECODE_RM_BYTE_REGISTER(rh);
2397 srcoffset = decode_rm00_address(rl);
2398 srcval = fetch_data_byte(srcoffset);
2399 DECODE_PRINTF("\n");
2401 *destreg = sub_byte(*destreg, srcval);
2404 destreg = DECODE_RM_BYTE_REGISTER(rh);
2406 srcoffset = decode_rm01_address(rl);
2407 srcval = fetch_data_byte(srcoffset);
2408 DECODE_PRINTF("\n");
2410 *destreg = sub_byte(*destreg, srcval);
2413 destreg = DECODE_RM_BYTE_REGISTER(rh);
2415 srcoffset = decode_rm10_address(rl);
2416 srcval = fetch_data_byte(srcoffset);
2417 DECODE_PRINTF("\n");
2419 *destreg = sub_byte(*destreg, srcval);
2421 case 3: /* register to register */
2422 destreg = DECODE_RM_BYTE_REGISTER(rh);
2424 srcreg = DECODE_RM_BYTE_REGISTER(rl);
2425 DECODE_PRINTF("\n");
2427 *destreg = sub_byte(*destreg, *srcreg);
2430 DECODE_CLEAR_SEGOVR();
2434 /****************************************************************************
2437 ****************************************************************************/
2438 void x86emuOp_sub_word_R_RM(u8 X86EMU_UNUSED(op1))
2444 DECODE_PRINTF("SUB\t");
2445 FETCH_DECODE_MODRM(mod, rh, rl);
2448 if (M.x86.mode & SYSMODE_PREFIX_DATA) {
2452 destreg = DECODE_RM_LONG_REGISTER(rh);
2454 srcoffset = decode_rm00_address(rl);
2455 srcval = fetch_data_long(srcoffset);
2456 DECODE_PRINTF("\n");
2458 *destreg = sub_long(*destreg, srcval);
2463 destreg = DECODE_RM_WORD_REGISTER(rh);
2465 srcoffset = decode_rm00_address(rl);
2466 srcval = fetch_data_word(srcoffset);
2467 DECODE_PRINTF("\n");
2469 *destreg = sub_word(*destreg, srcval);
2473 if (M.x86.mode & SYSMODE_PREFIX_DATA) {
2477 destreg = DECODE_RM_LONG_REGISTER(rh);
2479 srcoffset = decode_rm01_address(rl);
2480 srcval = fetch_data_long(srcoffset);
2481 DECODE_PRINTF("\n");
2483 *destreg = sub_long(*destreg, srcval);
2488 destreg = DECODE_RM_WORD_REGISTER(rh);
2490 srcoffset = decode_rm01_address(rl);
2491 srcval = fetch_data_word(srcoffset);
2492 DECODE_PRINTF("\n");
2494 *destreg = sub_word(*destreg, srcval);
2498 if (M.x86.mode & SYSMODE_PREFIX_DATA) {
2502 destreg = DECODE_RM_LONG_REGISTER(rh);
2504 srcoffset = decode_rm10_address(rl);
2505 srcval = fetch_data_long(srcoffset);
2506 DECODE_PRINTF("\n");
2508 *destreg = sub_long(*destreg, srcval);
2513 destreg = DECODE_RM_WORD_REGISTER(rh);
2515 srcoffset = decode_rm10_address(rl);
2516 srcval = fetch_data_word(srcoffset);
2517 DECODE_PRINTF("\n");
2519 *destreg = sub_word(*destreg, srcval);
2522 case 3: /* register to register */
2523 if (M.x86.mode & SYSMODE_PREFIX_DATA) {
2524 u32 *destreg,*srcreg;
2526 destreg = DECODE_RM_LONG_REGISTER(rh);
2528 srcreg = DECODE_RM_LONG_REGISTER(rl);
2529 DECODE_PRINTF("\n");
2531 *destreg = sub_long(*destreg, *srcreg);
2533 u16 *destreg,*srcreg;
2535 destreg = DECODE_RM_WORD_REGISTER(rh);
2537 srcreg = DECODE_RM_WORD_REGISTER(rl);
2538 DECODE_PRINTF("\n");
2540 *destreg = sub_word(*destreg, *srcreg);
2544 DECODE_CLEAR_SEGOVR();
2548 /****************************************************************************
2551 ****************************************************************************/
2552 void x86emuOp_sub_byte_AL_IMM(u8 X86EMU_UNUSED(op1))
2557 DECODE_PRINTF("SUB\tAL,");
2558 srcval = fetch_byte_imm();
2559 DECODE_PRINTF2("%x\n", srcval);
2561 M.x86.R_AL = sub_byte(M.x86.R_AL, srcval);
2562 DECODE_CLEAR_SEGOVR();
2566 /****************************************************************************
2569 ****************************************************************************/
2570 void x86emuOp_sub_word_AX_IMM(u8 X86EMU_UNUSED(op1))
2575 if (M.x86.mode & SYSMODE_PREFIX_DATA) {
2576 DECODE_PRINTF("SUB\tEAX,");
2577 srcval = fetch_long_imm();
2579 DECODE_PRINTF("SUB\tAX,");
2580 srcval = fetch_word_imm();
2582 DECODE_PRINTF2("%x\n", srcval);
2584 if (M.x86.mode & SYSMODE_PREFIX_DATA) {
2585 M.x86.R_EAX = sub_long(M.x86.R_EAX, srcval);
2587 M.x86.R_AX = sub_word(M.x86.R_AX, (u16)srcval);
2589 DECODE_CLEAR_SEGOVR();
2593 /****************************************************************************
2596 ****************************************************************************/
2597 void x86emuOp_segovr_CS(u8 X86EMU_UNUSED(op1))
2600 DECODE_PRINTF("CS:\n");
2602 M.x86.mode |= SYSMODE_SEGOVR_CS;
2603 /* note no DECODE_CLEAR_SEGOVR here. */
2607 /****************************************************************************
2610 ****************************************************************************/
2611 void x86emuOp_das(u8 X86EMU_UNUSED(op1))
2614 DECODE_PRINTF("DAS\n");
2616 M.x86.R_AL = das_byte(M.x86.R_AL);
2617 DECODE_CLEAR_SEGOVR();
2621 /****************************************************************************
2624 ****************************************************************************/
2625 void x86emuOp_xor_byte_RM_R(u8 X86EMU_UNUSED(op1))
2628 u8 *destreg, *srcreg;
2633 DECODE_PRINTF("XOR\t");
2634 FETCH_DECODE_MODRM(mod, rh, rl);
2637 destoffset = decode_rm00_address(rl);
2639 destval = fetch_data_byte(destoffset);
2640 srcreg = DECODE_RM_BYTE_REGISTER(rh);
2641 DECODE_PRINTF("\n");
2643 destval = xor_byte(destval, *srcreg);
2644 store_data_byte(destoffset, destval);
2647 destoffset = decode_rm01_address(rl);
2649 destval = fetch_data_byte(destoffset);
2650 srcreg = DECODE_RM_BYTE_REGISTER(rh);
2651 DECODE_PRINTF("\n");
2653 destval = xor_byte(destval, *srcreg);
2654 store_data_byte(destoffset, destval);
2657 destoffset = decode_rm10_address(rl);
2659 destval = fetch_data_byte(destoffset);
2660 srcreg = DECODE_RM_BYTE_REGISTER(rh);
2661 DECODE_PRINTF("\n");
2663 destval = xor_byte(destval, *srcreg);
2664 store_data_byte(destoffset, destval);
2666 case 3: /* register to register */
2667 destreg = DECODE_RM_BYTE_REGISTER(rl);
2669 srcreg = DECODE_RM_BYTE_REGISTER(rh);
2670 DECODE_PRINTF("\n");
2672 *destreg = xor_byte(*destreg, *srcreg);
2675 DECODE_CLEAR_SEGOVR();
2679 /****************************************************************************
2682 ****************************************************************************/
2683 void x86emuOp_xor_word_RM_R(u8 X86EMU_UNUSED(op1))
2689 DECODE_PRINTF("XOR\t");
2690 FETCH_DECODE_MODRM(mod, rh, rl);
2693 if (M.x86.mode & SYSMODE_PREFIX_DATA) {
2697 destoffset = decode_rm00_address(rl);
2699 destval = fetch_data_long(destoffset);
2700 srcreg = DECODE_RM_LONG_REGISTER(rh);
2701 DECODE_PRINTF("\n");
2703 destval = xor_long(destval, *srcreg);
2704 store_data_long(destoffset, destval);
2709 destoffset = decode_rm00_address(rl);
2711 destval = fetch_data_word(destoffset);
2712 srcreg = DECODE_RM_WORD_REGISTER(rh);
2713 DECODE_PRINTF("\n");
2715 destval = xor_word(destval, *srcreg);
2716 store_data_word(destoffset, destval);
2720 if (M.x86.mode & SYSMODE_PREFIX_DATA) {
2724 destoffset = decode_rm01_address(rl);
2726 destval = fetch_data_long(destoffset);
2727 srcreg = DECODE_RM_LONG_REGISTER(rh);
2728 DECODE_PRINTF("\n");
2730 destval = xor_long(destval, *srcreg);
2731 store_data_long(destoffset, destval);
2736 destoffset = decode_rm01_address(rl);
2738 destval = fetch_data_word(destoffset);
2739 srcreg = DECODE_RM_WORD_REGISTER(rh);
2740 DECODE_PRINTF("\n");
2742 destval = xor_word(destval, *srcreg);
2743 store_data_word(destoffset, destval);
2747 if (M.x86.mode & SYSMODE_PREFIX_DATA) {
2751 destoffset = decode_rm10_address(rl);
2753 destval = fetch_data_long(destoffset);
2754 srcreg = DECODE_RM_LONG_REGISTER(rh);
2755 DECODE_PRINTF("\n");
2757 destval = xor_long(destval, *srcreg);
2758 store_data_long(destoffset, destval);
2763 destoffset = decode_rm10_address(rl);
2765 destval = fetch_data_word(destoffset);
2766 srcreg = DECODE_RM_WORD_REGISTER(rh);
2767 DECODE_PRINTF("\n");
2769 destval = xor_word(destval, *srcreg);
2770 store_data_word(destoffset, destval);
2773 case 3: /* register to register */
2774 if (M.x86.mode & SYSMODE_PREFIX_DATA) {
2775 u32 *destreg,*srcreg;
2777 destreg = DECODE_RM_LONG_REGISTER(rl);
2779 srcreg = DECODE_RM_LONG_REGISTER(rh);
2780 DECODE_PRINTF("\n");
2782 *destreg = xor_long(*destreg, *srcreg);
2784 u16 *destreg,*srcreg;
2786 destreg = DECODE_RM_WORD_REGISTER(rl);
2788 srcreg = DECODE_RM_WORD_REGISTER(rh);
2789 DECODE_PRINTF("\n");
2791 *destreg = xor_word(*destreg, *srcreg);
2795 DECODE_CLEAR_SEGOVR();
2799 /****************************************************************************
2802 ****************************************************************************/
2803 void x86emuOp_xor_byte_R_RM(u8 X86EMU_UNUSED(op1))
2806 u8 *destreg, *srcreg;
2811 DECODE_PRINTF("XOR\t");
2812 FETCH_DECODE_MODRM(mod, rh, rl);
2815 destreg = DECODE_RM_BYTE_REGISTER(rh);
2817 srcoffset = decode_rm00_address(rl);
2818 srcval = fetch_data_byte(srcoffset);
2819 DECODE_PRINTF("\n");
2821 *destreg = xor_byte(*destreg, srcval);
2824 destreg = DECODE_RM_BYTE_REGISTER(rh);
2826 srcoffset = decode_rm01_address(rl);
2827 srcval = fetch_data_byte(srcoffset);
2828 DECODE_PRINTF("\n");
2830 *destreg = xor_byte(*destreg, srcval);
2833 destreg = DECODE_RM_BYTE_REGISTER(rh);
2835 srcoffset = decode_rm10_address(rl);
2836 srcval = fetch_data_byte(srcoffset);
2837 DECODE_PRINTF("\n");
2839 *destreg = xor_byte(*destreg, srcval);
2841 case 3: /* register to register */
2842 destreg = DECODE_RM_BYTE_REGISTER(rh);
2844 srcreg = DECODE_RM_BYTE_REGISTER(rl);
2845 DECODE_PRINTF("\n");
2847 *destreg = xor_byte(*destreg, *srcreg);
2850 DECODE_CLEAR_SEGOVR();
2854 /****************************************************************************
2857 ****************************************************************************/
2858 void x86emuOp_xor_word_R_RM(u8 X86EMU_UNUSED(op1))
2864 DECODE_PRINTF("XOR\t");
2865 FETCH_DECODE_MODRM(mod, rh, rl);
2868 if (M.x86.mode & SYSMODE_PREFIX_DATA) {
2872 destreg = DECODE_RM_LONG_REGISTER(rh);
2874 srcoffset = decode_rm00_address(rl);
2875 srcval = fetch_data_long(srcoffset);
2876 DECODE_PRINTF("\n");
2878 *destreg = xor_long(*destreg, srcval);
2883 destreg = DECODE_RM_WORD_REGISTER(rh);
2885 srcoffset = decode_rm00_address(rl);
2886 srcval = fetch_data_word(srcoffset);
2887 DECODE_PRINTF("\n");
2889 *destreg = xor_word(*destreg, srcval);
2893 if (M.x86.mode & SYSMODE_PREFIX_DATA) {
2897 destreg = DECODE_RM_LONG_REGISTER(rh);
2899 srcoffset = decode_rm01_address(rl);
2900 srcval = fetch_data_long(srcoffset);
2901 DECODE_PRINTF("\n");
2903 *destreg = xor_long(*destreg, srcval);
2908 destreg = DECODE_RM_WORD_REGISTER(rh);
2910 srcoffset = decode_rm01_address(rl);
2911 srcval = fetch_data_word(srcoffset);
2912 DECODE_PRINTF("\n");
2914 *destreg = xor_word(*destreg, srcval);
2918 if (M.x86.mode & SYSMODE_PREFIX_DATA) {
2922 destreg = DECODE_RM_LONG_REGISTER(rh);
2924 srcoffset = decode_rm10_address(rl);
2925 srcval = fetch_data_long(srcoffset);
2926 DECODE_PRINTF("\n");
2928 *destreg = xor_long(*destreg, srcval);
2933 destreg = DECODE_RM_WORD_REGISTER(rh);
2935 srcoffset = decode_rm10_address(rl);
2936 srcval = fetch_data_word(srcoffset);
2937 DECODE_PRINTF("\n");
2939 *destreg = xor_word(*destreg, srcval);
2942 case 3: /* register to register */
2943 if (M.x86.mode & SYSMODE_PREFIX_DATA) {
2944 u32 *destreg,*srcreg;
2946 destreg = DECODE_RM_LONG_REGISTER(rh);
2948 srcreg = DECODE_RM_LONG_REGISTER(rl);
2949 DECODE_PRINTF("\n");
2951 *destreg = xor_long(*destreg, *srcreg);
2953 u16 *destreg,*srcreg;
2955 destreg = DECODE_RM_WORD_REGISTER(rh);
2957 srcreg = DECODE_RM_WORD_REGISTER(rl);
2958 DECODE_PRINTF("\n");
2960 *destreg = xor_word(*destreg, *srcreg);
2964 DECODE_CLEAR_SEGOVR();
2968 /****************************************************************************
2971 ****************************************************************************/
2972 void x86emuOp_xor_byte_AL_IMM(u8 X86EMU_UNUSED(op1))
2977 DECODE_PRINTF("XOR\tAL,");
2978 srcval = fetch_byte_imm();
2979 DECODE_PRINTF2("%x\n", srcval);
2981 M.x86.R_AL = xor_byte(M.x86.R_AL, srcval);
2982 DECODE_CLEAR_SEGOVR();
2986 /****************************************************************************
2989 ****************************************************************************/
2990 void x86emuOp_xor_word_AX_IMM(u8 X86EMU_UNUSED(op1))
2995 if (M.x86.mode & SYSMODE_PREFIX_DATA) {
2996 DECODE_PRINTF("XOR\tEAX,");
2997 srcval = fetch_long_imm();
2999 DECODE_PRINTF("XOR\tAX,");
3000 srcval = fetch_word_imm();
3002 DECODE_PRINTF2("%x\n", srcval);
3004 if (M.x86.mode & SYSMODE_PREFIX_DATA) {
3005 M.x86.R_EAX = xor_long(M.x86.R_EAX, srcval);
3007 M.x86.R_AX = xor_word(M.x86.R_AX, (u16)srcval);
3009 DECODE_CLEAR_SEGOVR();
3013 /****************************************************************************
3016 ****************************************************************************/
3017 void x86emuOp_segovr_SS(u8 X86EMU_UNUSED(op1))
3020 DECODE_PRINTF("SS:\n");
3022 M.x86.mode |= SYSMODE_SEGOVR_SS;
3023 /* no DECODE_CLEAR_SEGOVR ! */
3027 /****************************************************************************
3030 ****************************************************************************/
3031 void x86emuOp_aaa(u8 X86EMU_UNUSED(op1))
3034 DECODE_PRINTF("AAA\n");
3036 M.x86.R_AX = aaa_word(M.x86.R_AX);
3037 DECODE_CLEAR_SEGOVR();
3041 /****************************************************************************
3044 ****************************************************************************/
3045 void x86emuOp_cmp_byte_RM_R(u8 X86EMU_UNUSED(op1))
3049 u8 *destreg, *srcreg;
3053 DECODE_PRINTF("CMP\t");
3054 FETCH_DECODE_MODRM(mod, rh, rl);
3057 destoffset = decode_rm00_address(rl);
3059 destval = fetch_data_byte(destoffset);
3060 srcreg = DECODE_RM_BYTE_REGISTER(rh);
3061 DECODE_PRINTF("\n");
3063 cmp_byte(destval, *srcreg);
3066 destoffset = decode_rm01_address(rl);
3068 destval = fetch_data_byte(destoffset);
3069 srcreg = DECODE_RM_BYTE_REGISTER(rh);
3070 DECODE_PRINTF("\n");
3072 cmp_byte(destval, *srcreg);
3075 destoffset = decode_rm10_address(rl);
3077 destval = fetch_data_byte(destoffset);
3078 srcreg = DECODE_RM_BYTE_REGISTER(rh);
3079 DECODE_PRINTF("\n");
3081 cmp_byte(destval, *srcreg);
3083 case 3: /* register to register */
3084 destreg = DECODE_RM_BYTE_REGISTER(rl);
3086 srcreg = DECODE_RM_BYTE_REGISTER(rh);
3087 DECODE_PRINTF("\n");
3089 cmp_byte(*destreg, *srcreg);
3092 DECODE_CLEAR_SEGOVR();
3096 /****************************************************************************
3099 ****************************************************************************/
3100 void x86emuOp_cmp_word_RM_R(u8 X86EMU_UNUSED(op1))
3106 DECODE_PRINTF("CMP\t");
3107 FETCH_DECODE_MODRM(mod, rh, rl);
3110 if (M.x86.mode & SYSMODE_PREFIX_DATA) {
3114 destoffset = decode_rm00_address(rl);
3116 destval = fetch_data_long(destoffset);
3117 srcreg = DECODE_RM_LONG_REGISTER(rh);
3118 DECODE_PRINTF("\n");
3120 cmp_long(destval, *srcreg);
3125 destoffset = decode_rm00_address(rl);
3127 destval = fetch_data_word(destoffset);
3128 srcreg = DECODE_RM_WORD_REGISTER(rh);
3129 DECODE_PRINTF("\n");
3131 cmp_word(destval, *srcreg);
3135 if (M.x86.mode & SYSMODE_PREFIX_DATA) {
3139 destoffset = decode_rm01_address(rl);
3141 destval = fetch_data_long(destoffset);
3142 srcreg = DECODE_RM_LONG_REGISTER(rh);
3143 DECODE_PRINTF("\n");
3145 cmp_long(destval, *srcreg);
3150 destoffset = decode_rm01_address(rl);
3152 destval = fetch_data_word(destoffset);
3153 srcreg = DECODE_RM_WORD_REGISTER(rh);
3154 DECODE_PRINTF("\n");
3156 cmp_word(destval, *srcreg);
3160 if (M.x86.mode & SYSMODE_PREFIX_DATA) {
3164 destoffset = decode_rm10_address(rl);
3166 destval = fetch_data_long(destoffset);
3167 srcreg = DECODE_RM_LONG_REGISTER(rh);
3168 DECODE_PRINTF("\n");
3170 cmp_long(destval, *srcreg);
3175 destoffset = decode_rm10_address(rl);
3177 destval = fetch_data_word(destoffset);
3178 srcreg = DECODE_RM_WORD_REGISTER(rh);
3179 DECODE_PRINTF("\n");
3181 cmp_word(destval, *srcreg);
3184 case 3: /* register to register */
3185 if (M.x86.mode & SYSMODE_PREFIX_DATA) {
3186 u32 *destreg,*srcreg;
3188 destreg = DECODE_RM_LONG_REGISTER(rl);
3190 srcreg = DECODE_RM_LONG_REGISTER(rh);
3191 DECODE_PRINTF("\n");
3193 cmp_long(*destreg, *srcreg);
3195 u16 *destreg,*srcreg;
3197 destreg = DECODE_RM_WORD_REGISTER(rl);
3199 srcreg = DECODE_RM_WORD_REGISTER(rh);
3200 DECODE_PRINTF("\n");
3202 cmp_word(*destreg, *srcreg);
3206 DECODE_CLEAR_SEGOVR();
3210 /****************************************************************************
3213 ****************************************************************************/
3214 void x86emuOp_cmp_byte_R_RM(u8 X86EMU_UNUSED(op1))
3217 u8 *destreg, *srcreg;
3222 DECODE_PRINTF("CMP\t");
3223 FETCH_DECODE_MODRM(mod, rh, rl);
3226 destreg = DECODE_RM_BYTE_REGISTER(rh);
3228 srcoffset = decode_rm00_address(rl);
3229 srcval = fetch_data_byte(srcoffset);
3230 DECODE_PRINTF("\n");
3232 cmp_byte(*destreg, srcval);
3235 destreg = DECODE_RM_BYTE_REGISTER(rh);
3237 srcoffset = decode_rm01_address(rl);
3238 srcval = fetch_data_byte(srcoffset);
3239 DECODE_PRINTF("\n");
3241 cmp_byte(*destreg, srcval);
3244 destreg = DECODE_RM_BYTE_REGISTER(rh);
3246 srcoffset = decode_rm10_address(rl);
3247 srcval = fetch_data_byte(srcoffset);
3248 DECODE_PRINTF("\n");
3250 cmp_byte(*destreg, srcval);
3252 case 3: /* register to register */
3253 destreg = DECODE_RM_BYTE_REGISTER(rh);
3255 srcreg = DECODE_RM_BYTE_REGISTER(rl);
3256 DECODE_PRINTF("\n");
3258 cmp_byte(*destreg, *srcreg);
3261 DECODE_CLEAR_SEGOVR();
3265 /****************************************************************************
3268 ****************************************************************************/
3269 void x86emuOp_cmp_word_R_RM(u8 X86EMU_UNUSED(op1))
3275 DECODE_PRINTF("CMP\t");
3276 FETCH_DECODE_MODRM(mod, rh, rl);
3279 if (M.x86.mode & SYSMODE_PREFIX_DATA) {
3283 destreg = DECODE_RM_LONG_REGISTER(rh);
3285 srcoffset = decode_rm00_address(rl);
3286 srcval = fetch_data_long(srcoffset);
3287 DECODE_PRINTF("\n");
3289 cmp_long(*destreg, srcval);
3294 destreg = DECODE_RM_WORD_REGISTER(rh);
3296 srcoffset = decode_rm00_address(rl);
3297 srcval = fetch_data_word(srcoffset);
3298 DECODE_PRINTF("\n");
3300 cmp_word(*destreg, srcval);
3304 if (M.x86.mode & SYSMODE_PREFIX_DATA) {
3308 destreg = DECODE_RM_LONG_REGISTER(rh);
3310 srcoffset = decode_rm01_address(rl);
3311 srcval = fetch_data_long(srcoffset);
3312 DECODE_PRINTF("\n");
3314 cmp_long(*destreg, srcval);
3319 destreg = DECODE_RM_WORD_REGISTER(rh);
3321 srcoffset = decode_rm01_address(rl);
3322 srcval = fetch_data_word(srcoffset);
3323 DECODE_PRINTF("\n");
3325 cmp_word(*destreg, srcval);
3329 if (M.x86.mode & SYSMODE_PREFIX_DATA) {
3333 destreg = DECODE_RM_LONG_REGISTER(rh);
3335 srcoffset = decode_rm10_address(rl);
3336 srcval = fetch_data_long(srcoffset);
3337 DECODE_PRINTF("\n");
3339 cmp_long(*destreg, srcval);
3344 destreg = DECODE_RM_WORD_REGISTER(rh);
3346 srcoffset = decode_rm10_address(rl);
3347 srcval = fetch_data_word(srcoffset);
3348 DECODE_PRINTF("\n");
3350 cmp_word(*destreg, srcval);
3353 case 3: /* register to register */
3354 if (M.x86.mode & SYSMODE_PREFIX_DATA) {
3355 u32 *destreg,*srcreg;
3357 destreg = DECODE_RM_LONG_REGISTER(rh);
3359 srcreg = DECODE_RM_LONG_REGISTER(rl);
3360 DECODE_PRINTF("\n");
3362 cmp_long(*destreg, *srcreg);
3364 u16 *destreg,*srcreg;
3366 destreg = DECODE_RM_WORD_REGISTER(rh);
3368 srcreg = DECODE_RM_WORD_REGISTER(rl);
3369 DECODE_PRINTF("\n");
3371 cmp_word(*destreg, *srcreg);
3375 DECODE_CLEAR_SEGOVR();
3379 /****************************************************************************
3382 ****************************************************************************/
3383 void x86emuOp_cmp_byte_AL_IMM(u8 X86EMU_UNUSED(op1))
3388 DECODE_PRINTF("CMP\tAL,");
3389 srcval = fetch_byte_imm();
3390 DECODE_PRINTF2("%x\n", srcval);
3392 cmp_byte(M.x86.R_AL, srcval);
3393 DECODE_CLEAR_SEGOVR();
3397 /****************************************************************************
3400 ****************************************************************************/
3401 void x86emuOp_cmp_word_AX_IMM(u8 X86EMU_UNUSED(op1))
3406 if (M.x86.mode & SYSMODE_PREFIX_DATA) {
3407 DECODE_PRINTF("CMP\tEAX,");
3408 srcval = fetch_long_imm();
3410 DECODE_PRINTF("CMP\tAX,");
3411 srcval = fetch_word_imm();
3413 DECODE_PRINTF2("%x\n", srcval);
3415 if (M.x86.mode & SYSMODE_PREFIX_DATA) {
3416 cmp_long(M.x86.R_EAX, srcval);
3418 cmp_word(M.x86.R_AX, (u16)srcval);
3420 DECODE_CLEAR_SEGOVR();
3424 /****************************************************************************
3427 ****************************************************************************/
3428 void x86emuOp_segovr_DS(u8 X86EMU_UNUSED(op1))
3431 DECODE_PRINTF("DS:\n");
3433 M.x86.mode |= SYSMODE_SEGOVR_DS;
3434 /* NO DECODE_CLEAR_SEGOVR! */
3438 /****************************************************************************
3441 ****************************************************************************/
3442 void x86emuOp_aas(u8 X86EMU_UNUSED(op1))
3445 DECODE_PRINTF("AAS\n");
3447 M.x86.R_AX = aas_word(M.x86.R_AX);
3448 DECODE_CLEAR_SEGOVR();
3452 /****************************************************************************
3455 ****************************************************************************/
3456 void x86emuOp_inc_AX(u8 X86EMU_UNUSED(op1))
3459 if (M.x86.mode & SYSMODE_PREFIX_DATA) {
3460 DECODE_PRINTF("INC\tEAX\n");
3462 DECODE_PRINTF("INC\tAX\n");
3465 if (M.x86.mode & SYSMODE_PREFIX_DATA) {
3466 M.x86.R_EAX = inc_long(M.x86.R_EAX);
3468 M.x86.R_AX = inc_word(M.x86.R_AX);
3470 DECODE_CLEAR_SEGOVR();
3474 /****************************************************************************
3477 ****************************************************************************/
3478 void x86emuOp_inc_CX(u8 X86EMU_UNUSED(op1))
3481 if (M.x86.mode & SYSMODE_PREFIX_DATA) {
3482 DECODE_PRINTF("INC\tECX\n");
3484 DECODE_PRINTF("INC\tCX\n");
3487 if (M.x86.mode & SYSMODE_PREFIX_DATA) {
3488 M.x86.R_ECX = inc_long(M.x86.R_ECX);
3490 M.x86.R_CX = inc_word(M.x86.R_CX);
3492 DECODE_CLEAR_SEGOVR();
3496 /****************************************************************************
3499 ****************************************************************************/
3500 void x86emuOp_inc_DX(u8 X86EMU_UNUSED(op1))
3503 if (M.x86.mode & SYSMODE_PREFIX_DATA) {
3504 DECODE_PRINTF("INC\tEDX\n");
3506 DECODE_PRINTF("INC\tDX\n");
3509 if (M.x86.mode & SYSMODE_PREFIX_DATA) {
3510 M.x86.R_EDX = inc_long(M.x86.R_EDX);
3512 M.x86.R_DX = inc_word(M.x86.R_DX);
3514 DECODE_CLEAR_SEGOVR();
3518 /****************************************************************************
3521 ****************************************************************************/
3522 void x86emuOp_inc_BX(u8 X86EMU_UNUSED(op1))
3525 if (M.x86.mode & SYSMODE_PREFIX_DATA) {
3526 DECODE_PRINTF("INC\tEBX\n");
3528 DECODE_PRINTF("INC\tBX\n");
3531 if (M.x86.mode & SYSMODE_PREFIX_DATA) {
3532 M.x86.R_EBX = inc_long(M.x86.R_EBX);
3534 M.x86.R_BX = inc_word(M.x86.R_BX);
3536 DECODE_CLEAR_SEGOVR();
3540 /****************************************************************************
3543 ****************************************************************************/
3544 void x86emuOp_inc_SP(u8 X86EMU_UNUSED(op1))
3547 if (M.x86.mode & SYSMODE_PREFIX_DATA) {
3548 DECODE_PRINTF("INC\tESP\n");
3550 DECODE_PRINTF("INC\tSP\n");
3553 if (M.x86.mode & SYSMODE_PREFIX_DATA) {
3554 M.x86.R_ESP = inc_long(M.x86.R_ESP);
3556 M.x86.R_SP = inc_word(M.x86.R_SP);
3558 DECODE_CLEAR_SEGOVR();
3562 /****************************************************************************
3565 ****************************************************************************/
3566 void x86emuOp_inc_BP(u8 X86EMU_UNUSED(op1))
3569 if (M.x86.mode & SYSMODE_PREFIX_DATA) {
3570 DECODE_PRINTF("INC\tEBP\n");
3572 DECODE_PRINTF("INC\tBP\n");
3575 if (M.x86.mode & SYSMODE_PREFIX_DATA) {
3576 M.x86.R_EBP = inc_long(M.x86.R_EBP);
3578 M.x86.R_BP = inc_word(M.x86.R_BP);
3580 DECODE_CLEAR_SEGOVR();
3584 /****************************************************************************
3587 ****************************************************************************/
3588 void x86emuOp_inc_SI(u8 X86EMU_UNUSED(op1))
3591 if (M.x86.mode & SYSMODE_PREFIX_DATA) {
3592 DECODE_PRINTF("INC\tESI\n");
3594 DECODE_PRINTF("INC\tSI\n");
3597 if (M.x86.mode & SYSMODE_PREFIX_DATA) {
3598 M.x86.R_ESI = inc_long(M.x86.R_ESI);
3600 M.x86.R_SI = inc_word(M.x86.R_SI);
3602 DECODE_CLEAR_SEGOVR();
3606 /****************************************************************************
3609 ****************************************************************************/
3610 void x86emuOp_inc_DI(u8 X86EMU_UNUSED(op1))
3613 if (M.x86.mode & SYSMODE_PREFIX_DATA) {
3614 DECODE_PRINTF("INC\tEDI\n");
3616 DECODE_PRINTF("INC\tDI\n");
3619 if (M.x86.mode & SYSMODE_PREFIX_DATA) {
3620 M.x86.R_EDI = inc_long(M.x86.R_EDI);
3622 M.x86.R_DI = inc_word(M.x86.R_DI);
3624 DECODE_CLEAR_SEGOVR();
3628 /****************************************************************************
3631 ****************************************************************************/
3632 void x86emuOp_dec_AX(u8 X86EMU_UNUSED(op1))
3635 if (M.x86.mode & SYSMODE_PREFIX_DATA) {
3636 DECODE_PRINTF("DEC\tEAX\n");
3638 DECODE_PRINTF("DEC\tAX\n");
3641 if (M.x86.mode & SYSMODE_PREFIX_DATA) {
3642 M.x86.R_EAX = dec_long(M.x86.R_EAX);
3644 M.x86.R_AX = dec_word(M.x86.R_AX);
3646 DECODE_CLEAR_SEGOVR();
3650 /****************************************************************************
3653 ****************************************************************************/
3654 void x86emuOp_dec_CX(u8 X86EMU_UNUSED(op1))
3657 if (M.x86.mode & SYSMODE_PREFIX_DATA) {
3658 DECODE_PRINTF("DEC\tECX\n");
3660 DECODE_PRINTF("DEC\tCX\n");
3663 if (M.x86.mode & SYSMODE_PREFIX_DATA) {
3664 M.x86.R_ECX = dec_long(M.x86.R_ECX);
3666 M.x86.R_CX = dec_word(M.x86.R_CX);
3668 DECODE_CLEAR_SEGOVR();
3672 /****************************************************************************
3675 ****************************************************************************/
3676 void x86emuOp_dec_DX(u8 X86EMU_UNUSED(op1))
3679 if (M.x86.mode & SYSMODE_PREFIX_DATA) {
3680 DECODE_PRINTF("DEC\tEDX\n");
3682 DECODE_PRINTF("DEC\tDX\n");
3685 if (M.x86.mode & SYSMODE_PREFIX_DATA) {
3686 M.x86.R_EDX = dec_long(M.x86.R_EDX);
3688 M.x86.R_DX = dec_word(M.x86.R_DX);
3690 DECODE_CLEAR_SEGOVR();
3694 /****************************************************************************
3697 ****************************************************************************/
3698 void x86emuOp_dec_BX(u8 X86EMU_UNUSED(op1))
3701 if (M.x86.mode & SYSMODE_PREFIX_DATA) {
3702 DECODE_PRINTF("DEC\tEBX\n");
3704 DECODE_PRINTF("DEC\tBX\n");
3707 if (M.x86.mode & SYSMODE_PREFIX_DATA) {
3708 M.x86.R_EBX = dec_long(M.x86.R_EBX);
3710 M.x86.R_BX = dec_word(M.x86.R_BX);
3712 DECODE_CLEAR_SEGOVR();
3716 /****************************************************************************
3719 ****************************************************************************/
3720 void x86emuOp_dec_SP(u8 X86EMU_UNUSED(op1))
3723 if (M.x86.mode & SYSMODE_PREFIX_DATA) {
3724 DECODE_PRINTF("DEC\tESP\n");
3726 DECODE_PRINTF("DEC\tSP\n");
3729 if (M.x86.mode & SYSMODE_PREFIX_DATA) {
3730 M.x86.R_ESP = dec_long(M.x86.R_ESP);
3732 M.x86.R_SP = dec_word(M.x86.R_SP);
3734 DECODE_CLEAR_SEGOVR();
3738 /****************************************************************************
3741 ****************************************************************************/
3742 void x86emuOp_dec_BP(u8 X86EMU_UNUSED(op1))
3745 if (M.x86.mode & SYSMODE_PREFIX_DATA) {
3746 DECODE_PRINTF("DEC\tEBP\n");
3748 DECODE_PRINTF("DEC\tBP\n");
3751 if (M.x86.mode & SYSMODE_PREFIX_DATA) {
3752 M.x86.R_EBP = dec_long(M.x86.R_EBP);
3754 M.x86.R_BP = dec_word(M.x86.R_BP);
3756 DECODE_CLEAR_SEGOVR();
3760 /****************************************************************************
3763 ****************************************************************************/
3764 void x86emuOp_dec_SI(u8 X86EMU_UNUSED(op1))
3767 if (M.x86.mode & SYSMODE_PREFIX_DATA) {
3768 DECODE_PRINTF("DEC\tESI\n");
3770 DECODE_PRINTF("DEC\tSI\n");
3773 if (M.x86.mode & SYSMODE_PREFIX_DATA) {
3774 M.x86.R_ESI = dec_long(M.x86.R_ESI);
3776 M.x86.R_SI = dec_word(M.x86.R_SI);
3778 DECODE_CLEAR_SEGOVR();
3782 /****************************************************************************
3785 ****************************************************************************/
3786 void x86emuOp_dec_DI(u8 X86EMU_UNUSED(op1))
3789 if (M.x86.mode & SYSMODE_PREFIX_DATA) {
3790 DECODE_PRINTF("DEC\tEDI\n");
3792 DECODE_PRINTF("DEC\tDI\n");
3795 if (M.x86.mode & SYSMODE_PREFIX_DATA) {
3796 M.x86.R_EDI = dec_long(M.x86.R_EDI);
3798 M.x86.R_DI = dec_word(M.x86.R_DI);
3800 DECODE_CLEAR_SEGOVR();
3804 /****************************************************************************
3807 ****************************************************************************/
3808 void x86emuOp_push_AX(u8 X86EMU_UNUSED(op1))
3811 if (M.x86.mode & SYSMODE_PREFIX_DATA) {
3812 DECODE_PRINTF("PUSH\tEAX\n");
3814 DECODE_PRINTF("PUSH\tAX\n");
3817 if (M.x86.mode & SYSMODE_PREFIX_DATA) {
3818 push_long(M.x86.R_EAX);
3820 push_word(M.x86.R_AX);
3822 DECODE_CLEAR_SEGOVR();
3826 /****************************************************************************
3829 ****************************************************************************/
3830 void x86emuOp_push_CX(u8 X86EMU_UNUSED(op1))
3833 if (M.x86.mode & SYSMODE_PREFIX_DATA) {
3834 DECODE_PRINTF("PUSH\tECX\n");
3836 DECODE_PRINTF("PUSH\tCX\n");
3839 if (M.x86.mode & SYSMODE_PREFIX_DATA) {
3840 push_long(M.x86.R_ECX);
3842 push_word(M.x86.R_CX);
3844 DECODE_CLEAR_SEGOVR();
3848 /****************************************************************************
3851 ****************************************************************************/
3852 void x86emuOp_push_DX(u8 X86EMU_UNUSED(op1))
3855 if (M.x86.mode & SYSMODE_PREFIX_DATA) {
3856 DECODE_PRINTF("PUSH\tEDX\n");
3858 DECODE_PRINTF("PUSH\tDX\n");
3861 if (M.x86.mode & SYSMODE_PREFIX_DATA) {
3862 push_long(M.x86.R_EDX);
3864 push_word(M.x86.R_DX);
3866 DECODE_CLEAR_SEGOVR();
3870 /****************************************************************************
3873 ****************************************************************************/
3874 void x86emuOp_push_BX(u8 X86EMU_UNUSED(op1))
3877 if (M.x86.mode & SYSMODE_PREFIX_DATA) {
3878 DECODE_PRINTF("PUSH\tEBX\n");
3880 DECODE_PRINTF("PUSH\tBX\n");
3883 if (M.x86.mode & SYSMODE_PREFIX_DATA) {
3884 push_long(M.x86.R_EBX);
3886 push_word(M.x86.R_BX);
3888 DECODE_CLEAR_SEGOVR();
3892 /****************************************************************************
3895 ****************************************************************************/
3896 void x86emuOp_push_SP(u8 X86EMU_UNUSED(op1))
3899 if (M.x86.mode & SYSMODE_PREFIX_DATA) {
3900 DECODE_PRINTF("PUSH\tESP\n");
3902 DECODE_PRINTF("PUSH\tSP\n");
3905 /* Always push (E)SP, since we are emulating an i386 and above
3906 * processor. This is necessary as some BIOS'es use this to check
3907 * what type of processor is in the system.
3909 if (M.x86.mode & SYSMODE_PREFIX_DATA) {
3910 push_long(M.x86.R_ESP);
3912 push_word((u16)(M.x86.R_SP));
3914 DECODE_CLEAR_SEGOVR();
3918 /****************************************************************************
3921 ****************************************************************************/
3922 void x86emuOp_push_BP(u8 X86EMU_UNUSED(op1))
3925 if (M.x86.mode & SYSMODE_PREFIX_DATA) {
3926 DECODE_PRINTF("PUSH\tEBP\n");
3928 DECODE_PRINTF("PUSH\tBP\n");
3931 if (M.x86.mode & SYSMODE_PREFIX_DATA) {
3932 push_long(M.x86.R_EBP);
3934 push_word(M.x86.R_BP);
3936 DECODE_CLEAR_SEGOVR();
3940 /****************************************************************************
3943 ****************************************************************************/
3944 void x86emuOp_push_SI(u8 X86EMU_UNUSED(op1))
3947 if (M.x86.mode & SYSMODE_PREFIX_DATA) {
3948 DECODE_PRINTF("PUSH\tESI\n");
3950 DECODE_PRINTF("PUSH\tSI\n");
3953 if (M.x86.mode & SYSMODE_PREFIX_DATA) {
3954 push_long(M.x86.R_ESI);
3956 push_word(M.x86.R_SI);
3958 DECODE_CLEAR_SEGOVR();
3962 /****************************************************************************
3965 ****************************************************************************/
3966 void x86emuOp_push_DI(u8 X86EMU_UNUSED(op1))
3969 if (M.x86.mode & SYSMODE_PREFIX_DATA) {
3970 DECODE_PRINTF("PUSH\tEDI\n");
3972 DECODE_PRINTF("PUSH\tDI\n");
3975 if (M.x86.mode & SYSMODE_PREFIX_DATA) {
3976 push_long(M.x86.R_EDI);
3978 push_word(M.x86.R_DI);
3980 DECODE_CLEAR_SEGOVR();
3984 /****************************************************************************
3987 ****************************************************************************/
3988 void x86emuOp_pop_AX(u8 X86EMU_UNUSED(op1))
3991 if (M.x86.mode & SYSMODE_PREFIX_DATA) {
3992 DECODE_PRINTF("POP\tEAX\n");
3994 DECODE_PRINTF("POP\tAX\n");
3997 if (M.x86.mode & SYSMODE_PREFIX_DATA) {
3998 M.x86.R_EAX = pop_long();
4000 M.x86.R_AX = pop_word();
4002 DECODE_CLEAR_SEGOVR();
4006 /****************************************************************************
4009 ****************************************************************************/
4010 void x86emuOp_pop_CX(u8 X86EMU_UNUSED(op1))
4013 if (M.x86.mode & SYSMODE_PREFIX_DATA) {
4014 DECODE_PRINTF("POP\tECX\n");
4016 DECODE_PRINTF("POP\tCX\n");
4019 if (M.x86.mode & SYSMODE_PREFIX_DATA) {
4020 M.x86.R_ECX = pop_long();
4022 M.x86.R_CX = pop_word();
4024 DECODE_CLEAR_SEGOVR();
4028 /****************************************************************************
4031 ****************************************************************************/
4032 void x86emuOp_pop_DX(u8 X86EMU_UNUSED(op1))
4035 if (M.x86.mode & SYSMODE_PREFIX_DATA) {
4036 DECODE_PRINTF("POP\tEDX\n");
4038 DECODE_PRINTF("POP\tDX\n");
4041 if (M.x86.mode & SYSMODE_PREFIX_DATA) {
4042 M.x86.R_EDX = pop_long();
4044 M.x86.R_DX = pop_word();
4046 DECODE_CLEAR_SEGOVR();
4050 /****************************************************************************
4053 ****************************************************************************/
4054 void x86emuOp_pop_BX(u8 X86EMU_UNUSED(op1))
4057 if (M.x86.mode & SYSMODE_PREFIX_DATA) {
4058 DECODE_PRINTF("POP\tEBX\n");
4060 DECODE_PRINTF("POP\tBX\n");
4063 if (M.x86.mode & SYSMODE_PREFIX_DATA) {
4064 M.x86.R_EBX = pop_long();
4066 M.x86.R_BX = pop_word();
4068 DECODE_CLEAR_SEGOVR();
4072 /****************************************************************************
4075 ****************************************************************************/
4076 void x86emuOp_pop_SP(u8 X86EMU_UNUSED(op1))
4079 if (M.x86.mode & SYSMODE_PREFIX_DATA) {
4080 DECODE_PRINTF("POP\tESP\n");
4082 DECODE_PRINTF("POP\tSP\n");
4085 if (M.x86.mode & SYSMODE_PREFIX_DATA) {
4086 M.x86.R_ESP = pop_long();
4088 M.x86.R_SP = pop_word();
4090 DECODE_CLEAR_SEGOVR();
4094 /****************************************************************************
4097 ****************************************************************************/
4098 void x86emuOp_pop_BP(u8 X86EMU_UNUSED(op1))
4101 if (M.x86.mode & SYSMODE_PREFIX_DATA) {
4102 DECODE_PRINTF("POP\tEBP\n");
4104 DECODE_PRINTF("POP\tBP\n");
4107 if (M.x86.mode & SYSMODE_PREFIX_DATA) {
4108 M.x86.R_EBP = pop_long();
4110 M.x86.R_BP = pop_word();
4112 DECODE_CLEAR_SEGOVR();
4116 /****************************************************************************
4119 ****************************************************************************/
4120 void x86emuOp_pop_SI(u8 X86EMU_UNUSED(op1))
4123 if (M.x86.mode & SYSMODE_PREFIX_DATA) {
4124 DECODE_PRINTF("POP\tESI\n");
4126 DECODE_PRINTF("POP\tSI\n");
4129 if (M.x86.mode & SYSMODE_PREFIX_DATA) {
4130 M.x86.R_ESI = pop_long();
4132 M.x86.R_SI = pop_word();
4134 DECODE_CLEAR_SEGOVR();
4138 /****************************************************************************
4141 ****************************************************************************/
4142 void x86emuOp_pop_DI(u8 X86EMU_UNUSED(op1))
4145 if (M.x86.mode & SYSMODE_PREFIX_DATA) {
4146 DECODE_PRINTF("POP\tEDI\n");
4148 DECODE_PRINTF("POP\tDI\n");
4151 if (M.x86.mode & SYSMODE_PREFIX_DATA) {
4152 M.x86.R_EDI = pop_long();
4154 M.x86.R_DI = pop_word();
4156 DECODE_CLEAR_SEGOVR();
4160 /****************************************************************************
4163 ****************************************************************************/
4164 void x86emuOp_push_all(u8 X86EMU_UNUSED(op1))
4167 if (M.x86.mode & SYSMODE_PREFIX_DATA) {
4168 DECODE_PRINTF("PUSHAD\n");
4170 DECODE_PRINTF("PUSHA\n");
4173 if (M.x86.mode & SYSMODE_PREFIX_DATA) {
4174 u32 old_sp = M.x86.R_ESP;
4176 push_long(M.x86.R_EAX);
4177 push_long(M.x86.R_ECX);
4178 push_long(M.x86.R_EDX);
4179 push_long(M.x86.R_EBX);
4181 push_long(M.x86.R_EBP);
4182 push_long(M.x86.R_ESI);
4183 push_long(M.x86.R_EDI);
4185 u16 old_sp = M.x86.R_SP;
4187 push_word(M.x86.R_AX);
4188 push_word(M.x86.R_CX);
4189 push_word(M.x86.R_DX);
4190 push_word(M.x86.R_BX);
4192 push_word(M.x86.R_BP);
4193 push_word(M.x86.R_SI);
4194 push_word(M.x86.R_DI);
4196 DECODE_CLEAR_SEGOVR();
4200 /****************************************************************************
4203 ****************************************************************************/
4204 void x86emuOp_pop_all(u8 X86EMU_UNUSED(op1))
4207 if (M.x86.mode & SYSMODE_PREFIX_DATA) {
4208 DECODE_PRINTF("POPAD\n");
4210 DECODE_PRINTF("POPA\n");
4213 if (M.x86.mode & SYSMODE_PREFIX_DATA) {
4214 M.x86.R_EDI = pop_long();
4215 M.x86.R_ESI = pop_long();
4216 M.x86.R_EBP = pop_long();
4217 M.x86.R_ESP += 4; /* skip ESP */
4218 M.x86.R_EBX = pop_long();
4219 M.x86.R_EDX = pop_long();
4220 M.x86.R_ECX = pop_long();
4221 M.x86.R_EAX = pop_long();
4223 M.x86.R_DI = pop_word();
4224 M.x86.R_SI = pop_word();
4225 M.x86.R_BP = pop_word();
4226 M.x86.R_SP += 2; /* skip SP */
4227 M.x86.R_BX = pop_word();
4228 M.x86.R_DX = pop_word();
4229 M.x86.R_CX = pop_word();
4230 M.x86.R_AX = pop_word();
4232 DECODE_CLEAR_SEGOVR();
4236 /*opcode 0x62 ILLEGAL OP, calls x86emuOp_illegal_op() */
4237 /*opcode 0x63 ILLEGAL OP, calls x86emuOp_illegal_op() */
4239 /****************************************************************************
4242 ****************************************************************************/
4243 void x86emuOp_segovr_FS(u8 X86EMU_UNUSED(op1))
4246 DECODE_PRINTF("FS:\n");
4248 M.x86.mode |= SYSMODE_SEGOVR_FS;
4250 * note the lack of DECODE_CLEAR_SEGOVR(r) since, here is one of 4
4251 * opcode subroutines we do not want to do this.
4256 /****************************************************************************
4259 ****************************************************************************/
4260 void x86emuOp_segovr_GS(u8 X86EMU_UNUSED(op1))
4263 DECODE_PRINTF("GS:\n");
4265 M.x86.mode |= SYSMODE_SEGOVR_GS;
4267 * note the lack of DECODE_CLEAR_SEGOVR(r) since, here is one of 4
4268 * opcode subroutines we do not want to do this.
4273 /****************************************************************************
4275 Handles opcode 0x66 - prefix for 32-bit register
4276 ****************************************************************************/
4277 void x86emuOp_prefix_data(u8 X86EMU_UNUSED(op1))
4280 DECODE_PRINTF("DATA:\n");
4282 M.x86.mode |= SYSMODE_PREFIX_DATA;
4283 /* note no DECODE_CLEAR_SEGOVR here. */
4287 /****************************************************************************
4289 Handles opcode 0x67 - prefix for 32-bit address
4290 ****************************************************************************/
4291 void x86emuOp_prefix_addr(u8 X86EMU_UNUSED(op1))
4294 DECODE_PRINTF("ADDR:\n");
4296 M.x86.mode |= SYSMODE_PREFIX_ADDR;
4297 /* note no DECODE_CLEAR_SEGOVR here. */
4301 /****************************************************************************
4304 ****************************************************************************/
4305 void x86emuOp_push_word_IMM(u8 X86EMU_UNUSED(op1))
4310 if (M.x86.mode & SYSMODE_PREFIX_DATA) {
4311 imm = fetch_long_imm();
4313 imm = fetch_word_imm();
4315 DECODE_PRINTF2("PUSH\t%x\n", imm);
4317 if (M.x86.mode & SYSMODE_PREFIX_DATA) {
4320 push_word((u16)imm);
4322 DECODE_CLEAR_SEGOVR();
4326 /****************************************************************************
4329 ****************************************************************************/
4330 void x86emuOp_imul_word_IMM(u8 X86EMU_UNUSED(op1))
4336 DECODE_PRINTF("IMUL\t");
4337 FETCH_DECODE_MODRM(mod, rh, rl);
4340 if (M.x86.mode & SYSMODE_PREFIX_DATA) {
4346 destreg = DECODE_RM_LONG_REGISTER(rh);
4348 srcoffset = decode_rm00_address(rl);
4349 srcval = fetch_data_long(srcoffset);
4350 imm = fetch_long_imm();
4351 DECODE_PRINTF2(",%d\n", (s32)imm);
4353 imul_long_direct(&res_lo,&res_hi,(s32)srcval,(s32)imm);
4361 *destreg = (u32)res_lo;
4368 destreg = DECODE_RM_WORD_REGISTER(rh);
4370 srcoffset = decode_rm00_address(rl);
4371 srcval = fetch_data_word(srcoffset);
4372 imm = fetch_word_imm();
4373 DECODE_PRINTF2(",%d\n", (s32)imm);
4375 res = (s16)srcval * (s16)imm;
4383 *destreg = (u16)res;
4387 if (M.x86.mode & SYSMODE_PREFIX_DATA) {
4393 destreg = DECODE_RM_LONG_REGISTER(rh);
4395 srcoffset = decode_rm01_address(rl);
4396 srcval = fetch_data_long(srcoffset);
4397 imm = fetch_long_imm();
4398 DECODE_PRINTF2(",%d\n", (s32)imm);
4400 imul_long_direct(&res_lo,&res_hi,(s32)srcval,(s32)imm);
4408 *destreg = (u32)res_lo;
4415 destreg = DECODE_RM_WORD_REGISTER(rh);
4417 srcoffset = decode_rm01_address(rl);
4418 srcval = fetch_data_word(srcoffset);
4419 imm = fetch_word_imm();
4420 DECODE_PRINTF2(",%d\n", (s32)imm);
4422 res = (s16)srcval * (s16)imm;
4430 *destreg = (u16)res;
4434 if (M.x86.mode & SYSMODE_PREFIX_DATA) {
4440 destreg = DECODE_RM_LONG_REGISTER(rh);
4442 srcoffset = decode_rm10_address(rl);
4443 srcval = fetch_data_long(srcoffset);
4444 imm = fetch_long_imm();
4445 DECODE_PRINTF2(",%d\n", (s32)imm);
4447 imul_long_direct(&res_lo,&res_hi,(s32)srcval,(s32)imm);
4455 *destreg = (u32)res_lo;
4462 destreg = DECODE_RM_WORD_REGISTER(rh);
4464 srcoffset = decode_rm10_address(rl);
4465 srcval = fetch_data_word(srcoffset);
4466 imm = fetch_word_imm();
4467 DECODE_PRINTF2(",%d\n", (s32)imm);
4469 res = (s16)srcval * (s16)imm;
4477 *destreg = (u16)res;
4480 case 3: /* register to register */
4481 if (M.x86.mode & SYSMODE_PREFIX_DATA) {
4482 u32 *destreg,*srcreg;
4486 destreg = DECODE_RM_LONG_REGISTER(rh);
4488 srcreg = DECODE_RM_LONG_REGISTER(rl);
4489 imm = fetch_long_imm();
4490 DECODE_PRINTF2(",%d\n", (s32)imm);
4492 imul_long_direct(&res_lo,&res_hi,(s32)*srcreg,(s32)imm);
4500 *destreg = (u32)res_lo;
4502 u16 *destreg,*srcreg;
4506 destreg = DECODE_RM_WORD_REGISTER(rh);
4508 srcreg = DECODE_RM_WORD_REGISTER(rl);
4509 imm = fetch_word_imm();
4510 DECODE_PRINTF2(",%d\n", (s32)imm);
4511 res = (s16)*srcreg * (s16)imm;
4519 *destreg = (u16)res;
4523 DECODE_CLEAR_SEGOVR();
4527 /****************************************************************************
4530 ****************************************************************************/
4531 void x86emuOp_push_byte_IMM(u8 X86EMU_UNUSED(op1))
4536 imm = (s8)fetch_byte_imm();
4537 DECODE_PRINTF2("PUSH\t%d\n", imm);
4540 DECODE_CLEAR_SEGOVR();
4544 /****************************************************************************
4547 ****************************************************************************/
4548 void x86emuOp_imul_byte_IMM(u8 X86EMU_UNUSED(op1))
4555 DECODE_PRINTF("IMUL\t");
4556 FETCH_DECODE_MODRM(mod, rh, rl);
4559 if (M.x86.mode & SYSMODE_PREFIX_DATA) {
4564 destreg = DECODE_RM_LONG_REGISTER(rh);
4566 srcoffset = decode_rm00_address(rl);
4567 srcval = fetch_data_long(srcoffset);
4568 imm = fetch_byte_imm();
4569 DECODE_PRINTF2(",%d\n", (s32)imm);
4571 imul_long_direct(&res_lo,&res_hi,(s32)srcval,(s32)imm);
4579 *destreg = (u32)res_lo;
4585 destreg = DECODE_RM_WORD_REGISTER(rh);
4587 srcoffset = decode_rm00_address(rl);
4588 srcval = fetch_data_word(srcoffset);
4589 imm = fetch_byte_imm();
4590 DECODE_PRINTF2(",%d\n", (s32)imm);
4592 res = (s16)srcval * (s16)imm;
4600 *destreg = (u16)res;
4604 if (M.x86.mode & SYSMODE_PREFIX_DATA) {
4609 destreg = DECODE_RM_LONG_REGISTER(rh);
4611 srcoffset = decode_rm01_address(rl);
4612 srcval = fetch_data_long(srcoffset);
4613 imm = fetch_byte_imm();
4614 DECODE_PRINTF2(",%d\n", (s32)imm);
4616 imul_long_direct(&res_lo,&res_hi,(s32)srcval,(s32)imm);
4624 *destreg = (u32)res_lo;
4630 destreg = DECODE_RM_WORD_REGISTER(rh);
4632 srcoffset = decode_rm01_address(rl);
4633 srcval = fetch_data_word(srcoffset);
4634 imm = fetch_byte_imm();
4635 DECODE_PRINTF2(",%d\n", (s32)imm);
4637 res = (s16)srcval * (s16)imm;
4645 *destreg = (u16)res;
4649 if (M.x86.mode & SYSMODE_PREFIX_DATA) {
4654 destreg = DECODE_RM_LONG_REGISTER(rh);
4656 srcoffset = decode_rm10_address(rl);
4657 srcval = fetch_data_long(srcoffset);
4658 imm = fetch_byte_imm();
4659 DECODE_PRINTF2(",%d\n", (s32)imm);
4661 imul_long_direct(&res_lo,&res_hi,(s32)srcval,(s32)imm);
4669 *destreg = (u32)res_lo;
4675 destreg = DECODE_RM_WORD_REGISTER(rh);
4677 srcoffset = decode_rm10_address(rl);
4678 srcval = fetch_data_word(srcoffset);
4679 imm = fetch_byte_imm();
4680 DECODE_PRINTF2(",%d\n", (s32)imm);
4682 res = (s16)srcval * (s16)imm;
4690 *destreg = (u16)res;
4693 case 3: /* register to register */
4694 if (M.x86.mode & SYSMODE_PREFIX_DATA) {
4695 u32 *destreg,*srcreg;
4698 destreg = DECODE_RM_LONG_REGISTER(rh);
4700 srcreg = DECODE_RM_LONG_REGISTER(rl);
4701 imm = fetch_byte_imm();
4702 DECODE_PRINTF2(",%d\n", (s32)imm);
4704 imul_long_direct(&res_lo,&res_hi,(s32)*srcreg,(s32)imm);
4712 *destreg = (u32)res_lo;
4714 u16 *destreg,*srcreg;
4717 destreg = DECODE_RM_WORD_REGISTER(rh);
4719 srcreg = DECODE_RM_WORD_REGISTER(rl);
4720 imm = fetch_byte_imm();
4721 DECODE_PRINTF2(",%d\n", (s32)imm);
4722 res = (s16)*srcreg * (s16)imm;
4730 *destreg = (u16)res;
4734 DECODE_CLEAR_SEGOVR();
4738 /****************************************************************************
4741 ****************************************************************************/
4742 void x86emuOp_ins_byte(u8 X86EMU_UNUSED(op1))
4745 DECODE_PRINTF("INSB\n");
4748 DECODE_CLEAR_SEGOVR();
4752 /****************************************************************************
4755 ****************************************************************************/
4756 void x86emuOp_ins_word(u8 X86EMU_UNUSED(op1))
4759 if (M.x86.mode & SYSMODE_PREFIX_DATA) {
4760 DECODE_PRINTF("INSD\n");
4763 DECODE_PRINTF("INSW\n");
4767 DECODE_CLEAR_SEGOVR();
4771 /****************************************************************************
4774 ****************************************************************************/
4775 void x86emuOp_outs_byte(u8 X86EMU_UNUSED(op1))
4778 DECODE_PRINTF("OUTSB\n");
4781 DECODE_CLEAR_SEGOVR();
4785 /****************************************************************************
4788 ****************************************************************************/
4789 void x86emuOp_outs_word(u8 X86EMU_UNUSED(op1))
4792 if (M.x86.mode & SYSMODE_PREFIX_DATA) {
4793 DECODE_PRINTF("OUTSD\n");
4796 DECODE_PRINTF("OUTSW\n");
4800 DECODE_CLEAR_SEGOVR();
4804 /****************************************************************************
4807 ****************************************************************************/
4808 void x86emuOp_jump_near_O(u8 X86EMU_UNUSED(op1))
4813 /* jump to byte offset if overflow flag is set */
4815 DECODE_PRINTF("JO\t");
4816 offset = (s8)fetch_byte_imm();
4817 target = (u16)(M.x86.R_IP + (s16)offset);
4818 DECODE_PRINTF2("%x\n", target);
4820 if (ACCESS_FLAG(F_OF))
4821 M.x86.R_IP = target;
4822 DECODE_CLEAR_SEGOVR();
4826 /****************************************************************************
4829 ****************************************************************************/
4830 void x86emuOp_jump_near_NO(u8 X86EMU_UNUSED(op1))
4835 /* jump to byte offset if overflow is not set */
4837 DECODE_PRINTF("JNO\t");
4838 offset = (s8)fetch_byte_imm();
4839 target = (u16)(M.x86.R_IP + (s16)offset);
4840 DECODE_PRINTF2("%x\n", target);
4842 if (!ACCESS_FLAG(F_OF))
4843 M.x86.R_IP = target;
4844 DECODE_CLEAR_SEGOVR();
4848 /****************************************************************************
4851 ****************************************************************************/
4852 void x86emuOp_jump_near_B(u8 X86EMU_UNUSED(op1))
4857 /* jump to byte offset if carry flag is set. */
4859 DECODE_PRINTF("JB\t");
4860 offset = (s8)fetch_byte_imm();
4861 target = (u16)(M.x86.R_IP + (s16)offset);
4862 DECODE_PRINTF2("%x\n", target);
4864 if (ACCESS_FLAG(F_CF))
4865 M.x86.R_IP = target;
4866 DECODE_CLEAR_SEGOVR();
4870 /****************************************************************************
4873 ****************************************************************************/
4874 void x86emuOp_jump_near_NB(u8 X86EMU_UNUSED(op1))
4879 /* jump to byte offset if carry flag is clear. */
4881 DECODE_PRINTF("JNB\t");
4882 offset = (s8)fetch_byte_imm();
4883 target = (u16)(M.x86.R_IP + (s16)offset);
4884 DECODE_PRINTF2("%x\n", target);
4886 if (!ACCESS_FLAG(F_CF))
4887 M.x86.R_IP = target;
4888 DECODE_CLEAR_SEGOVR();
4892 /****************************************************************************
4895 ****************************************************************************/
4896 void x86emuOp_jump_near_Z(u8 X86EMU_UNUSED(op1))
4901 /* jump to byte offset if zero flag is set. */
4903 DECODE_PRINTF("JZ\t");
4904 offset = (s8)fetch_byte_imm();
4905 target = (u16)(M.x86.R_IP + (s16)offset);
4906 DECODE_PRINTF2("%x\n", target);
4908 if (ACCESS_FLAG(F_ZF))
4909 M.x86.R_IP = target;
4910 DECODE_CLEAR_SEGOVR();
4914 /****************************************************************************
4917 ****************************************************************************/
4918 void x86emuOp_jump_near_NZ(u8 X86EMU_UNUSED(op1))
4923 /* jump to byte offset if zero flag is clear. */
4925 DECODE_PRINTF("JNZ\t");
4926 offset = (s8)fetch_byte_imm();
4927 target = (u16)(M.x86.R_IP + (s16)offset);
4928 DECODE_PRINTF2("%x\n", target);
4930 if (!ACCESS_FLAG(F_ZF))
4931 M.x86.R_IP = target;
4932 DECODE_CLEAR_SEGOVR();
4936 /****************************************************************************
4939 ****************************************************************************/
4940 void x86emuOp_jump_near_BE(u8 X86EMU_UNUSED(op1))
4945 /* jump to byte offset if carry flag is set or if the zero
4948 DECODE_PRINTF("JBE\t");
4949 offset = (s8)fetch_byte_imm();
4950 target = (u16)(M.x86.R_IP + (s16)offset);
4951 DECODE_PRINTF2("%x\n", target);
4953 if (ACCESS_FLAG(F_CF) || ACCESS_FLAG(F_ZF))
4954 M.x86.R_IP = target;
4955 DECODE_CLEAR_SEGOVR();
4959 /****************************************************************************
4962 ****************************************************************************/
4963 void x86emuOp_jump_near_NBE(u8 X86EMU_UNUSED(op1))
4968 /* jump to byte offset if carry flag is clear and if the zero
4971 DECODE_PRINTF("JNBE\t");
4972 offset = (s8)fetch_byte_imm();
4973 target = (u16)(M.x86.R_IP + (s16)offset);
4974 DECODE_PRINTF2("%x\n", target);
4976 if (!(ACCESS_FLAG(F_CF) || ACCESS_FLAG(F_ZF)))
4977 M.x86.R_IP = target;
4978 DECODE_CLEAR_SEGOVR();
4982 /****************************************************************************
4985 ****************************************************************************/
4986 void x86emuOp_jump_near_S(u8 X86EMU_UNUSED(op1))
4991 /* jump to byte offset if sign flag is set */
4993 DECODE_PRINTF("JS\t");
4994 offset = (s8)fetch_byte_imm();
4995 target = (u16)(M.x86.R_IP + (s16)offset);
4996 DECODE_PRINTF2("%x\n", target);
4998 if (ACCESS_FLAG(F_SF))
4999 M.x86.R_IP = target;
5000 DECODE_CLEAR_SEGOVR();
5004 /****************************************************************************
5007 ****************************************************************************/
5008 void x86emuOp_jump_near_NS(u8 X86EMU_UNUSED(op1))
5013 /* jump to byte offset if sign flag is clear */
5015 DECODE_PRINTF("JNS\t");
5016 offset = (s8)fetch_byte_imm();
5017 target = (u16)(M.x86.R_IP + (s16)offset);
5018 DECODE_PRINTF2("%x\n", target);
5020 if (!ACCESS_FLAG(F_SF))
5021 M.x86.R_IP = target;
5022 DECODE_CLEAR_SEGOVR();
5026 /****************************************************************************
5029 ****************************************************************************/
5030 void x86emuOp_jump_near_P(u8 X86EMU_UNUSED(op1))
5035 /* jump to byte offset if parity flag is set (even parity) */
5037 DECODE_PRINTF("JP\t");
5038 offset = (s8)fetch_byte_imm();
5039 target = (u16)(M.x86.R_IP + (s16)offset);
5040 DECODE_PRINTF2("%x\n", target);
5042 if (ACCESS_FLAG(F_PF))
5043 M.x86.R_IP = target;
5044 DECODE_CLEAR_SEGOVR();
5048 /****************************************************************************
5051 ****************************************************************************/
5052 void x86emuOp_jump_near_NP(u8 X86EMU_UNUSED(op1))
5057 /* jump to byte offset if parity flag is clear (odd parity) */
5059 DECODE_PRINTF("JNP\t");
5060 offset = (s8)fetch_byte_imm();
5061 target = (u16)(M.x86.R_IP + (s16)offset);
5062 DECODE_PRINTF2("%x\n", target);
5064 if (!ACCESS_FLAG(F_PF))
5065 M.x86.R_IP = target;
5066 DECODE_CLEAR_SEGOVR();
5070 /****************************************************************************
5073 ****************************************************************************/
5074 void x86emuOp_jump_near_L(u8 X86EMU_UNUSED(op1))
5080 /* jump to byte offset if sign flag not equal to overflow flag. */
5082 DECODE_PRINTF("JL\t");
5083 offset = (s8)fetch_byte_imm();
5084 target = (u16)(M.x86.R_IP + (s16)offset);
5085 DECODE_PRINTF2("%x\n", target);
5087 sf = ACCESS_FLAG(F_SF) != 0;
5088 of = ACCESS_FLAG(F_OF) != 0;
5090 M.x86.R_IP = target;
5091 DECODE_CLEAR_SEGOVR();
5095 /****************************************************************************
5098 ****************************************************************************/
5099 void x86emuOp_jump_near_NL(u8 X86EMU_UNUSED(op1))
5105 /* jump to byte offset if sign flag not equal to overflow flag. */
5107 DECODE_PRINTF("JNL\t");
5108 offset = (s8)fetch_byte_imm();
5109 target = (u16)(M.x86.R_IP + (s16)offset);
5110 DECODE_PRINTF2("%x\n", target);
5112 sf = ACCESS_FLAG(F_SF) != 0;
5113 of = ACCESS_FLAG(F_OF) != 0;
5114 /* note: inverse of above, but using == instead of xor. */
5116 M.x86.R_IP = target;
5117 DECODE_CLEAR_SEGOVR();
5121 /****************************************************************************
5124 ****************************************************************************/
5125 void x86emuOp_jump_near_LE(u8 X86EMU_UNUSED(op1))
5131 /* jump to byte offset if sign flag not equal to overflow flag
5132 or the zero flag is set */
5134 DECODE_PRINTF("JLE\t");
5135 offset = (s8)fetch_byte_imm();
5136 target = (u16)(M.x86.R_IP + (s16)offset);
5137 DECODE_PRINTF2("%x\n", target);
5139 sf = ACCESS_FLAG(F_SF) != 0;
5140 of = ACCESS_FLAG(F_OF) != 0;
5141 if ((sf ^ of) || ACCESS_FLAG(F_ZF))
5142 M.x86.R_IP = target;
5143 DECODE_CLEAR_SEGOVR();
5147 /****************************************************************************
5150 ****************************************************************************/
5151 void x86emuOp_jump_near_NLE(u8 X86EMU_UNUSED(op1))
5157 /* jump to byte offset if sign flag equal to overflow flag.
5158 and the zero flag is clear */
5160 DECODE_PRINTF("JNLE\t");
5161 offset = (s8)fetch_byte_imm();
5162 target = (u16)(M.x86.R_IP + (s16)offset);
5163 DECODE_PRINTF2("%x\n", target);
5165 sf = ACCESS_FLAG(F_SF) != 0;
5166 of = ACCESS_FLAG(F_OF) != 0;
5167 if ((sf == of) && !ACCESS_FLAG(F_ZF))
5168 M.x86.R_IP = target;
5169 DECODE_CLEAR_SEGOVR();
5173 static u8 (*opc80_byte_operation[])(u8 d, u8 s) =
5185 /****************************************************************************
5188 ****************************************************************************/
5189 void x86emuOp_opc80_byte_RM_IMM(u8 X86EMU_UNUSED(op1))
5198 * Weirdo special case instruction format. Part of the opcode
5199 * held below in "RH". Doubly nested case would result, except
5200 * that the decoded instruction
5203 FETCH_DECODE_MODRM(mod, rh, rl);
5205 if (DEBUG_DECODE()) {
5206 /* XXX DECODE_PRINTF may be changed to something more
5207 general, so that it is important to leave the strings
5208 in the same format, even though the result is that the
5209 above test is done twice. */
5213 DECODE_PRINTF("ADD\t");
5216 DECODE_PRINTF("OR\t");
5219 DECODE_PRINTF("ADC\t");
5222 DECODE_PRINTF("SBB\t");
5225 DECODE_PRINTF("AND\t");
5228 DECODE_PRINTF("SUB\t");
5231 DECODE_PRINTF("XOR\t");
5234 DECODE_PRINTF("CMP\t");
5239 /* know operation, decode the mod byte to find the addressing
5243 DECODE_PRINTF("BYTE PTR ");
5244 destoffset = decode_rm00_address(rl);
5246 destval = fetch_data_byte(destoffset);
5247 imm = fetch_byte_imm();
5248 DECODE_PRINTF2("%x\n", imm);
5250 destval = (*opc80_byte_operation[rh]) (destval, imm);
5252 store_data_byte(destoffset, destval);
5255 DECODE_PRINTF("BYTE PTR ");
5256 destoffset = decode_rm01_address(rl);
5258 destval = fetch_data_byte(destoffset);
5259 imm = fetch_byte_imm();
5260 DECODE_PRINTF2("%x\n", imm);
5262 destval = (*opc80_byte_operation[rh]) (destval, imm);
5264 store_data_byte(destoffset, destval);
5267 DECODE_PRINTF("BYTE PTR ");
5268 destoffset = decode_rm10_address(rl);
5270 destval = fetch_data_byte(destoffset);
5271 imm = fetch_byte_imm();
5272 DECODE_PRINTF2("%x\n", imm);
5274 destval = (*opc80_byte_operation[rh]) (destval, imm);
5276 store_data_byte(destoffset, destval);
5278 case 3: /* register to register */
5279 destreg = DECODE_RM_BYTE_REGISTER(rl);
5281 imm = fetch_byte_imm();
5282 DECODE_PRINTF2("%x\n", imm);
5284 destval = (*opc80_byte_operation[rh]) (*destreg, imm);
5289 DECODE_CLEAR_SEGOVR();
5293 static u16 (*opc81_word_operation[])(u16 d, u16 s) =
5305 static u32 (*opc81_long_operation[])(u32 d, u32 s) =
5317 /****************************************************************************
5320 ****************************************************************************/
5321 void x86emuOp_opc81_word_RM_IMM(u8 X86EMU_UNUSED(op1))
5327 * Weirdo special case instruction format. Part of the opcode
5328 * held below in "RH". Doubly nested case would result, except
5329 * that the decoded instruction
5332 FETCH_DECODE_MODRM(mod, rh, rl);
5334 if (DEBUG_DECODE()) {
5335 /* XXX DECODE_PRINTF may be changed to something more
5336 general, so that it is important to leave the strings
5337 in the same format, even though the result is that the
5338 above test is done twice. */
5342 DECODE_PRINTF("ADD\t");
5345 DECODE_PRINTF("OR\t");
5348 DECODE_PRINTF("ADC\t");
5351 DECODE_PRINTF("SBB\t");
5354 DECODE_PRINTF("AND\t");
5357 DECODE_PRINTF("SUB\t");
5360 DECODE_PRINTF("XOR\t");
5363 DECODE_PRINTF("CMP\t");
5369 * Know operation, decode the mod byte to find the addressing
5374 if (M.x86.mode & SYSMODE_PREFIX_DATA) {
5377 DECODE_PRINTF("DWORD PTR ");
5378 destoffset = decode_rm00_address(rl);
5380 destval = fetch_data_long(destoffset);
5381 imm = fetch_long_imm();
5382 DECODE_PRINTF2("%x\n", imm);
5384 destval = (*opc81_long_operation[rh]) (destval, imm);
5386 store_data_long(destoffset, destval);
5390 DECODE_PRINTF("WORD PTR ");
5391 destoffset = decode_rm00_address(rl);
5393 destval = fetch_data_word(destoffset);
5394 imm = fetch_word_imm();
5395 DECODE_PRINTF2("%x\n", imm);
5397 destval = (*opc81_word_operation[rh]) (destval, imm);
5399 store_data_word(destoffset, destval);
5403 if (M.x86.mode & SYSMODE_PREFIX_DATA) {
5406 DECODE_PRINTF("DWORD PTR ");
5407 destoffset = decode_rm01_address(rl);
5409 destval = fetch_data_long(destoffset);
5410 imm = fetch_long_imm();
5411 DECODE_PRINTF2("%x\n", imm);
5413 destval = (*opc81_long_operation[rh]) (destval, imm);
5415 store_data_long(destoffset, destval);
5419 DECODE_PRINTF("WORD PTR ");
5420 destoffset = decode_rm01_address(rl);
5422 destval = fetch_data_word(destoffset);
5423 imm = fetch_word_imm();
5424 DECODE_PRINTF2("%x\n", imm);
5426 destval = (*opc81_word_operation[rh]) (destval, imm);
5428 store_data_word(destoffset, destval);
5432 if (M.x86.mode & SYSMODE_PREFIX_DATA) {
5435 DECODE_PRINTF("DWORD PTR ");
5436 destoffset = decode_rm10_address(rl);
5438 destval = fetch_data_long(destoffset);
5439 imm = fetch_long_imm();
5440 DECODE_PRINTF2("%x\n", imm);
5442 destval = (*opc81_long_operation[rh]) (destval, imm);
5444 store_data_long(destoffset, destval);
5448 DECODE_PRINTF("WORD PTR ");
5449 destoffset = decode_rm10_address(rl);
5451 destval = fetch_data_word(destoffset);
5452 imm = fetch_word_imm();
5453 DECODE_PRINTF2("%x\n", imm);
5455 destval = (*opc81_word_operation[rh]) (destval, imm);
5457 store_data_word(destoffset, destval);
5460 case 3: /* register to register */
5461 if (M.x86.mode & SYSMODE_PREFIX_DATA) {
5465 destreg = DECODE_RM_LONG_REGISTER(rl);
5467 imm = fetch_long_imm();
5468 DECODE_PRINTF2("%x\n", imm);
5470 destval = (*opc81_long_operation[rh]) (*destreg, imm);
5477 destreg = DECODE_RM_WORD_REGISTER(rl);
5479 imm = fetch_word_imm();
5480 DECODE_PRINTF2("%x\n", imm);
5482 destval = (*opc81_word_operation[rh]) (*destreg, imm);
5488 DECODE_CLEAR_SEGOVR();
5492 static u8 (*opc82_byte_operation[])(u8 s, u8 d) =
5495 or_byte, /*01 *//*YYY UNUSED ???? */
5498 and_byte, /*04 *//*YYY UNUSED ???? */
5500 xor_byte, /*06 *//*YYY UNUSED ???? */
5504 /****************************************************************************
5507 ****************************************************************************/
5508 void x86emuOp_opc82_byte_RM_IMM(u8 X86EMU_UNUSED(op1))
5517 * Weirdo special case instruction format. Part of the opcode
5518 * held below in "RH". Doubly nested case would result, except
5519 * that the decoded instruction Similar to opcode 81, except that
5520 * the immediate byte is sign extended to a word length.
5523 FETCH_DECODE_MODRM(mod, rh, rl);
5525 if (DEBUG_DECODE()) {
5526 /* XXX DECODE_PRINTF may be changed to something more
5527 general, so that it is important to leave the strings
5528 in the same format, even though the result is that the
5529 above test is done twice. */
5532 DECODE_PRINTF("ADD\t");
5535 DECODE_PRINTF("OR\t");
5538 DECODE_PRINTF("ADC\t");
5541 DECODE_PRINTF("SBB\t");
5544 DECODE_PRINTF("AND\t");
5547 DECODE_PRINTF("SUB\t");
5550 DECODE_PRINTF("XOR\t");
5553 DECODE_PRINTF("CMP\t");
5558 /* know operation, decode the mod byte to find the addressing
5562 DECODE_PRINTF("BYTE PTR ");
5563 destoffset = decode_rm00_address(rl);
5564 destval = fetch_data_byte(destoffset);
5565 imm = fetch_byte_imm();
5566 DECODE_PRINTF2(",%x\n", imm);
5568 destval = (*opc82_byte_operation[rh]) (destval, imm);
5570 store_data_byte(destoffset, destval);
5573 DECODE_PRINTF("BYTE PTR ");
5574 destoffset = decode_rm01_address(rl);
5575 destval = fetch_data_byte(destoffset);
5576 imm = fetch_byte_imm();
5577 DECODE_PRINTF2(",%x\n", imm);
5579 destval = (*opc82_byte_operation[rh]) (destval, imm);
5581 store_data_byte(destoffset, destval);
5584 DECODE_PRINTF("BYTE PTR ");
5585 destoffset = decode_rm10_address(rl);
5586 destval = fetch_data_byte(destoffset);
5587 imm = fetch_byte_imm();
5588 DECODE_PRINTF2(",%x\n", imm);
5590 destval = (*opc82_byte_operation[rh]) (destval, imm);
5592 store_data_byte(destoffset, destval);
5594 case 3: /* register to register */
5595 destreg = DECODE_RM_BYTE_REGISTER(rl);
5596 imm = fetch_byte_imm();
5597 DECODE_PRINTF2(",%x\n", imm);
5599 destval = (*opc82_byte_operation[rh]) (*destreg, imm);
5604 DECODE_CLEAR_SEGOVR();
5608 static u16 (*opc83_word_operation[])(u16 s, u16 d) =
5611 or_word, /*01 *//*YYY UNUSED ???? */
5614 and_word, /*04 *//*YYY UNUSED ???? */
5616 xor_word, /*06 *//*YYY UNUSED ???? */
5620 static u32 (*opc83_long_operation[])(u32 s, u32 d) =
5623 or_long, /*01 *//*YYY UNUSED ???? */
5626 and_long, /*04 *//*YYY UNUSED ???? */
5628 xor_long, /*06 *//*YYY UNUSED ???? */
5632 /****************************************************************************
5635 ****************************************************************************/
5636 void x86emuOp_opc83_word_RM_IMM(u8 X86EMU_UNUSED(op1))
5642 * Weirdo special case instruction format. Part of the opcode
5643 * held below in "RH". Doubly nested case would result, except
5644 * that the decoded instruction Similar to opcode 81, except that
5645 * the immediate byte is sign extended to a word length.
5648 FETCH_DECODE_MODRM(mod, rh, rl);
5650 if (DEBUG_DECODE()) {
5651 /* XXX DECODE_PRINTF may be changed to something more
5652 general, so that it is important to leave the strings
5653 in the same format, even though the result is that the
5654 above test is done twice. */
5657 DECODE_PRINTF("ADD\t");
5660 DECODE_PRINTF("OR\t");
5663 DECODE_PRINTF("ADC\t");
5666 DECODE_PRINTF("SBB\t");
5669 DECODE_PRINTF("AND\t");
5672 DECODE_PRINTF("SUB\t");
5675 DECODE_PRINTF("XOR\t");
5678 DECODE_PRINTF("CMP\t");
5683 /* know operation, decode the mod byte to find the addressing
5687 if (M.x86.mode & SYSMODE_PREFIX_DATA) {
5690 DECODE_PRINTF("DWORD PTR ");
5691 destoffset = decode_rm00_address(rl);
5692 destval = fetch_data_long(destoffset);
5693 imm = (s8) fetch_byte_imm();
5694 DECODE_PRINTF2(",%x\n", imm);
5696 destval = (*opc83_long_operation[rh]) (destval, imm);
5698 store_data_long(destoffset, destval);
5702 DECODE_PRINTF("WORD PTR ");
5703 destoffset = decode_rm00_address(rl);
5704 destval = fetch_data_word(destoffset);
5705 imm = (s8) fetch_byte_imm();
5706 DECODE_PRINTF2(",%x\n", imm);
5708 destval = (*opc83_word_operation[rh]) (destval, imm);
5710 store_data_word(destoffset, destval);
5714 if (M.x86.mode & SYSMODE_PREFIX_DATA) {
5717 DECODE_PRINTF("DWORD PTR ");
5718 destoffset = decode_rm01_address(rl);
5719 destval = fetch_data_long(destoffset);
5720 imm = (s8) fetch_byte_imm();
5721 DECODE_PRINTF2(",%x\n", imm);
5723 destval = (*opc83_long_operation[rh]) (destval, imm);
5725 store_data_long(destoffset, destval);
5729 DECODE_PRINTF("WORD PTR ");
5730 destoffset = decode_rm01_address(rl);
5731 destval = fetch_data_word(destoffset);
5732 imm = (s8) fetch_byte_imm();
5733 DECODE_PRINTF2(",%x\n", imm);
5735 destval = (*opc83_word_operation[rh]) (destval, imm);
5737 store_data_word(destoffset, destval);
5741 if (M.x86.mode & SYSMODE_PREFIX_DATA) {
5744 DECODE_PRINTF("DWORD PTR ");
5745 destoffset = decode_rm10_address(rl);
5746 destval = fetch_data_long(destoffset);
5747 imm = (s8) fetch_byte_imm();
5748 DECODE_PRINTF2(",%x\n", imm);
5750 destval = (*opc83_long_operation[rh]) (destval, imm);
5752 store_data_long(destoffset, destval);
5756 DECODE_PRINTF("WORD PTR ");
5757 destoffset = decode_rm10_address(rl);
5758 destval = fetch_data_word(destoffset);
5759 imm = (s8) fetch_byte_imm();
5760 DECODE_PRINTF2(",%x\n", imm);
5762 destval = (*opc83_word_operation[rh]) (destval, imm);
5764 store_data_word(destoffset, destval);
5767 case 3: /* register to register */
5768 if (M.x86.mode & SYSMODE_PREFIX_DATA) {
5772 destreg = DECODE_RM_LONG_REGISTER(rl);
5773 imm = (s8) fetch_byte_imm();
5774 DECODE_PRINTF2(",%x\n", imm);
5776 destval = (*opc83_long_operation[rh]) (*destreg, imm);
5783 destreg = DECODE_RM_WORD_REGISTER(rl);
5784 imm = (s8) fetch_byte_imm();
5785 DECODE_PRINTF2(",%x\n", imm);
5787 destval = (*opc83_word_operation[rh]) (*destreg, imm);
5793 DECODE_CLEAR_SEGOVR();
5797 /****************************************************************************
5800 ****************************************************************************/
5801 void x86emuOp_test_byte_RM_R(u8 X86EMU_UNUSED(op1))
5804 u8 *destreg, *srcreg;
5809 DECODE_PRINTF("TEST\t");
5810 FETCH_DECODE_MODRM(mod, rh, rl);
5813 destoffset = decode_rm00_address(rl);
5815 destval = fetch_data_byte(destoffset);
5816 srcreg = DECODE_RM_BYTE_REGISTER(rh);
5817 DECODE_PRINTF("\n");
5819 test_byte(destval, *srcreg);
5822 destoffset = decode_rm01_address(rl);
5824 destval = fetch_data_byte(destoffset);
5825 srcreg = DECODE_RM_BYTE_REGISTER(rh);
5826 DECODE_PRINTF("\n");
5828 test_byte(destval, *srcreg);
5831 destoffset = decode_rm10_address(rl);
5833 destval = fetch_data_byte(destoffset);
5834 srcreg = DECODE_RM_BYTE_REGISTER(rh);
5835 DECODE_PRINTF("\n");
5837 test_byte(destval, *srcreg);
5839 case 3: /* register to register */
5840 destreg = DECODE_RM_BYTE_REGISTER(rl);
5842 srcreg = DECODE_RM_BYTE_REGISTER(rh);
5843 DECODE_PRINTF("\n");
5845 test_byte(*destreg, *srcreg);
5848 DECODE_CLEAR_SEGOVR();
5852 /****************************************************************************
5855 ****************************************************************************/
5856 void x86emuOp_test_word_RM_R(u8 X86EMU_UNUSED(op1))
5862 DECODE_PRINTF("TEST\t");
5863 FETCH_DECODE_MODRM(mod, rh, rl);
5866 if (M.x86.mode & SYSMODE_PREFIX_DATA) {
5870 destoffset = decode_rm00_address(rl);
5872 destval = fetch_data_long(destoffset);
5873 srcreg = DECODE_RM_LONG_REGISTER(rh);
5874 DECODE_PRINTF("\n");
5876 test_long(destval, *srcreg);
5881 destoffset = decode_rm00_address(rl);
5883 destval = fetch_data_word(destoffset);
5884 srcreg = DECODE_RM_WORD_REGISTER(rh);
5885 DECODE_PRINTF("\n");
5887 test_word(destval, *srcreg);
5891 if (M.x86.mode & SYSMODE_PREFIX_DATA) {
5895 destoffset = decode_rm01_address(rl);
5897 destval = fetch_data_long(destoffset);
5898 srcreg = DECODE_RM_LONG_REGISTER(rh);
5899 DECODE_PRINTF("\n");
5901 test_long(destval, *srcreg);
5906 destoffset = decode_rm01_address(rl);
5908 destval = fetch_data_word(destoffset);
5909 srcreg = DECODE_RM_WORD_REGISTER(rh);
5910 DECODE_PRINTF("\n");
5912 test_word(destval, *srcreg);
5916 if (M.x86.mode & SYSMODE_PREFIX_DATA) {
5920 destoffset = decode_rm10_address(rl);
5922 destval = fetch_data_long(destoffset);
5923 srcreg = DECODE_RM_LONG_REGISTER(rh);
5924 DECODE_PRINTF("\n");
5926 test_long(destval, *srcreg);
5931 destoffset = decode_rm10_address(rl);
5933 destval = fetch_data_word(destoffset);
5934 srcreg = DECODE_RM_WORD_REGISTER(rh);
5935 DECODE_PRINTF("\n");
5937 test_word(destval, *srcreg);
5940 case 3: /* register to register */
5941 if (M.x86.mode & SYSMODE_PREFIX_DATA) {
5942 u32 *destreg,*srcreg;
5944 destreg = DECODE_RM_LONG_REGISTER(rl);
5946 srcreg = DECODE_RM_LONG_REGISTER(rh);
5947 DECODE_PRINTF("\n");
5949 test_long(*destreg, *srcreg);
5951 u16 *destreg,*srcreg;
5953 destreg = DECODE_RM_WORD_REGISTER(rl);
5955 srcreg = DECODE_RM_WORD_REGISTER(rh);
5956 DECODE_PRINTF("\n");
5958 test_word(*destreg, *srcreg);
5962 DECODE_CLEAR_SEGOVR();
5966 /****************************************************************************
5969 ****************************************************************************/
5970 void x86emuOp_xchg_byte_RM_R(u8 X86EMU_UNUSED(op1))
5973 u8 *destreg, *srcreg;
5979 DECODE_PRINTF("XCHG\t");
5980 FETCH_DECODE_MODRM(mod, rh, rl);
5983 destoffset = decode_rm00_address(rl);
5985 destval = fetch_data_byte(destoffset);
5986 srcreg = DECODE_RM_BYTE_REGISTER(rh);
5987 DECODE_PRINTF("\n");
5992 store_data_byte(destoffset, destval);
5995 destoffset = decode_rm01_address(rl);
5997 destval = fetch_data_byte(destoffset);
5998 srcreg = DECODE_RM_BYTE_REGISTER(rh);
5999 DECODE_PRINTF("\n");
6004 store_data_byte(destoffset, destval);
6007 destoffset = decode_rm10_address(rl);
6009 destval = fetch_data_byte(destoffset);
6010 srcreg = DECODE_RM_BYTE_REGISTER(rh);
6011 DECODE_PRINTF("\n");
6016 store_data_byte(destoffset, destval);
6018 case 3: /* register to register */
6019 destreg = DECODE_RM_BYTE_REGISTER(rl);
6021 srcreg = DECODE_RM_BYTE_REGISTER(rh);
6022 DECODE_PRINTF("\n");
6029 DECODE_CLEAR_SEGOVR();
6033 /****************************************************************************
6036 ****************************************************************************/
6037 void x86emuOp_xchg_word_RM_R(u8 X86EMU_UNUSED(op1))
6043 DECODE_PRINTF("XCHG\t");
6044 FETCH_DECODE_MODRM(mod, rh, rl);
6047 if (M.x86.mode & SYSMODE_PREFIX_DATA) {
6051 destoffset = decode_rm00_address(rl);
6053 destval = fetch_data_long(destoffset);
6054 srcreg = DECODE_RM_LONG_REGISTER(rh);
6055 DECODE_PRINTF("\n");
6060 store_data_long(destoffset, destval);
6065 destoffset = decode_rm00_address(rl);
6067 destval = fetch_data_word(destoffset);
6068 srcreg = DECODE_RM_WORD_REGISTER(rh);
6069 DECODE_PRINTF("\n");
6074 store_data_word(destoffset, destval);
6078 if (M.x86.mode & SYSMODE_PREFIX_DATA) {
6082 destoffset = decode_rm01_address(rl);
6084 destval = fetch_data_long(destoffset);
6085 srcreg = DECODE_RM_LONG_REGISTER(rh);
6086 DECODE_PRINTF("\n");
6091 store_data_long(destoffset, destval);
6096 destoffset = decode_rm01_address(rl);
6098 destval = fetch_data_word(destoffset);
6099 srcreg = DECODE_RM_WORD_REGISTER(rh);
6100 DECODE_PRINTF("\n");
6105 store_data_word(destoffset, destval);
6109 if (M.x86.mode & SYSMODE_PREFIX_DATA) {
6113 destoffset = decode_rm10_address(rl);
6115 destval = fetch_data_long(destoffset);
6116 srcreg = DECODE_RM_LONG_REGISTER(rh);
6117 DECODE_PRINTF("\n");
6122 store_data_long(destoffset, destval);
6127 destoffset = decode_rm10_address(rl);
6129 destval = fetch_data_word(destoffset);
6130 srcreg = DECODE_RM_WORD_REGISTER(rh);
6131 DECODE_PRINTF("\n");
6136 store_data_word(destoffset, destval);
6139 case 3: /* register to register */
6140 if (M.x86.mode & SYSMODE_PREFIX_DATA) {
6141 u32 *destreg,*srcreg;
6144 destreg = DECODE_RM_LONG_REGISTER(rl);
6146 srcreg = DECODE_RM_LONG_REGISTER(rh);
6147 DECODE_PRINTF("\n");
6153 u16 *destreg,*srcreg;
6156 destreg = DECODE_RM_WORD_REGISTER(rl);
6158 srcreg = DECODE_RM_WORD_REGISTER(rh);
6159 DECODE_PRINTF("\n");
6167 DECODE_CLEAR_SEGOVR();
6171 /****************************************************************************
6174 ****************************************************************************/
6175 void x86emuOp_mov_byte_RM_R(u8 X86EMU_UNUSED(op1))
6178 u8 *destreg, *srcreg;
6182 DECODE_PRINTF("MOV\t");
6183 FETCH_DECODE_MODRM(mod, rh, rl);
6186 destoffset = decode_rm00_address(rl);
6188 srcreg = DECODE_RM_BYTE_REGISTER(rh);
6189 DECODE_PRINTF("\n");
6191 store_data_byte(destoffset, *srcreg);
6194 destoffset = decode_rm01_address(rl);
6196 srcreg = DECODE_RM_BYTE_REGISTER(rh);
6197 DECODE_PRINTF("\n");
6199 store_data_byte(destoffset, *srcreg);
6202 destoffset = decode_rm10_address(rl);
6204 srcreg = DECODE_RM_BYTE_REGISTER(rh);
6205 DECODE_PRINTF("\n");
6207 store_data_byte(destoffset, *srcreg);
6209 case 3: /* register to register */
6210 destreg = DECODE_RM_BYTE_REGISTER(rl);
6212 srcreg = DECODE_RM_BYTE_REGISTER(rh);
6213 DECODE_PRINTF("\n");
6218 DECODE_CLEAR_SEGOVR();
6222 /****************************************************************************
6225 ****************************************************************************/
6226 void x86emuOp_mov_word_RM_R(u8 X86EMU_UNUSED(op1))
6232 DECODE_PRINTF("MOV\t");
6233 FETCH_DECODE_MODRM(mod, rh, rl);
6236 if (M.x86.mode & SYSMODE_PREFIX_DATA) {
6239 destoffset = decode_rm00_address(rl);
6241 srcreg = DECODE_RM_LONG_REGISTER(rh);
6242 DECODE_PRINTF("\n");
6244 store_data_long(destoffset, *srcreg);
6248 destoffset = decode_rm00_address(rl);
6250 srcreg = DECODE_RM_WORD_REGISTER(rh);
6251 DECODE_PRINTF("\n");
6253 store_data_word(destoffset, *srcreg);
6257 if (M.x86.mode & SYSMODE_PREFIX_DATA) {
6260 destoffset = decode_rm01_address(rl);
6262 srcreg = DECODE_RM_LONG_REGISTER(rh);
6263 DECODE_PRINTF("\n");
6265 store_data_long(destoffset, *srcreg);
6269 destoffset = decode_rm01_address(rl);
6271 srcreg = DECODE_RM_WORD_REGISTER(rh);
6272 DECODE_PRINTF("\n");
6274 store_data_word(destoffset, *srcreg);
6278 if (M.x86.mode & SYSMODE_PREFIX_DATA) {
6281 destoffset = decode_rm10_address(rl);
6283 srcreg = DECODE_RM_LONG_REGISTER(rh);
6284 DECODE_PRINTF("\n");
6286 store_data_long(destoffset, *srcreg);
6290 destoffset = decode_rm10_address(rl);
6292 srcreg = DECODE_RM_WORD_REGISTER(rh);
6293 DECODE_PRINTF("\n");
6295 store_data_word(destoffset, *srcreg);
6298 case 3: /* register to register */
6299 if (M.x86.mode & SYSMODE_PREFIX_DATA) {
6300 u32 *destreg,*srcreg;
6302 destreg = DECODE_RM_LONG_REGISTER(rl);
6304 srcreg = DECODE_RM_LONG_REGISTER(rh);
6305 DECODE_PRINTF("\n");
6309 u16 *destreg,*srcreg;
6311 destreg = DECODE_RM_WORD_REGISTER(rl);
6313 srcreg = DECODE_RM_WORD_REGISTER(rh);
6314 DECODE_PRINTF("\n");
6320 DECODE_CLEAR_SEGOVR();
6324 /****************************************************************************
6327 ****************************************************************************/
6328 void x86emuOp_mov_byte_R_RM(u8 X86EMU_UNUSED(op1))
6331 u8 *destreg, *srcreg;
6336 DECODE_PRINTF("MOV\t");
6337 FETCH_DECODE_MODRM(mod, rh, rl);
6340 destreg = DECODE_RM_BYTE_REGISTER(rh);
6342 srcoffset = decode_rm00_address(rl);
6343 srcval = fetch_data_byte(srcoffset);
6344 DECODE_PRINTF("\n");
6349 destreg = DECODE_RM_BYTE_REGISTER(rh);
6351 srcoffset = decode_rm01_address(rl);
6352 srcval = fetch_data_byte(srcoffset);
6353 DECODE_PRINTF("\n");
6358 destreg = DECODE_RM_BYTE_REGISTER(rh);
6360 srcoffset = decode_rm10_address(rl);
6361 srcval = fetch_data_byte(srcoffset);
6362 DECODE_PRINTF("\n");
6366 case 3: /* register to register */
6367 destreg = DECODE_RM_BYTE_REGISTER(rh);
6369 srcreg = DECODE_RM_BYTE_REGISTER(rl);
6370 DECODE_PRINTF("\n");
6375 DECODE_CLEAR_SEGOVR();
6379 /****************************************************************************
6382 ****************************************************************************/
6383 void x86emuOp_mov_word_R_RM(u8 X86EMU_UNUSED(op1))
6389 DECODE_PRINTF("MOV\t");
6390 FETCH_DECODE_MODRM(mod, rh, rl);
6393 if (M.x86.mode & SYSMODE_PREFIX_DATA) {
6397 destreg = DECODE_RM_LONG_REGISTER(rh);
6399 srcoffset = decode_rm00_address(rl);
6400 srcval = fetch_data_long(srcoffset);
6401 DECODE_PRINTF("\n");
6408 destreg = DECODE_RM_WORD_REGISTER(rh);
6410 srcoffset = decode_rm00_address(rl);
6411 srcval = fetch_data_word(srcoffset);
6412 DECODE_PRINTF("\n");
6418 if (M.x86.mode & SYSMODE_PREFIX_DATA) {
6422 destreg = DECODE_RM_LONG_REGISTER(rh);
6424 srcoffset = decode_rm01_address(rl);
6425 srcval = fetch_data_long(srcoffset);
6426 DECODE_PRINTF("\n");
6433 destreg = DECODE_RM_WORD_REGISTER(rh);
6435 srcoffset = decode_rm01_address(rl);
6436 srcval = fetch_data_word(srcoffset);
6437 DECODE_PRINTF("\n");
6443 if (M.x86.mode & SYSMODE_PREFIX_DATA) {
6447 destreg = DECODE_RM_LONG_REGISTER(rh);
6449 srcoffset = decode_rm10_address(rl);
6450 srcval = fetch_data_long(srcoffset);
6451 DECODE_PRINTF("\n");
6458 destreg = DECODE_RM_WORD_REGISTER(rh);
6460 srcoffset = decode_rm10_address(rl);
6461 srcval = fetch_data_word(srcoffset);
6462 DECODE_PRINTF("\n");
6467 case 3: /* register to register */
6468 if (M.x86.mode & SYSMODE_PREFIX_DATA) {
6469 u32 *destreg, *srcreg;
6471 destreg = DECODE_RM_LONG_REGISTER(rh);
6473 srcreg = DECODE_RM_LONG_REGISTER(rl);
6474 DECODE_PRINTF("\n");
6478 u16 *destreg, *srcreg;
6480 destreg = DECODE_RM_WORD_REGISTER(rh);
6482 srcreg = DECODE_RM_WORD_REGISTER(rl);
6483 DECODE_PRINTF("\n");
6489 DECODE_CLEAR_SEGOVR();
6493 /****************************************************************************
6496 ****************************************************************************/
6497 void x86emuOp_mov_word_RM_SR(u8 X86EMU_UNUSED(op1))
6500 u16 *destreg, *srcreg;
6505 DECODE_PRINTF("MOV\t");
6506 FETCH_DECODE_MODRM(mod, rh, rl);
6509 destoffset = decode_rm00_address(rl);
6511 srcreg = decode_rm_seg_register(rh);
6512 DECODE_PRINTF("\n");
6515 store_data_word(destoffset, destval);
6518 destoffset = decode_rm01_address(rl);
6520 srcreg = decode_rm_seg_register(rh);
6521 DECODE_PRINTF("\n");
6524 store_data_word(destoffset, destval);
6527 destoffset = decode_rm10_address(rl);
6529 srcreg = decode_rm_seg_register(rh);
6530 DECODE_PRINTF("\n");
6533 store_data_word(destoffset, destval);
6535 case 3: /* register to register */
6536 destreg = DECODE_RM_WORD_REGISTER(rl);
6538 srcreg = decode_rm_seg_register(rh);
6539 DECODE_PRINTF("\n");
6544 DECODE_CLEAR_SEGOVR();
6548 /****************************************************************************
6551 ****************************************************************************/
6552 void x86emuOp_lea_word_R_M(u8 X86EMU_UNUSED(op1))
6559 * TODO: Need to handle address size prefix!
6561 * lea eax,[eax+ebx*2] ??
6565 DECODE_PRINTF("LEA\t");
6566 FETCH_DECODE_MODRM(mod, rh, rl);
6569 srcreg = DECODE_RM_WORD_REGISTER(rh);
6571 destoffset = decode_rm00_address(rl);
6572 DECODE_PRINTF("\n");
6574 *srcreg = (u16)destoffset;
6577 srcreg = DECODE_RM_WORD_REGISTER(rh);
6579 destoffset = decode_rm01_address(rl);
6580 DECODE_PRINTF("\n");
6582 *srcreg = (u16)destoffset;
6585 srcreg = DECODE_RM_WORD_REGISTER(rh);
6587 destoffset = decode_rm10_address(rl);
6588 DECODE_PRINTF("\n");
6590 *srcreg = (u16)destoffset;
6592 case 3: /* register to register */
6593 /* undefined. Do nothing. */
6596 DECODE_CLEAR_SEGOVR();
6600 /****************************************************************************
6603 ****************************************************************************/
6604 void x86emuOp_mov_word_SR_RM(u8 X86EMU_UNUSED(op1))
6607 u16 *destreg, *srcreg;
6612 DECODE_PRINTF("MOV\t");
6613 FETCH_DECODE_MODRM(mod, rh, rl);
6616 destreg = decode_rm_seg_register(rh);
6618 srcoffset = decode_rm00_address(rl);
6619 srcval = fetch_data_word(srcoffset);
6620 DECODE_PRINTF("\n");
6625 destreg = decode_rm_seg_register(rh);
6627 srcoffset = decode_rm01_address(rl);
6628 srcval = fetch_data_word(srcoffset);
6629 DECODE_PRINTF("\n");
6634 destreg = decode_rm_seg_register(rh);
6636 srcoffset = decode_rm10_address(rl);
6637 srcval = fetch_data_word(srcoffset);
6638 DECODE_PRINTF("\n");
6642 case 3: /* register to register */
6643 destreg = decode_rm_seg_register(rh);
6645 srcreg = DECODE_RM_WORD_REGISTER(rl);
6646 DECODE_PRINTF("\n");
6652 * Clean up, and reset all the R_xSP pointers to the correct
6653 * locations. This is about 3x too much overhead (doing all the
6654 * segreg ptrs when only one is needed, but this instruction
6655 * *cannot* be that common, and this isn't too much work anyway.
6657 DECODE_CLEAR_SEGOVR();
6661 /****************************************************************************
6664 ****************************************************************************/
6665 void x86emuOp_pop_RM(u8 X86EMU_UNUSED(op1))
6671 DECODE_PRINTF("POP\t");
6672 FETCH_DECODE_MODRM(mod, rh, rl);
6674 DECODE_PRINTF("ILLEGAL DECODE OF OPCODE 8F\n");
6679 if (M.x86.mode & SYSMODE_PREFIX_DATA) {
6682 destoffset = decode_rm00_address(rl);
6683 DECODE_PRINTF("\n");
6685 destval = pop_long();
6686 store_data_long(destoffset, destval);
6690 destoffset = decode_rm00_address(rl);
6691 DECODE_PRINTF("\n");
6693 destval = pop_word();
6694 store_data_word(destoffset, destval);
6698 if (M.x86.mode & SYSMODE_PREFIX_DATA) {
6701 destoffset = decode_rm01_address(rl);
6702 DECODE_PRINTF("\n");
6704 destval = pop_long();
6705 store_data_long(destoffset, destval);
6709 destoffset = decode_rm01_address(rl);
6710 DECODE_PRINTF("\n");
6712 destval = pop_word();
6713 store_data_word(destoffset, destval);
6717 if (M.x86.mode & SYSMODE_PREFIX_DATA) {
6720 destoffset = decode_rm10_address(rl);
6721 DECODE_PRINTF("\n");
6723 destval = pop_long();
6724 store_data_long(destoffset, destval);
6728 destoffset = decode_rm10_address(rl);
6729 DECODE_PRINTF("\n");
6731 destval = pop_word();
6732 store_data_word(destoffset, destval);
6735 case 3: /* register to register */
6736 if (M.x86.mode & SYSMODE_PREFIX_DATA) {
6739 destreg = DECODE_RM_LONG_REGISTER(rl);
6740 DECODE_PRINTF("\n");
6742 *destreg = pop_long();
6746 destreg = DECODE_RM_WORD_REGISTER(rl);
6747 DECODE_PRINTF("\n");
6749 *destreg = pop_word();
6753 DECODE_CLEAR_SEGOVR();
6757 /****************************************************************************
6760 ****************************************************************************/
6761 void x86emuOp_nop(u8 X86EMU_UNUSED(op1))
6764 DECODE_PRINTF("NOP\n");
6766 DECODE_CLEAR_SEGOVR();
6770 /****************************************************************************
6773 ****************************************************************************/
6774 void x86emuOp_xchg_word_AX_CX(u8 X86EMU_UNUSED(op1))
6779 if (M.x86.mode & SYSMODE_PREFIX_DATA) {
6780 DECODE_PRINTF("XCHG\tEAX,ECX\n");
6782 DECODE_PRINTF("XCHG\tAX,CX\n");
6785 if (M.x86.mode & SYSMODE_PREFIX_DATA) {
6787 M.x86.R_EAX = M.x86.R_ECX;
6791 M.x86.R_AX = M.x86.R_CX;
6792 M.x86.R_CX = (u16)tmp;
6794 DECODE_CLEAR_SEGOVR();
6798 /****************************************************************************
6801 ****************************************************************************/
6802 void x86emuOp_xchg_word_AX_DX(u8 X86EMU_UNUSED(op1))
6807 if (M.x86.mode & SYSMODE_PREFIX_DATA) {
6808 DECODE_PRINTF("XCHG\tEAX,EDX\n");
6810 DECODE_PRINTF("XCHG\tAX,DX\n");
6813 if (M.x86.mode & SYSMODE_PREFIX_DATA) {
6815 M.x86.R_EAX = M.x86.R_EDX;
6819 M.x86.R_AX = M.x86.R_DX;
6820 M.x86.R_DX = (u16)tmp;
6822 DECODE_CLEAR_SEGOVR();
6826 /****************************************************************************
6829 ****************************************************************************/
6830 void x86emuOp_xchg_word_AX_BX(u8 X86EMU_UNUSED(op1))
6835 if (M.x86.mode & SYSMODE_PREFIX_DATA) {
6836 DECODE_PRINTF("XCHG\tEAX,EBX\n");
6838 DECODE_PRINTF("XCHG\tAX,BX\n");
6841 if (M.x86.mode & SYSMODE_PREFIX_DATA) {
6843 M.x86.R_EAX = M.x86.R_EBX;
6847 M.x86.R_AX = M.x86.R_BX;
6848 M.x86.R_BX = (u16)tmp;
6850 DECODE_CLEAR_SEGOVR();
6854 /****************************************************************************
6857 ****************************************************************************/
6858 void x86emuOp_xchg_word_AX_SP(u8 X86EMU_UNUSED(op1))
6863 if (M.x86.mode & SYSMODE_PREFIX_DATA) {
6864 DECODE_PRINTF("XCHG\tEAX,ESP\n");
6866 DECODE_PRINTF("XCHG\tAX,SP\n");
6869 if (M.x86.mode & SYSMODE_PREFIX_DATA) {
6871 M.x86.R_EAX = M.x86.R_ESP;
6875 M.x86.R_AX = M.x86.R_SP;
6876 M.x86.R_SP = (u16)tmp;
6878 DECODE_CLEAR_SEGOVR();
6882 /****************************************************************************
6885 ****************************************************************************/
6886 void x86emuOp_xchg_word_AX_BP(u8 X86EMU_UNUSED(op1))
6891 if (M.x86.mode & SYSMODE_PREFIX_DATA) {
6892 DECODE_PRINTF("XCHG\tEAX,EBP\n");
6894 DECODE_PRINTF("XCHG\tAX,BP\n");
6897 if (M.x86.mode & SYSMODE_PREFIX_DATA) {
6899 M.x86.R_EAX = M.x86.R_EBP;
6903 M.x86.R_AX = M.x86.R_BP;
6904 M.x86.R_BP = (u16)tmp;
6906 DECODE_CLEAR_SEGOVR();
6910 /****************************************************************************
6913 ****************************************************************************/
6914 void x86emuOp_xchg_word_AX_SI(u8 X86EMU_UNUSED(op1))
6919 if (M.x86.mode & SYSMODE_PREFIX_DATA) {
6920 DECODE_PRINTF("XCHG\tEAX,ESI\n");
6922 DECODE_PRINTF("XCHG\tAX,SI\n");
6925 if (M.x86.mode & SYSMODE_PREFIX_DATA) {
6927 M.x86.R_EAX = M.x86.R_ESI;
6931 M.x86.R_AX = M.x86.R_SI;
6932 M.x86.R_SI = (u16)tmp;
6934 DECODE_CLEAR_SEGOVR();
6938 /****************************************************************************
6941 ****************************************************************************/
6942 void x86emuOp_xchg_word_AX_DI(u8 X86EMU_UNUSED(op1))
6947 if (M.x86.mode & SYSMODE_PREFIX_DATA) {
6948 DECODE_PRINTF("XCHG\tEAX,EDI\n");
6950 DECODE_PRINTF("XCHG\tAX,DI\n");
6953 if (M.x86.mode & SYSMODE_PREFIX_DATA) {
6955 M.x86.R_EAX = M.x86.R_EDI;
6959 M.x86.R_AX = M.x86.R_DI;
6960 M.x86.R_DI = (u16)tmp;
6962 DECODE_CLEAR_SEGOVR();
6966 /****************************************************************************
6969 ****************************************************************************/
6970 void x86emuOp_cbw(u8 X86EMU_UNUSED(op1))
6973 if (M.x86.mode & SYSMODE_PREFIX_DATA) {
6974 DECODE_PRINTF("CWDE\n");
6976 DECODE_PRINTF("CBW\n");
6979 if (M.x86.mode & SYSMODE_PREFIX_DATA) {
6980 if (M.x86.R_AX & 0x8000) {
6981 M.x86.R_EAX |= 0xffff0000;
6983 M.x86.R_EAX &= 0x0000ffff;
6986 if (M.x86.R_AL & 0x80) {
6992 DECODE_CLEAR_SEGOVR();
6996 /****************************************************************************
6999 ****************************************************************************/
7000 void x86emuOp_cwd(u8 X86EMU_UNUSED(op1))
7003 if (M.x86.mode & SYSMODE_PREFIX_DATA) {
7004 DECODE_PRINTF("CDQ\n");
7006 DECODE_PRINTF("CWD\n");
7008 DECODE_PRINTF("CWD\n");
7010 if (M.x86.mode & SYSMODE_PREFIX_DATA) {
7011 if (M.x86.R_EAX & 0x80000000) {
7012 M.x86.R_EDX = 0xffffffff;
7017 if (M.x86.R_AX & 0x8000) {
7018 M.x86.R_DX = 0xffff;
7023 DECODE_CLEAR_SEGOVR();
7027 /****************************************************************************
7030 ****************************************************************************/
7031 void x86emuOp_call_far_IMM(u8 X86EMU_UNUSED(op1))
7036 DECODE_PRINTF("CALL\t");
7037 faroff = fetch_word_imm();
7038 farseg = fetch_word_imm();
7039 DECODE_PRINTF2("%04x:", farseg);
7040 DECODE_PRINTF2("%04x\n", faroff);
7041 CALL_TRACE(M.x86.saved_cs, M.x86.saved_ip, farseg, faroff, "FAR ");
7045 * Hooked interrupt vectors calling into our "BIOS" will cause
7046 * problems unless all intersegment stuff is checked for BIOS
7047 * access. Check needed here. For moment, let it alone.
7050 push_word(M.x86.R_CS);
7051 M.x86.R_CS = farseg;
7052 push_word(M.x86.R_IP);
7053 M.x86.R_IP = faroff;
7054 DECODE_CLEAR_SEGOVR();
7058 /****************************************************************************
7061 ****************************************************************************/
7062 void x86emuOp_wait(u8 X86EMU_UNUSED(op1))
7065 DECODE_PRINTF("WAIT");
7068 DECODE_CLEAR_SEGOVR();
7072 /****************************************************************************
7075 ****************************************************************************/
7076 void x86emuOp_pushf_word(u8 X86EMU_UNUSED(op1))
7081 if (M.x86.mode & SYSMODE_PREFIX_DATA) {
7082 DECODE_PRINTF("PUSHFD\n");
7084 DECODE_PRINTF("PUSHF\n");
7088 /* clear out *all* bits not representing flags, and turn on real bits */
7089 flags = (M.x86.R_EFLG & F_MSK) | F_ALWAYS_ON;
7090 if (M.x86.mode & SYSMODE_PREFIX_DATA) {
7093 push_word((u16)flags);
7095 DECODE_CLEAR_SEGOVR();
7099 /****************************************************************************
7102 ****************************************************************************/
7103 void x86emuOp_popf_word(u8 X86EMU_UNUSED(op1))
7106 if (M.x86.mode & SYSMODE_PREFIX_DATA) {
7107 DECODE_PRINTF("POPFD\n");
7109 DECODE_PRINTF("POPF\n");
7112 if (M.x86.mode & SYSMODE_PREFIX_DATA) {
7113 M.x86.R_EFLG = pop_long();
7115 M.x86.R_FLG = pop_word();
7117 DECODE_CLEAR_SEGOVR();
7121 /****************************************************************************
7124 ****************************************************************************/
7125 void x86emuOp_sahf(u8 X86EMU_UNUSED(op1))
7128 DECODE_PRINTF("SAHF\n");
7130 /* clear the lower bits of the flag register */
7131 M.x86.R_FLG &= 0xffffff00;
7132 /* or in the AH register into the flags register */
7133 M.x86.R_FLG |= M.x86.R_AH;
7134 DECODE_CLEAR_SEGOVR();
7138 /****************************************************************************
7141 ****************************************************************************/
7142 void x86emuOp_lahf(u8 X86EMU_UNUSED(op1))
7145 DECODE_PRINTF("LAHF\n");
7147 M.x86.R_AH = (u8)(M.x86.R_FLG & 0xff);
7148 /*undocumented TC++ behavior??? Nope. It's documented, but
7149 you have too look real hard to notice it. */
7151 DECODE_CLEAR_SEGOVR();
7155 /****************************************************************************
7158 ****************************************************************************/
7159 void x86emuOp_mov_AL_M_IMM(u8 X86EMU_UNUSED(op1))
7164 DECODE_PRINTF("MOV\tAL,");
7165 offset = fetch_word_imm();
7166 DECODE_PRINTF2("[%04x]\n", offset);
7168 M.x86.R_AL = fetch_data_byte(offset);
7169 DECODE_CLEAR_SEGOVR();
7173 /****************************************************************************
7176 ****************************************************************************/
7177 void x86emuOp_mov_AX_M_IMM(u8 X86EMU_UNUSED(op1))
7182 offset = fetch_word_imm();
7183 if (M.x86.mode & SYSMODE_PREFIX_DATA) {
7184 DECODE_PRINTF2("MOV\tEAX,[%04x]\n", offset);
7186 DECODE_PRINTF2("MOV\tAX,[%04x]\n", offset);
7189 if (M.x86.mode & SYSMODE_PREFIX_DATA) {
7190 M.x86.R_EAX = fetch_data_long(offset);
7192 M.x86.R_AX = fetch_data_word(offset);
7194 DECODE_CLEAR_SEGOVR();
7198 /****************************************************************************
7201 ****************************************************************************/
7202 void x86emuOp_mov_M_AL_IMM(u8 X86EMU_UNUSED(op1))
7207 DECODE_PRINTF("MOV\t");
7208 offset = fetch_word_imm();
7209 DECODE_PRINTF2("[%04x],AL\n", offset);
7211 store_data_byte(offset, M.x86.R_AL);
7212 DECODE_CLEAR_SEGOVR();
7216 /****************************************************************************
7219 ****************************************************************************/
7220 void x86emuOp_mov_M_AX_IMM(u8 X86EMU_UNUSED(op1))
7225 offset = fetch_word_imm();
7226 if (M.x86.mode & SYSMODE_PREFIX_DATA) {
7227 DECODE_PRINTF2("MOV\t[%04x],EAX\n", offset);
7229 DECODE_PRINTF2("MOV\t[%04x],AX\n", offset);
7232 if (M.x86.mode & SYSMODE_PREFIX_DATA) {
7233 store_data_long(offset, M.x86.R_EAX);
7235 store_data_word(offset, M.x86.R_AX);
7237 DECODE_CLEAR_SEGOVR();
7241 /****************************************************************************
7244 ****************************************************************************/
7245 void x86emuOp_movs_byte(u8 X86EMU_UNUSED(op1))
7252 DECODE_PRINTF("MOVS\tBYTE\n");
7253 if (ACCESS_FLAG(F_DF)) /* down */
7259 if (M.x86.mode & (SYSMODE_PREFIX_REPE | SYSMODE_PREFIX_REPNE)) {
7260 /* dont care whether REPE or REPNE */
7261 /* move them until CX is ZERO. */
7264 M.x86.mode &= ~(SYSMODE_PREFIX_REPE | SYSMODE_PREFIX_REPNE);
7267 val = fetch_data_byte(M.x86.R_SI);
7268 store_data_byte_abs(M.x86.R_ES, M.x86.R_DI, val);
7272 DECODE_CLEAR_SEGOVR();
7276 /****************************************************************************
7279 ****************************************************************************/
7280 void x86emuOp_movs_word(u8 X86EMU_UNUSED(op1))
7287 if (M.x86.mode & SYSMODE_PREFIX_DATA) {
7288 DECODE_PRINTF("MOVS\tDWORD\n");
7289 if (ACCESS_FLAG(F_DF)) /* down */
7294 DECODE_PRINTF("MOVS\tWORD\n");
7295 if (ACCESS_FLAG(F_DF)) /* down */
7302 if (M.x86.mode & (SYSMODE_PREFIX_REPE | SYSMODE_PREFIX_REPNE)) {
7303 /* dont care whether REPE or REPNE */
7304 /* move them until CX is ZERO. */
7307 M.x86.mode &= ~(SYSMODE_PREFIX_REPE | SYSMODE_PREFIX_REPNE);
7310 if (M.x86.mode & SYSMODE_PREFIX_DATA) {
7311 val = fetch_data_long(M.x86.R_SI);
7312 store_data_long_abs(M.x86.R_ES, M.x86.R_DI, val);
7314 val = fetch_data_word(M.x86.R_SI);
7315 store_data_word_abs(M.x86.R_ES, M.x86.R_DI, (u16)val);
7320 DECODE_CLEAR_SEGOVR();
7324 /****************************************************************************
7327 ****************************************************************************/
7328 void x86emuOp_cmps_byte(u8 X86EMU_UNUSED(op1))
7334 DECODE_PRINTF("CMPS\tBYTE\n");
7336 if (ACCESS_FLAG(F_DF)) /* down */
7341 if (M.x86.mode & SYSMODE_PREFIX_REPE) {
7343 /* move them until CX is ZERO. */
7344 while (M.x86.R_CX != 0) {
7345 val1 = fetch_data_byte(M.x86.R_SI);
7346 val2 = fetch_data_byte_abs(M.x86.R_ES, M.x86.R_DI);
7347 cmp_byte(val1, val2);
7351 if (ACCESS_FLAG(F_ZF) == 0)
7354 M.x86.mode &= ~SYSMODE_PREFIX_REPE;
7355 } else if (M.x86.mode & SYSMODE_PREFIX_REPNE) {
7357 /* move them until CX is ZERO. */
7358 while (M.x86.R_CX != 0) {
7359 val1 = fetch_data_byte(M.x86.R_SI);
7360 val2 = fetch_data_byte_abs(M.x86.R_ES, M.x86.R_DI);
7361 cmp_byte(val1, val2);
7365 if (ACCESS_FLAG(F_ZF))
7366 break; /* zero flag set means equal */
7368 M.x86.mode &= ~SYSMODE_PREFIX_REPNE;
7370 val1 = fetch_data_byte(M.x86.R_SI);
7371 val2 = fetch_data_byte_abs(M.x86.R_ES, M.x86.R_DI);
7372 cmp_byte(val1, val2);
7376 DECODE_CLEAR_SEGOVR();
7380 /****************************************************************************
7383 ****************************************************************************/
7384 void x86emuOp_cmps_word(u8 X86EMU_UNUSED(op1))
7390 if (M.x86.mode & SYSMODE_PREFIX_DATA) {
7391 DECODE_PRINTF("CMPS\tDWORD\n");
7392 if (ACCESS_FLAG(F_DF)) /* down */
7397 DECODE_PRINTF("CMPS\tWORD\n");
7398 if (ACCESS_FLAG(F_DF)) /* down */
7404 if (M.x86.mode & SYSMODE_PREFIX_REPE) {
7406 /* move them until CX is ZERO. */
7407 while (M.x86.R_CX != 0) {
7408 if (M.x86.mode & SYSMODE_PREFIX_DATA) {
7409 val1 = fetch_data_long(M.x86.R_SI);
7410 val2 = fetch_data_long_abs(M.x86.R_ES, M.x86.R_DI);
7411 cmp_long(val1, val2);
7413 val1 = fetch_data_word(M.x86.R_SI);
7414 val2 = fetch_data_word_abs(M.x86.R_ES, M.x86.R_DI);
7415 cmp_word((u16)val1, (u16)val2);
7420 if (ACCESS_FLAG(F_ZF) == 0)
7423 M.x86.mode &= ~SYSMODE_PREFIX_REPE;
7424 } else if (M.x86.mode & SYSMODE_PREFIX_REPNE) {
7426 /* move them until CX is ZERO. */
7427 while (M.x86.R_CX != 0) {
7428 if (M.x86.mode & SYSMODE_PREFIX_DATA) {
7429 val1 = fetch_data_long(M.x86.R_SI);
7430 val2 = fetch_data_long_abs(M.x86.R_ES, M.x86.R_DI);
7431 cmp_long(val1, val2);
7433 val1 = fetch_data_word(M.x86.R_SI);
7434 val2 = fetch_data_word_abs(M.x86.R_ES, M.x86.R_DI);
7435 cmp_word((u16)val1, (u16)val2);
7440 if (ACCESS_FLAG(F_ZF))
7441 break; /* zero flag set means equal */
7443 M.x86.mode &= ~SYSMODE_PREFIX_REPNE;
7445 if (M.x86.mode & SYSMODE_PREFIX_DATA) {
7446 val1 = fetch_data_long(M.x86.R_SI);
7447 val2 = fetch_data_long_abs(M.x86.R_ES, M.x86.R_DI);
7448 cmp_long(val1, val2);
7450 val1 = fetch_data_word(M.x86.R_SI);
7451 val2 = fetch_data_word_abs(M.x86.R_ES, M.x86.R_DI);
7452 cmp_word((u16)val1, (u16)val2);
7457 DECODE_CLEAR_SEGOVR();
7461 /****************************************************************************
7464 ****************************************************************************/
7465 void x86emuOp_test_AL_IMM(u8 X86EMU_UNUSED(op1))
7470 DECODE_PRINTF("TEST\tAL,");
7471 imm = fetch_byte_imm();
7472 DECODE_PRINTF2("%04x\n", imm);
7474 test_byte(M.x86.R_AL, (u8)imm);
7475 DECODE_CLEAR_SEGOVR();
7479 /****************************************************************************
7482 ****************************************************************************/
7483 void x86emuOp_test_AX_IMM(u8 X86EMU_UNUSED(op1))
7488 if (M.x86.mode & SYSMODE_PREFIX_DATA) {
7489 DECODE_PRINTF("TEST\tEAX,");
7490 srcval = fetch_long_imm();
7492 DECODE_PRINTF("TEST\tAX,");
7493 srcval = fetch_word_imm();
7495 DECODE_PRINTF2("%x\n", srcval);
7497 if (M.x86.mode & SYSMODE_PREFIX_DATA) {
7498 test_long(M.x86.R_EAX, srcval);
7500 test_word(M.x86.R_AX, (u16)srcval);
7502 DECODE_CLEAR_SEGOVR();
7506 /****************************************************************************
7509 ****************************************************************************/
7510 void x86emuOp_stos_byte(u8 X86EMU_UNUSED(op1))
7515 DECODE_PRINTF("STOS\tBYTE\n");
7516 if (ACCESS_FLAG(F_DF)) /* down */
7521 if (M.x86.mode & (SYSMODE_PREFIX_REPE | SYSMODE_PREFIX_REPNE)) {
7522 /* dont care whether REPE or REPNE */
7523 /* move them until CX is ZERO. */
7524 while (M.x86.R_CX != 0) {
7525 store_data_byte_abs(M.x86.R_ES, M.x86.R_DI, M.x86.R_AL);
7529 M.x86.mode &= ~(SYSMODE_PREFIX_REPE | SYSMODE_PREFIX_REPNE);
7531 store_data_byte_abs(M.x86.R_ES, M.x86.R_DI, M.x86.R_AL);
7534 DECODE_CLEAR_SEGOVR();
7538 /****************************************************************************
7541 ****************************************************************************/
7542 void x86emuOp_stos_word(u8 X86EMU_UNUSED(op1))
7548 if (M.x86.mode & SYSMODE_PREFIX_DATA) {
7549 DECODE_PRINTF("STOS\tDWORD\n");
7550 if (ACCESS_FLAG(F_DF)) /* down */
7555 DECODE_PRINTF("STOS\tWORD\n");
7556 if (ACCESS_FLAG(F_DF)) /* down */
7563 if (M.x86.mode & (SYSMODE_PREFIX_REPE | SYSMODE_PREFIX_REPNE)) {
7564 /* dont care whether REPE or REPNE */
7565 /* move them until CX is ZERO. */
7568 M.x86.mode &= ~(SYSMODE_PREFIX_REPE | SYSMODE_PREFIX_REPNE);
7571 if (M.x86.mode & SYSMODE_PREFIX_DATA) {
7572 store_data_long_abs(M.x86.R_ES, M.x86.R_DI, M.x86.R_EAX);
7574 store_data_word_abs(M.x86.R_ES, M.x86.R_DI, M.x86.R_AX);
7578 DECODE_CLEAR_SEGOVR();
7582 /****************************************************************************
7585 ****************************************************************************/
7586 void x86emuOp_lods_byte(u8 X86EMU_UNUSED(op1))
7591 DECODE_PRINTF("LODS\tBYTE\n");
7593 if (ACCESS_FLAG(F_DF)) /* down */
7597 if (M.x86.mode & (SYSMODE_PREFIX_REPE | SYSMODE_PREFIX_REPNE)) {
7598 /* dont care whether REPE or REPNE */
7599 /* move them until CX is ZERO. */
7600 while (M.x86.R_CX != 0) {
7601 M.x86.R_AL = fetch_data_byte(M.x86.R_SI);
7605 M.x86.mode &= ~(SYSMODE_PREFIX_REPE | SYSMODE_PREFIX_REPNE);
7607 M.x86.R_AL = fetch_data_byte(M.x86.R_SI);
7610 DECODE_CLEAR_SEGOVR();
7614 /****************************************************************************
7617 ****************************************************************************/
7618 void x86emuOp_lods_word(u8 X86EMU_UNUSED(op1))
7624 if (M.x86.mode & SYSMODE_PREFIX_DATA) {
7625 DECODE_PRINTF("LODS\tDWORD\n");
7626 if (ACCESS_FLAG(F_DF)) /* down */
7631 DECODE_PRINTF("LODS\tWORD\n");
7632 if (ACCESS_FLAG(F_DF)) /* down */
7639 if (M.x86.mode & (SYSMODE_PREFIX_REPE | SYSMODE_PREFIX_REPNE)) {
7640 /* dont care whether REPE or REPNE */
7641 /* move them until CX is ZERO. */
7644 M.x86.mode &= ~(SYSMODE_PREFIX_REPE | SYSMODE_PREFIX_REPNE);
7647 if (M.x86.mode & SYSMODE_PREFIX_DATA) {
7648 M.x86.R_EAX = fetch_data_long(M.x86.R_SI);
7650 M.x86.R_AX = fetch_data_word(M.x86.R_SI);
7654 DECODE_CLEAR_SEGOVR();
7658 /****************************************************************************
7661 ****************************************************************************/
7662 void x86emuOp_scas_byte(u8 X86EMU_UNUSED(op1))
7668 DECODE_PRINTF("SCAS\tBYTE\n");
7670 if (ACCESS_FLAG(F_DF)) /* down */
7674 if (M.x86.mode & SYSMODE_PREFIX_REPE) {
7676 /* move them until CX is ZERO. */
7677 while (M.x86.R_CX != 0) {
7678 val2 = fetch_data_byte_abs(M.x86.R_ES, M.x86.R_DI);
7679 cmp_byte(M.x86.R_AL, val2);
7682 if (ACCESS_FLAG(F_ZF) == 0)
7685 M.x86.mode &= ~SYSMODE_PREFIX_REPE;
7686 } else if (M.x86.mode & SYSMODE_PREFIX_REPNE) {
7688 /* move them until CX is ZERO. */
7689 while (M.x86.R_CX != 0) {
7690 val2 = fetch_data_byte_abs(M.x86.R_ES, M.x86.R_DI);
7691 cmp_byte(M.x86.R_AL, val2);
7694 if (ACCESS_FLAG(F_ZF))
7695 break; /* zero flag set means equal */
7697 M.x86.mode &= ~SYSMODE_PREFIX_REPNE;
7699 val2 = fetch_data_byte_abs(M.x86.R_ES, M.x86.R_DI);
7700 cmp_byte(M.x86.R_AL, val2);
7703 DECODE_CLEAR_SEGOVR();
7707 /****************************************************************************
7710 ****************************************************************************/
7711 void x86emuOp_scas_word(u8 X86EMU_UNUSED(op1))
7717 if (M.x86.mode & SYSMODE_PREFIX_DATA) {
7718 DECODE_PRINTF("SCAS\tDWORD\n");
7719 if (ACCESS_FLAG(F_DF)) /* down */
7724 DECODE_PRINTF("SCAS\tWORD\n");
7725 if (ACCESS_FLAG(F_DF)) /* down */
7731 if (M.x86.mode & SYSMODE_PREFIX_REPE) {
7733 /* move them until CX is ZERO. */
7734 while (M.x86.R_CX != 0) {
7735 if (M.x86.mode & SYSMODE_PREFIX_DATA) {
7736 val = fetch_data_long_abs(M.x86.R_ES, M.x86.R_DI);
7737 cmp_long(M.x86.R_EAX, val);
7739 val = fetch_data_word_abs(M.x86.R_ES, M.x86.R_DI);
7740 cmp_word(M.x86.R_AX, (u16)val);
7744 if (ACCESS_FLAG(F_ZF) == 0)
7747 M.x86.mode &= ~SYSMODE_PREFIX_REPE;
7748 } else if (M.x86.mode & SYSMODE_PREFIX_REPNE) {
7750 /* move them until CX is ZERO. */
7751 while (M.x86.R_CX != 0) {
7752 if (M.x86.mode & SYSMODE_PREFIX_DATA) {
7753 val = fetch_data_long_abs(M.x86.R_ES, M.x86.R_DI);
7754 cmp_long(M.x86.R_EAX, val);
7756 val = fetch_data_word_abs(M.x86.R_ES, M.x86.R_DI);
7757 cmp_word(M.x86.R_AX, (u16)val);
7761 if (ACCESS_FLAG(F_ZF))
7762 break; /* zero flag set means equal */
7764 M.x86.mode &= ~SYSMODE_PREFIX_REPNE;
7766 if (M.x86.mode & SYSMODE_PREFIX_DATA) {
7767 val = fetch_data_long_abs(M.x86.R_ES, M.x86.R_DI);
7768 cmp_long(M.x86.R_EAX, val);
7770 val = fetch_data_word_abs(M.x86.R_ES, M.x86.R_DI);
7771 cmp_word(M.x86.R_AX, (u16)val);
7775 DECODE_CLEAR_SEGOVR();
7779 /****************************************************************************
7782 ****************************************************************************/
7783 void x86emuOp_mov_byte_AL_IMM(u8 X86EMU_UNUSED(op1))
7788 DECODE_PRINTF("MOV\tAL,");
7789 imm = fetch_byte_imm();
7790 DECODE_PRINTF2("%x\n", imm);
7793 DECODE_CLEAR_SEGOVR();
7797 /****************************************************************************
7800 ****************************************************************************/
7801 void x86emuOp_mov_byte_CL_IMM(u8 X86EMU_UNUSED(op1))
7806 DECODE_PRINTF("MOV\tCL,");
7807 imm = fetch_byte_imm();
7808 DECODE_PRINTF2("%x\n", imm);
7811 DECODE_CLEAR_SEGOVR();
7815 /****************************************************************************
7818 ****************************************************************************/
7819 void x86emuOp_mov_byte_DL_IMM(u8 X86EMU_UNUSED(op1))
7824 DECODE_PRINTF("MOV\tDL,");
7825 imm = fetch_byte_imm();
7826 DECODE_PRINTF2("%x\n", imm);
7829 DECODE_CLEAR_SEGOVR();
7833 /****************************************************************************
7836 ****************************************************************************/
7837 void x86emuOp_mov_byte_BL_IMM(u8 X86EMU_UNUSED(op1))
7842 DECODE_PRINTF("MOV\tBL,");
7843 imm = fetch_byte_imm();
7844 DECODE_PRINTF2("%x\n", imm);
7847 DECODE_CLEAR_SEGOVR();
7851 /****************************************************************************
7854 ****************************************************************************/
7855 void x86emuOp_mov_byte_AH_IMM(u8 X86EMU_UNUSED(op1))
7860 DECODE_PRINTF("MOV\tAH,");
7861 imm = fetch_byte_imm();
7862 DECODE_PRINTF2("%x\n", imm);
7865 DECODE_CLEAR_SEGOVR();
7869 /****************************************************************************
7872 ****************************************************************************/
7873 void x86emuOp_mov_byte_CH_IMM(u8 X86EMU_UNUSED(op1))
7878 DECODE_PRINTF("MOV\tCH,");
7879 imm = fetch_byte_imm();
7880 DECODE_PRINTF2("%x\n", imm);
7883 DECODE_CLEAR_SEGOVR();
7887 /****************************************************************************
7890 ****************************************************************************/
7891 void x86emuOp_mov_byte_DH_IMM(u8 X86EMU_UNUSED(op1))
7896 DECODE_PRINTF("MOV\tDH,");
7897 imm = fetch_byte_imm();
7898 DECODE_PRINTF2("%x\n", imm);
7901 DECODE_CLEAR_SEGOVR();
7905 /****************************************************************************
7908 ****************************************************************************/
7909 void x86emuOp_mov_byte_BH_IMM(u8 X86EMU_UNUSED(op1))
7914 DECODE_PRINTF("MOV\tBH,");
7915 imm = fetch_byte_imm();
7916 DECODE_PRINTF2("%x\n", imm);
7919 DECODE_CLEAR_SEGOVR();
7923 /****************************************************************************
7926 ****************************************************************************/
7927 void x86emuOp_mov_word_AX_IMM(u8 X86EMU_UNUSED(op1))
7932 if (M.x86.mode & SYSMODE_PREFIX_DATA) {
7933 DECODE_PRINTF("MOV\tEAX,");
7934 srcval = fetch_long_imm();
7936 DECODE_PRINTF("MOV\tAX,");
7937 srcval = fetch_word_imm();
7939 DECODE_PRINTF2("%x\n", srcval);
7941 if (M.x86.mode & SYSMODE_PREFIX_DATA) {
7942 M.x86.R_EAX = srcval;
7944 M.x86.R_AX = (u16)srcval;
7946 DECODE_CLEAR_SEGOVR();
7950 /****************************************************************************
7953 ****************************************************************************/
7954 void x86emuOp_mov_word_CX_IMM(u8 X86EMU_UNUSED(op1))
7959 if (M.x86.mode & SYSMODE_PREFIX_DATA) {
7960 DECODE_PRINTF("MOV\tECX,");
7961 srcval = fetch_long_imm();
7963 DECODE_PRINTF("MOV\tCX,");
7964 srcval = fetch_word_imm();
7966 DECODE_PRINTF2("%x\n", srcval);
7968 if (M.x86.mode & SYSMODE_PREFIX_DATA) {
7969 M.x86.R_ECX = srcval;
7971 M.x86.R_CX = (u16)srcval;
7973 DECODE_CLEAR_SEGOVR();
7977 /****************************************************************************
7980 ****************************************************************************/
7981 void x86emuOp_mov_word_DX_IMM(u8 X86EMU_UNUSED(op1))
7986 if (M.x86.mode & SYSMODE_PREFIX_DATA) {
7987 DECODE_PRINTF("MOV\tEDX,");
7988 srcval = fetch_long_imm();
7990 DECODE_PRINTF("MOV\tDX,");
7991 srcval = fetch_word_imm();
7993 DECODE_PRINTF2("%x\n", srcval);
7995 if (M.x86.mode & SYSMODE_PREFIX_DATA) {
7996 M.x86.R_EDX = srcval;
7998 M.x86.R_DX = (u16)srcval;
8000 DECODE_CLEAR_SEGOVR();
8004 /****************************************************************************
8007 ****************************************************************************/
8008 void x86emuOp_mov_word_BX_IMM(u8 X86EMU_UNUSED(op1))
8013 if (M.x86.mode & SYSMODE_PREFIX_DATA) {
8014 DECODE_PRINTF("MOV\tEBX,");
8015 srcval = fetch_long_imm();
8017 DECODE_PRINTF("MOV\tBX,");
8018 srcval = fetch_word_imm();
8020 DECODE_PRINTF2("%x\n", srcval);
8022 if (M.x86.mode & SYSMODE_PREFIX_DATA) {
8023 M.x86.R_EBX = srcval;
8025 M.x86.R_BX = (u16)srcval;
8027 DECODE_CLEAR_SEGOVR();
8031 /****************************************************************************
8034 ****************************************************************************/
8035 void x86emuOp_mov_word_SP_IMM(u8 X86EMU_UNUSED(op1))
8040 if (M.x86.mode & SYSMODE_PREFIX_DATA) {
8041 DECODE_PRINTF("MOV\tESP,");
8042 srcval = fetch_long_imm();
8044 DECODE_PRINTF("MOV\tSP,");
8045 srcval = fetch_word_imm();
8047 DECODE_PRINTF2("%x\n", srcval);
8049 if (M.x86.mode & SYSMODE_PREFIX_DATA) {
8050 M.x86.R_ESP = srcval;
8052 M.x86.R_SP = (u16)srcval;
8054 DECODE_CLEAR_SEGOVR();
8058 /****************************************************************************
8061 ****************************************************************************/
8062 void x86emuOp_mov_word_BP_IMM(u8 X86EMU_UNUSED(op1))
8067 if (M.x86.mode & SYSMODE_PREFIX_DATA) {
8068 DECODE_PRINTF("MOV\tEBP,");
8069 srcval = fetch_long_imm();
8071 DECODE_PRINTF("MOV\tBP,");
8072 srcval = fetch_word_imm();
8074 DECODE_PRINTF2("%x\n", srcval);
8076 if (M.x86.mode & SYSMODE_PREFIX_DATA) {
8077 M.x86.R_EBP = srcval;
8079 M.x86.R_BP = (u16)srcval;
8081 DECODE_CLEAR_SEGOVR();
8085 /****************************************************************************
8088 ****************************************************************************/
8089 void x86emuOp_mov_word_SI_IMM(u8 X86EMU_UNUSED(op1))
8094 if (M.x86.mode & SYSMODE_PREFIX_DATA) {
8095 DECODE_PRINTF("MOV\tESI,");
8096 srcval = fetch_long_imm();
8098 DECODE_PRINTF("MOV\tSI,");
8099 srcval = fetch_word_imm();
8101 DECODE_PRINTF2("%x\n", srcval);
8103 if (M.x86.mode & SYSMODE_PREFIX_DATA) {
8104 M.x86.R_ESI = srcval;
8106 M.x86.R_SI = (u16)srcval;
8108 DECODE_CLEAR_SEGOVR();
8112 /****************************************************************************
8115 ****************************************************************************/
8116 void x86emuOp_mov_word_DI_IMM(u8 X86EMU_UNUSED(op1))
8121 if (M.x86.mode & SYSMODE_PREFIX_DATA) {
8122 DECODE_PRINTF("MOV\tEDI,");
8123 srcval = fetch_long_imm();
8125 DECODE_PRINTF("MOV\tDI,");
8126 srcval = fetch_word_imm();
8128 DECODE_PRINTF2("%x\n", srcval);
8130 if (M.x86.mode & SYSMODE_PREFIX_DATA) {
8131 M.x86.R_EDI = srcval;
8133 M.x86.R_DI = (u16)srcval;
8135 DECODE_CLEAR_SEGOVR();
8139 /* used by opcodes c0, d0, and d2. */
8140 static u8(*opcD0_byte_operation[])(u8 d, u8 s) =
8148 shl_byte, /* sal_byte === shl_byte by definition */
8152 /****************************************************************************
8155 ****************************************************************************/
8156 void x86emuOp_opcC0_byte_RM_MEM(u8 X86EMU_UNUSED(op1))
8165 * Yet another weirdo special case instruction format. Part of
8166 * the opcode held below in "RH". Doubly nested case would
8167 * result, except that the decoded instruction
8170 FETCH_DECODE_MODRM(mod, rh, rl);
8172 if (DEBUG_DECODE()) {
8173 /* XXX DECODE_PRINTF may be changed to something more
8174 general, so that it is important to leave the strings
8175 in the same format, even though the result is that the
8176 above test is done twice. */
8180 DECODE_PRINTF("ROL\t");
8183 DECODE_PRINTF("ROR\t");
8186 DECODE_PRINTF("RCL\t");
8189 DECODE_PRINTF("RCR\t");
8192 DECODE_PRINTF("SHL\t");
8195 DECODE_PRINTF("SHR\t");
8198 DECODE_PRINTF("SAL\t");
8201 DECODE_PRINTF("SAR\t");
8206 /* know operation, decode the mod byte to find the addressing
8210 DECODE_PRINTF("BYTE PTR ");
8211 destoffset = decode_rm00_address(rl);
8212 amt = fetch_byte_imm();
8213 DECODE_PRINTF2(",%x\n", amt);
8214 destval = fetch_data_byte(destoffset);
8216 destval = (*opcD0_byte_operation[rh]) (destval, amt);
8217 store_data_byte(destoffset, destval);
8220 DECODE_PRINTF("BYTE PTR ");
8221 destoffset = decode_rm01_address(rl);
8222 amt = fetch_byte_imm();
8223 DECODE_PRINTF2(",%x\n", amt);
8224 destval = fetch_data_byte(destoffset);
8226 destval = (*opcD0_byte_operation[rh]) (destval, amt);
8227 store_data_byte(destoffset, destval);
8230 DECODE_PRINTF("BYTE PTR ");
8231 destoffset = decode_rm10_address(rl);
8232 amt = fetch_byte_imm();
8233 DECODE_PRINTF2(",%x\n", amt);
8234 destval = fetch_data_byte(destoffset);
8236 destval = (*opcD0_byte_operation[rh]) (destval, amt);
8237 store_data_byte(destoffset, destval);
8239 case 3: /* register to register */
8240 destreg = DECODE_RM_BYTE_REGISTER(rl);
8241 amt = fetch_byte_imm();
8242 DECODE_PRINTF2(",%x\n", amt);
8244 destval = (*opcD0_byte_operation[rh]) (*destreg, amt);
8248 DECODE_CLEAR_SEGOVR();
8252 /* used by opcodes c1, d1, and d3. */
8253 static u16(*opcD1_word_operation[])(u16 s, u8 d) =
8261 shl_word, /* sal_byte === shl_byte by definition */
8265 /* used by opcodes c1, d1, and d3. */
8266 static u32 (*opcD1_long_operation[])(u32 s, u8 d) =
8274 shl_long, /* sal_byte === shl_byte by definition */
8278 /****************************************************************************
8281 ****************************************************************************/
8282 void x86emuOp_opcC1_word_RM_MEM(u8 X86EMU_UNUSED(op1))
8289 * Yet another weirdo special case instruction format. Part of
8290 * the opcode held below in "RH". Doubly nested case would
8291 * result, except that the decoded instruction
8294 FETCH_DECODE_MODRM(mod, rh, rl);
8296 if (DEBUG_DECODE()) {
8297 /* XXX DECODE_PRINTF may be changed to something more
8298 general, so that it is important to leave the strings
8299 in the same format, even though the result is that the
8300 above test is done twice. */
8304 DECODE_PRINTF("ROL\t");
8307 DECODE_PRINTF("ROR\t");
8310 DECODE_PRINTF("RCL\t");
8313 DECODE_PRINTF("RCR\t");
8316 DECODE_PRINTF("SHL\t");
8319 DECODE_PRINTF("SHR\t");
8322 DECODE_PRINTF("SAL\t");
8325 DECODE_PRINTF("SAR\t");
8330 /* know operation, decode the mod byte to find the addressing
8334 if (M.x86.mode & SYSMODE_PREFIX_DATA) {
8337 DECODE_PRINTF("DWORD PTR ");
8338 destoffset = decode_rm00_address(rl);
8339 amt = fetch_byte_imm();
8340 DECODE_PRINTF2(",%x\n", amt);
8341 destval = fetch_data_long(destoffset);
8343 destval = (*opcD1_long_operation[rh]) (destval, amt);
8344 store_data_long(destoffset, destval);
8348 DECODE_PRINTF("WORD PTR ");
8349 destoffset = decode_rm00_address(rl);
8350 amt = fetch_byte_imm();
8351 DECODE_PRINTF2(",%x\n", amt);
8352 destval = fetch_data_word(destoffset);
8354 destval = (*opcD1_word_operation[rh]) (destval, amt);
8355 store_data_word(destoffset, destval);
8359 if (M.x86.mode & SYSMODE_PREFIX_DATA) {
8362 DECODE_PRINTF("DWORD PTR ");
8363 destoffset = decode_rm01_address(rl);
8364 amt = fetch_byte_imm();
8365 DECODE_PRINTF2(",%x\n", amt);
8366 destval = fetch_data_long(destoffset);
8368 destval = (*opcD1_long_operation[rh]) (destval, amt);
8369 store_data_long(destoffset, destval);
8373 DECODE_PRINTF("WORD PTR ");
8374 destoffset = decode_rm01_address(rl);
8375 amt = fetch_byte_imm();
8376 DECODE_PRINTF2(",%x\n", amt);
8377 destval = fetch_data_word(destoffset);
8379 destval = (*opcD1_word_operation[rh]) (destval, amt);
8380 store_data_word(destoffset, destval);
8384 if (M.x86.mode & SYSMODE_PREFIX_DATA) {
8387 DECODE_PRINTF("DWORD PTR ");
8388 destoffset = decode_rm10_address(rl);
8389 amt = fetch_byte_imm();
8390 DECODE_PRINTF2(",%x\n", amt);
8391 destval = fetch_data_long(destoffset);
8393 destval = (*opcD1_long_operation[rh]) (destval, amt);
8394 store_data_long(destoffset, destval);
8398 DECODE_PRINTF("WORD PTR ");
8399 destoffset = decode_rm10_address(rl);
8400 amt = fetch_byte_imm();
8401 DECODE_PRINTF2(",%x\n", amt);
8402 destval = fetch_data_word(destoffset);
8404 destval = (*opcD1_word_operation[rh]) (destval, amt);
8405 store_data_word(destoffset, destval);
8408 case 3: /* register to register */
8409 if (M.x86.mode & SYSMODE_PREFIX_DATA) {
8412 destreg = DECODE_RM_LONG_REGISTER(rl);
8413 amt = fetch_byte_imm();
8414 DECODE_PRINTF2(",%x\n", amt);
8416 *destreg = (*opcD1_long_operation[rh]) (*destreg, amt);
8420 destreg = DECODE_RM_WORD_REGISTER(rl);
8421 amt = fetch_byte_imm();
8422 DECODE_PRINTF2(",%x\n", amt);
8424 *destreg = (*opcD1_word_operation[rh]) (*destreg, amt);
8428 DECODE_CLEAR_SEGOVR();
8432 /****************************************************************************
8435 ****************************************************************************/
8436 void x86emuOp_ret_near_IMM(u8 X86EMU_UNUSED(op1))
8441 DECODE_PRINTF("RET\t");
8442 imm = fetch_word_imm();
8443 DECODE_PRINTF2("%x\n", imm);
8444 RETURN_TRACE("RET",M.x86.saved_cs,M.x86.saved_ip);
8446 M.x86.R_IP = pop_word();
8448 DECODE_CLEAR_SEGOVR();
8452 /****************************************************************************
8455 ****************************************************************************/
8456 void x86emuOp_ret_near(u8 X86EMU_UNUSED(op1))
8459 DECODE_PRINTF("RET\n");
8460 RETURN_TRACE("RET",M.x86.saved_cs,M.x86.saved_ip);
8462 M.x86.R_IP = pop_word();
8463 DECODE_CLEAR_SEGOVR();
8467 /****************************************************************************
8470 ****************************************************************************/
8471 void x86emuOp_les_R_IMM(u8 X86EMU_UNUSED(op1))
8478 DECODE_PRINTF("LES\t");
8479 FETCH_DECODE_MODRM(mod, rh, rl);
8482 dstreg = DECODE_RM_WORD_REGISTER(rh);
8484 srcoffset = decode_rm00_address(rl);
8485 DECODE_PRINTF("\n");
8487 *dstreg = fetch_data_word(srcoffset);
8488 M.x86.R_ES = fetch_data_word(srcoffset + 2);
8491 dstreg = DECODE_RM_WORD_REGISTER(rh);
8493 srcoffset = decode_rm01_address(rl);
8494 DECODE_PRINTF("\n");
8496 *dstreg = fetch_data_word(srcoffset);
8497 M.x86.R_ES = fetch_data_word(srcoffset + 2);
8500 dstreg = DECODE_RM_WORD_REGISTER(rh);
8502 srcoffset = decode_rm10_address(rl);
8503 DECODE_PRINTF("\n");
8505 *dstreg = fetch_data_word(srcoffset);
8506 M.x86.R_ES = fetch_data_word(srcoffset + 2);
8508 case 3: /* register to register */
8512 DECODE_CLEAR_SEGOVR();
8516 /****************************************************************************
8519 ****************************************************************************/
8520 void x86emuOp_lds_R_IMM(u8 X86EMU_UNUSED(op1))
8527 DECODE_PRINTF("LDS\t");
8528 FETCH_DECODE_MODRM(mod, rh, rl);
8531 dstreg = DECODE_RM_WORD_REGISTER(rh);
8533 srcoffset = decode_rm00_address(rl);
8534 DECODE_PRINTF("\n");
8536 *dstreg = fetch_data_word(srcoffset);
8537 M.x86.R_DS = fetch_data_word(srcoffset + 2);
8540 dstreg = DECODE_RM_WORD_REGISTER(rh);
8542 srcoffset = decode_rm01_address(rl);
8543 DECODE_PRINTF("\n");
8545 *dstreg = fetch_data_word(srcoffset);
8546 M.x86.R_DS = fetch_data_word(srcoffset + 2);
8549 dstreg = DECODE_RM_WORD_REGISTER(rh);
8551 srcoffset = decode_rm10_address(rl);
8552 DECODE_PRINTF("\n");
8554 *dstreg = fetch_data_word(srcoffset);
8555 M.x86.R_DS = fetch_data_word(srcoffset + 2);
8557 case 3: /* register to register */
8561 DECODE_CLEAR_SEGOVR();
8565 /****************************************************************************
8568 ****************************************************************************/
8569 void x86emuOp_mov_byte_RM_IMM(u8 X86EMU_UNUSED(op1))
8577 DECODE_PRINTF("MOV\t");
8578 FETCH_DECODE_MODRM(mod, rh, rl);
8580 DECODE_PRINTF("ILLEGAL DECODE OF OPCODE c6\n");
8585 DECODE_PRINTF("BYTE PTR ");
8586 destoffset = decode_rm00_address(rl);
8587 imm = fetch_byte_imm();
8588 DECODE_PRINTF2(",%2x\n", imm);
8590 store_data_byte(destoffset, imm);
8593 DECODE_PRINTF("BYTE PTR ");
8594 destoffset = decode_rm01_address(rl);
8595 imm = fetch_byte_imm();
8596 DECODE_PRINTF2(",%2x\n", imm);
8598 store_data_byte(destoffset, imm);
8601 DECODE_PRINTF("BYTE PTR ");
8602 destoffset = decode_rm10_address(rl);
8603 imm = fetch_byte_imm();
8604 DECODE_PRINTF2(",%2x\n", imm);
8606 store_data_byte(destoffset, imm);
8608 case 3: /* register to register */
8609 destreg = DECODE_RM_BYTE_REGISTER(rl);
8610 imm = fetch_byte_imm();
8611 DECODE_PRINTF2(",%2x\n", imm);
8616 DECODE_CLEAR_SEGOVR();
8620 /****************************************************************************
8623 ****************************************************************************/
8624 void x86emuOp_mov_word_RM_IMM(u8 X86EMU_UNUSED(op1))
8630 DECODE_PRINTF("MOV\t");
8631 FETCH_DECODE_MODRM(mod, rh, rl);
8633 DECODE_PRINTF("ILLEGAL DECODE OF OPCODE 8F\n");
8638 if (M.x86.mode & SYSMODE_PREFIX_DATA) {
8641 DECODE_PRINTF("DWORD PTR ");
8642 destoffset = decode_rm00_address(rl);
8643 imm = fetch_long_imm();
8644 DECODE_PRINTF2(",%x\n", imm);
8646 store_data_long(destoffset, imm);
8650 DECODE_PRINTF("WORD PTR ");
8651 destoffset = decode_rm00_address(rl);
8652 imm = fetch_word_imm();
8653 DECODE_PRINTF2(",%x\n", imm);
8655 store_data_word(destoffset, imm);
8659 if (M.x86.mode & SYSMODE_PREFIX_DATA) {
8662 DECODE_PRINTF("DWORD PTR ");
8663 destoffset = decode_rm01_address(rl);
8664 imm = fetch_long_imm();
8665 DECODE_PRINTF2(",%x\n", imm);
8667 store_data_long(destoffset, imm);
8671 DECODE_PRINTF("WORD PTR ");
8672 destoffset = decode_rm01_address(rl);
8673 imm = fetch_word_imm();
8674 DECODE_PRINTF2(",%x\n", imm);
8676 store_data_word(destoffset, imm);
8680 if (M.x86.mode & SYSMODE_PREFIX_DATA) {
8683 DECODE_PRINTF("DWORD PTR ");
8684 destoffset = decode_rm10_address(rl);
8685 imm = fetch_long_imm();
8686 DECODE_PRINTF2(",%x\n", imm);
8688 store_data_long(destoffset, imm);
8692 DECODE_PRINTF("WORD PTR ");
8693 destoffset = decode_rm10_address(rl);
8694 imm = fetch_word_imm();
8695 DECODE_PRINTF2(",%x\n", imm);
8697 store_data_word(destoffset, imm);
8700 case 3: /* register to register */
8701 if (M.x86.mode & SYSMODE_PREFIX_DATA) {
8705 destreg = DECODE_RM_LONG_REGISTER(rl);
8706 imm = fetch_long_imm();
8707 DECODE_PRINTF2(",%x\n", imm);
8714 destreg = DECODE_RM_WORD_REGISTER(rl);
8715 imm = fetch_word_imm();
8716 DECODE_PRINTF2(",%x\n", imm);
8722 DECODE_CLEAR_SEGOVR();
8726 /****************************************************************************
8729 ****************************************************************************/
8730 void x86emuOp_enter(u8 X86EMU_UNUSED(op1))
8732 u16 local,frame_pointer;
8737 local = fetch_word_imm();
8738 nesting = fetch_byte_imm();
8739 DECODE_PRINTF2("ENTER %x\n", local);
8740 DECODE_PRINTF2(",%x\n", nesting);
8742 push_word(M.x86.R_BP);
8743 frame_pointer = M.x86.R_SP;
8745 for (i = 1; i < nesting; i++) {
8747 push_word(fetch_data_word_abs(M.x86.R_SS, M.x86.R_BP));
8749 push_word(frame_pointer);
8751 M.x86.R_BP = frame_pointer;
8752 M.x86.R_SP = (u16)(M.x86.R_SP - local);
8753 DECODE_CLEAR_SEGOVR();
8757 /****************************************************************************
8760 ****************************************************************************/
8761 void x86emuOp_leave(u8 X86EMU_UNUSED(op1))
8764 DECODE_PRINTF("LEAVE\n");
8766 M.x86.R_SP = M.x86.R_BP;
8767 M.x86.R_BP = pop_word();
8768 DECODE_CLEAR_SEGOVR();
8772 /****************************************************************************
8775 ****************************************************************************/
8776 void x86emuOp_ret_far_IMM(u8 X86EMU_UNUSED(op1))
8781 DECODE_PRINTF("RETF\t");
8782 imm = fetch_word_imm();
8783 DECODE_PRINTF2("%x\n", imm);
8784 RETURN_TRACE("RETF",M.x86.saved_cs,M.x86.saved_ip);
8786 M.x86.R_IP = pop_word();
8787 M.x86.R_CS = pop_word();
8789 DECODE_CLEAR_SEGOVR();
8793 /****************************************************************************
8796 ****************************************************************************/
8797 void x86emuOp_ret_far(u8 X86EMU_UNUSED(op1))
8800 DECODE_PRINTF("RETF\n");
8801 RETURN_TRACE("RETF",M.x86.saved_cs,M.x86.saved_ip);
8803 M.x86.R_IP = pop_word();
8804 M.x86.R_CS = pop_word();
8805 DECODE_CLEAR_SEGOVR();
8809 /****************************************************************************
8812 ****************************************************************************/
8813 void x86emuOp_int3(u8 X86EMU_UNUSED(op1))
8818 DECODE_PRINTF("INT 3\n");
8819 tmp = (u16) mem_access_word(3 * 4 + 2);
8820 /* access the segment register */
8822 if (_X86EMU_intrTab[3]) {
8823 (*_X86EMU_intrTab[3])(3);
8825 push_word((u16)M.x86.R_FLG);
8828 push_word(M.x86.R_CS);
8829 M.x86.R_CS = mem_access_word(3 * 4 + 2);
8830 push_word(M.x86.R_IP);
8831 M.x86.R_IP = mem_access_word(3 * 4);
8833 DECODE_CLEAR_SEGOVR();
8837 /****************************************************************************
8840 ****************************************************************************/
8841 void x86emuOp_int_IMM(u8 X86EMU_UNUSED(op1))
8847 DECODE_PRINTF("INT\t");
8848 intnum = fetch_byte_imm();
8849 DECODE_PRINTF2("%x\n", intnum);
8850 tmp = mem_access_word(intnum * 4 + 2);
8852 if (_X86EMU_intrTab[intnum]) {
8853 (*_X86EMU_intrTab[intnum])(intnum);
8855 push_word((u16)M.x86.R_FLG);
8858 push_word(M.x86.R_CS);
8859 M.x86.R_CS = mem_access_word(intnum * 4 + 2);
8860 push_word(M.x86.R_IP);
8861 M.x86.R_IP = mem_access_word(intnum * 4);
8863 DECODE_CLEAR_SEGOVR();
8867 /****************************************************************************
8870 ****************************************************************************/
8871 void x86emuOp_into(u8 X86EMU_UNUSED(op1))
8876 DECODE_PRINTF("INTO\n");
8878 if (ACCESS_FLAG(F_OF)) {
8879 tmp = mem_access_word(4 * 4 + 2);
8880 if (_X86EMU_intrTab[4]) {
8881 (*_X86EMU_intrTab[4])(4);
8883 push_word((u16)M.x86.R_FLG);
8886 push_word(M.x86.R_CS);
8887 M.x86.R_CS = mem_access_word(4 * 4 + 2);
8888 push_word(M.x86.R_IP);
8889 M.x86.R_IP = mem_access_word(4 * 4);
8892 DECODE_CLEAR_SEGOVR();
8896 /****************************************************************************
8899 ****************************************************************************/
8900 void x86emuOp_iret(u8 X86EMU_UNUSED(op1))
8903 DECODE_PRINTF("IRET\n");
8907 M.x86.R_IP = pop_word();
8908 M.x86.R_CS = pop_word();
8909 M.x86.R_FLG = pop_word();
8910 DECODE_CLEAR_SEGOVR();
8914 /****************************************************************************
8917 ****************************************************************************/
8918 void x86emuOp_opcD0_byte_RM_1(u8 X86EMU_UNUSED(op1))
8926 * Yet another weirdo special case instruction format. Part of
8927 * the opcode held below in "RH". Doubly nested case would
8928 * result, except that the decoded instruction
8931 FETCH_DECODE_MODRM(mod, rh, rl);
8933 if (DEBUG_DECODE()) {
8934 /* XXX DECODE_PRINTF may be changed to something more
8935 general, so that it is important to leave the strings
8936 in the same format, even though the result is that the
8937 above test is done twice. */
8940 DECODE_PRINTF("ROL\t");
8943 DECODE_PRINTF("ROR\t");
8946 DECODE_PRINTF("RCL\t");
8949 DECODE_PRINTF("RCR\t");
8952 DECODE_PRINTF("SHL\t");
8955 DECODE_PRINTF("SHR\t");
8958 DECODE_PRINTF("SAL\t");
8961 DECODE_PRINTF("SAR\t");
8966 /* know operation, decode the mod byte to find the addressing
8970 DECODE_PRINTF("BYTE PTR ");
8971 destoffset = decode_rm00_address(rl);
8972 DECODE_PRINTF(",1\n");
8973 destval = fetch_data_byte(destoffset);
8975 destval = (*opcD0_byte_operation[rh]) (destval, 1);
8976 store_data_byte(destoffset, destval);
8979 DECODE_PRINTF("BYTE PTR ");
8980 destoffset = decode_rm01_address(rl);
8981 DECODE_PRINTF(",1\n");
8982 destval = fetch_data_byte(destoffset);
8984 destval = (*opcD0_byte_operation[rh]) (destval, 1);
8985 store_data_byte(destoffset, destval);
8988 DECODE_PRINTF("BYTE PTR ");
8989 destoffset = decode_rm10_address(rl);
8990 DECODE_PRINTF(",1\n");
8991 destval = fetch_data_byte(destoffset);
8993 destval = (*opcD0_byte_operation[rh]) (destval, 1);
8994 store_data_byte(destoffset, destval);
8996 case 3: /* register to register */
8997 destreg = DECODE_RM_BYTE_REGISTER(rl);
8998 DECODE_PRINTF(",1\n");
9000 destval = (*opcD0_byte_operation[rh]) (*destreg, 1);
9004 DECODE_CLEAR_SEGOVR();
9008 /****************************************************************************
9011 ****************************************************************************/
9012 void x86emuOp_opcD1_word_RM_1(u8 X86EMU_UNUSED(op1))
9018 * Yet another weirdo special case instruction format. Part of
9019 * the opcode held below in "RH". Doubly nested case would
9020 * result, except that the decoded instruction
9023 FETCH_DECODE_MODRM(mod, rh, rl);
9025 if (DEBUG_DECODE()) {
9026 /* XXX DECODE_PRINTF may be changed to something more
9027 general, so that it is important to leave the strings
9028 in the same format, even though the result is that the
9029 above test is done twice. */
9032 DECODE_PRINTF("ROL\t");
9035 DECODE_PRINTF("ROR\t");
9038 DECODE_PRINTF("RCL\t");
9041 DECODE_PRINTF("RCR\t");
9044 DECODE_PRINTF("SHL\t");
9047 DECODE_PRINTF("SHR\t");
9050 DECODE_PRINTF("SAL\t");
9053 DECODE_PRINTF("SAR\t");
9058 /* know operation, decode the mod byte to find the addressing
9062 if (M.x86.mode & SYSMODE_PREFIX_DATA) {
9065 DECODE_PRINTF("DWORD PTR ");
9066 destoffset = decode_rm00_address(rl);
9067 DECODE_PRINTF(",1\n");
9068 destval = fetch_data_long(destoffset);
9070 destval = (*opcD1_long_operation[rh]) (destval, 1);
9071 store_data_long(destoffset, destval);
9075 DECODE_PRINTF("WORD PTR ");
9076 destoffset = decode_rm00_address(rl);
9077 DECODE_PRINTF(",1\n");
9078 destval = fetch_data_word(destoffset);
9080 destval = (*opcD1_word_operation[rh]) (destval, 1);
9081 store_data_word(destoffset, destval);
9085 if (M.x86.mode & SYSMODE_PREFIX_DATA) {
9088 DECODE_PRINTF("DWORD PTR ");
9089 destoffset = decode_rm01_address(rl);
9090 DECODE_PRINTF(",1\n");
9091 destval = fetch_data_long(destoffset);
9093 destval = (*opcD1_long_operation[rh]) (destval, 1);
9094 store_data_long(destoffset, destval);
9098 DECODE_PRINTF("WORD PTR ");
9099 destoffset = decode_rm01_address(rl);
9100 DECODE_PRINTF(",1\n");
9101 destval = fetch_data_word(destoffset);
9103 destval = (*opcD1_word_operation[rh]) (destval, 1);
9104 store_data_word(destoffset, destval);
9108 if (M.x86.mode & SYSMODE_PREFIX_DATA) {
9111 DECODE_PRINTF("DWORD PTR ");
9112 destoffset = decode_rm10_address(rl);
9113 DECODE_PRINTF(",1\n");
9114 destval = fetch_data_long(destoffset);
9116 destval = (*opcD1_long_operation[rh]) (destval, 1);
9117 store_data_long(destoffset, destval);
9121 DECODE_PRINTF("BYTE PTR ");
9122 destoffset = decode_rm10_address(rl);
9123 DECODE_PRINTF(",1\n");
9124 destval = fetch_data_word(destoffset);
9126 destval = (*opcD1_word_operation[rh]) (destval, 1);
9127 store_data_word(destoffset, destval);
9130 case 3: /* register to register */
9131 if (M.x86.mode & SYSMODE_PREFIX_DATA) {
9135 destreg = DECODE_RM_LONG_REGISTER(rl);
9136 DECODE_PRINTF(",1\n");
9138 destval = (*opcD1_long_operation[rh]) (*destreg, 1);
9144 destreg = DECODE_RM_WORD_REGISTER(rl);
9145 DECODE_PRINTF(",1\n");
9147 destval = (*opcD1_word_operation[rh]) (*destreg, 1);
9152 DECODE_CLEAR_SEGOVR();
9156 /****************************************************************************
9159 ****************************************************************************/
9160 void x86emuOp_opcD2_byte_RM_CL(u8 X86EMU_UNUSED(op1))
9169 * Yet another weirdo special case instruction format. Part of
9170 * the opcode held below in "RH". Doubly nested case would
9171 * result, except that the decoded instruction
9174 FETCH_DECODE_MODRM(mod, rh, rl);
9176 if (DEBUG_DECODE()) {
9177 /* XXX DECODE_PRINTF may be changed to something more
9178 general, so that it is important to leave the strings
9179 in the same format, even though the result is that the
9180 above test is done twice. */
9183 DECODE_PRINTF("ROL\t");
9186 DECODE_PRINTF("ROR\t");
9189 DECODE_PRINTF("RCL\t");
9192 DECODE_PRINTF("RCR\t");
9195 DECODE_PRINTF("SHL\t");
9198 DECODE_PRINTF("SHR\t");
9201 DECODE_PRINTF("SAL\t");
9204 DECODE_PRINTF("SAR\t");
9209 /* know operation, decode the mod byte to find the addressing
9214 DECODE_PRINTF("BYTE PTR ");
9215 destoffset = decode_rm00_address(rl);
9216 DECODE_PRINTF(",CL\n");
9217 destval = fetch_data_byte(destoffset);
9219 destval = (*opcD0_byte_operation[rh]) (destval, amt);
9220 store_data_byte(destoffset, destval);
9223 DECODE_PRINTF("BYTE PTR ");
9224 destoffset = decode_rm01_address(rl);
9225 DECODE_PRINTF(",CL\n");
9226 destval = fetch_data_byte(destoffset);
9228 destval = (*opcD0_byte_operation[rh]) (destval, amt);
9229 store_data_byte(destoffset, destval);
9232 DECODE_PRINTF("BYTE PTR ");
9233 destoffset = decode_rm10_address(rl);
9234 DECODE_PRINTF(",CL\n");
9235 destval = fetch_data_byte(destoffset);
9237 destval = (*opcD0_byte_operation[rh]) (destval, amt);
9238 store_data_byte(destoffset, destval);
9240 case 3: /* register to register */
9241 destreg = DECODE_RM_BYTE_REGISTER(rl);
9242 DECODE_PRINTF(",CL\n");
9244 destval = (*opcD0_byte_operation[rh]) (*destreg, amt);
9248 DECODE_CLEAR_SEGOVR();
9252 /****************************************************************************
9255 ****************************************************************************/
9256 void x86emuOp_opcD3_word_RM_CL(u8 X86EMU_UNUSED(op1))
9263 * Yet another weirdo special case instruction format. Part of
9264 * the opcode held below in "RH". Doubly nested case would
9265 * result, except that the decoded instruction
9268 FETCH_DECODE_MODRM(mod, rh, rl);
9270 if (DEBUG_DECODE()) {
9271 /* XXX DECODE_PRINTF may be changed to something more
9272 general, so that it is important to leave the strings
9273 in the same format, even though the result is that the
9274 above test is done twice. */
9277 DECODE_PRINTF("ROL\t");
9280 DECODE_PRINTF("ROR\t");
9283 DECODE_PRINTF("RCL\t");
9286 DECODE_PRINTF("RCR\t");
9289 DECODE_PRINTF("SHL\t");
9292 DECODE_PRINTF("SHR\t");
9295 DECODE_PRINTF("SAL\t");
9298 DECODE_PRINTF("SAR\t");
9303 /* know operation, decode the mod byte to find the addressing
9308 if (M.x86.mode & SYSMODE_PREFIX_DATA) {
9311 DECODE_PRINTF("DWORD PTR ");
9312 destoffset = decode_rm00_address(rl);
9313 DECODE_PRINTF(",CL\n");
9314 destval = fetch_data_long(destoffset);
9316 destval = (*opcD1_long_operation[rh]) (destval, amt);
9317 store_data_long(destoffset, destval);
9321 DECODE_PRINTF("WORD PTR ");
9322 destoffset = decode_rm00_address(rl);
9323 DECODE_PRINTF(",CL\n");
9324 destval = fetch_data_word(destoffset);
9326 destval = (*opcD1_word_operation[rh]) (destval, amt);
9327 store_data_word(destoffset, destval);
9331 if (M.x86.mode & SYSMODE_PREFIX_DATA) {
9334 DECODE_PRINTF("DWORD PTR ");
9335 destoffset = decode_rm01_address(rl);
9336 DECODE_PRINTF(",CL\n");
9337 destval = fetch_data_long(destoffset);
9339 destval = (*opcD1_long_operation[rh]) (destval, amt);
9340 store_data_long(destoffset, destval);
9344 DECODE_PRINTF("WORD PTR ");
9345 destoffset = decode_rm01_address(rl);
9346 DECODE_PRINTF(",CL\n");
9347 destval = fetch_data_word(destoffset);
9349 destval = (*opcD1_word_operation[rh]) (destval, amt);
9350 store_data_word(destoffset, destval);
9354 if (M.x86.mode & SYSMODE_PREFIX_DATA) {
9357 DECODE_PRINTF("DWORD PTR ");
9358 destoffset = decode_rm10_address(rl);
9359 DECODE_PRINTF(",CL\n");
9360 destval = fetch_data_long(destoffset);
9362 destval = (*opcD1_long_operation[rh]) (destval, amt);
9363 store_data_long(destoffset, destval);
9367 DECODE_PRINTF("WORD PTR ");
9368 destoffset = decode_rm10_address(rl);
9369 DECODE_PRINTF(",CL\n");
9370 destval = fetch_data_word(destoffset);
9372 destval = (*opcD1_word_operation[rh]) (destval, amt);
9373 store_data_word(destoffset, destval);
9376 case 3: /* register to register */
9377 if (M.x86.mode & SYSMODE_PREFIX_DATA) {
9380 destreg = DECODE_RM_LONG_REGISTER(rl);
9381 DECODE_PRINTF(",CL\n");
9383 *destreg = (*opcD1_long_operation[rh]) (*destreg, amt);
9387 destreg = DECODE_RM_WORD_REGISTER(rl);
9388 DECODE_PRINTF(",CL\n");
9390 *destreg = (*opcD1_word_operation[rh]) (*destreg, amt);
9394 DECODE_CLEAR_SEGOVR();
9398 /****************************************************************************
9401 ****************************************************************************/
9402 void x86emuOp_aam(u8 X86EMU_UNUSED(op1))
9407 DECODE_PRINTF("AAM\n");
9408 a = fetch_byte_imm(); /* this is a stupid encoding. */
9410 DECODE_PRINTF("ERROR DECODING AAM\n");
9415 /* note the type change here --- returning AL and AH in AX. */
9416 M.x86.R_AX = aam_word(M.x86.R_AL);
9417 DECODE_CLEAR_SEGOVR();
9421 /****************************************************************************
9424 ****************************************************************************/
9425 void x86emuOp_aad(u8 X86EMU_UNUSED(op1))
9430 DECODE_PRINTF("AAD\n");
9431 a = fetch_byte_imm();
9433 M.x86.R_AX = aad_word(M.x86.R_AX);
9434 DECODE_CLEAR_SEGOVR();
9438 /* opcode 0xd6 ILLEGAL OPCODE */
9440 /****************************************************************************
9443 ****************************************************************************/
9444 void x86emuOp_xlat(u8 X86EMU_UNUSED(op1))
9449 DECODE_PRINTF("XLAT\n");
9451 addr = (u16)(M.x86.R_BX + (u8)M.x86.R_AL);
9452 M.x86.R_AL = fetch_data_byte(addr);
9453 DECODE_CLEAR_SEGOVR();
9457 /* instuctions D8 .. DF are in i87_ops.c */
9459 /****************************************************************************
9462 ****************************************************************************/
9463 void x86emuOp_loopne(u8 X86EMU_UNUSED(op1))
9468 DECODE_PRINTF("LOOPNE\t");
9469 ip = (s8) fetch_byte_imm();
9470 ip += (s16) M.x86.R_IP;
9471 DECODE_PRINTF2("%04x\n", ip);
9474 if (M.x86.R_CX != 0 && !ACCESS_FLAG(F_ZF)) /* CX != 0 and !ZF */
9476 DECODE_CLEAR_SEGOVR();
9480 /****************************************************************************
9483 ****************************************************************************/
9484 void x86emuOp_loope(u8 X86EMU_UNUSED(op1))
9489 DECODE_PRINTF("LOOPE\t");
9490 ip = (s8) fetch_byte_imm();
9491 ip += (s16) M.x86.R_IP;
9492 DECODE_PRINTF2("%04x\n", ip);
9495 if (M.x86.R_CX != 0 && ACCESS_FLAG(F_ZF)) /* CX != 0 and ZF */
9497 DECODE_CLEAR_SEGOVR();
9501 /****************************************************************************
9504 ****************************************************************************/
9505 void x86emuOp_loop(u8 X86EMU_UNUSED(op1))
9510 DECODE_PRINTF("LOOP\t");
9511 ip = (s8) fetch_byte_imm();
9512 ip += (s16) M.x86.R_IP;
9513 DECODE_PRINTF2("%04x\n", ip);
9516 if (M.x86.R_CX != 0)
9518 DECODE_CLEAR_SEGOVR();
9522 /****************************************************************************
9525 ****************************************************************************/
9526 void x86emuOp_jcxz(u8 X86EMU_UNUSED(op1))
9531 /* jump to byte offset if overflow flag is set */
9533 DECODE_PRINTF("JCXZ\t");
9534 offset = (s8)fetch_byte_imm();
9535 target = (u16)(M.x86.R_IP + offset);
9536 DECODE_PRINTF2("%x\n", target);
9538 if (M.x86.R_CX == 0)
9539 M.x86.R_IP = target;
9540 DECODE_CLEAR_SEGOVR();
9544 /****************************************************************************
9547 ****************************************************************************/
9548 void x86emuOp_in_byte_AL_IMM(u8 X86EMU_UNUSED(op1))
9553 DECODE_PRINTF("IN\t");
9554 port = (u8) fetch_byte_imm();
9555 DECODE_PRINTF2("%x,AL\n", port);
9557 M.x86.R_AL = (*sys_inb)(port);
9558 DECODE_CLEAR_SEGOVR();
9562 /****************************************************************************
9565 ****************************************************************************/
9566 void x86emuOp_in_word_AX_IMM(u8 X86EMU_UNUSED(op1))
9571 DECODE_PRINTF("IN\t");
9572 port = (u8) fetch_byte_imm();
9573 if (M.x86.mode & SYSMODE_PREFIX_DATA) {
9574 DECODE_PRINTF2("EAX,%x\n", port);
9576 DECODE_PRINTF2("AX,%x\n", port);
9579 if (M.x86.mode & SYSMODE_PREFIX_DATA) {
9580 M.x86.R_EAX = (*sys_inl)(port);
9582 M.x86.R_AX = (*sys_inw)(port);
9584 DECODE_CLEAR_SEGOVR();
9588 /****************************************************************************
9591 ****************************************************************************/
9592 void x86emuOp_out_byte_IMM_AL(u8 X86EMU_UNUSED(op1))
9597 DECODE_PRINTF("OUT\t");
9598 port = (u8) fetch_byte_imm();
9599 DECODE_PRINTF2("%x,AL\n", port);
9601 (*sys_outb)(port, M.x86.R_AL);
9602 DECODE_CLEAR_SEGOVR();
9606 /****************************************************************************
9609 ****************************************************************************/
9610 void x86emuOp_out_word_IMM_AX(u8 X86EMU_UNUSED(op1))
9615 DECODE_PRINTF("OUT\t");
9616 port = (u8) fetch_byte_imm();
9617 if (M.x86.mode & SYSMODE_PREFIX_DATA) {
9618 DECODE_PRINTF2("%x,EAX\n", port);
9620 DECODE_PRINTF2("%x,AX\n", port);
9623 if (M.x86.mode & SYSMODE_PREFIX_DATA) {
9624 (*sys_outl)(port, M.x86.R_EAX);
9626 (*sys_outw)(port, M.x86.R_AX);
9628 DECODE_CLEAR_SEGOVR();
9632 /****************************************************************************
9635 ****************************************************************************/
9636 void x86emuOp_call_near_IMM(u8 X86EMU_UNUSED(op1))
9641 DECODE_PRINTF("CALL\t");
9642 ip = (s16) fetch_word_imm();
9643 ip += (s16) M.x86.R_IP; /* CHECK SIGN */
9644 DECODE_PRINTF2("%04x\n", ip);
9645 CALL_TRACE(M.x86.saved_cs, M.x86.saved_ip, M.x86.R_CS, ip, "");
9647 push_word(M.x86.R_IP);
9649 DECODE_CLEAR_SEGOVR();
9653 /****************************************************************************
9656 ****************************************************************************/
9657 void x86emuOp_jump_near_IMM(u8 X86EMU_UNUSED(op1))
9662 DECODE_PRINTF("JMP\t");
9663 ip = (s16)fetch_word_imm();
9664 ip += (s16)M.x86.R_IP;
9665 DECODE_PRINTF2("%04x\n", ip);
9667 M.x86.R_IP = (u16)ip;
9668 DECODE_CLEAR_SEGOVR();
9672 /****************************************************************************
9675 ****************************************************************************/
9676 void x86emuOp_jump_far_IMM(u8 X86EMU_UNUSED(op1))
9681 DECODE_PRINTF("JMP\tFAR ");
9682 ip = fetch_word_imm();
9683 cs = fetch_word_imm();
9684 DECODE_PRINTF2("%04x:", cs);
9685 DECODE_PRINTF2("%04x\n", ip);
9689 DECODE_CLEAR_SEGOVR();
9693 /****************************************************************************
9696 ****************************************************************************/
9697 void x86emuOp_jump_byte_IMM(u8 X86EMU_UNUSED(op1))
9703 DECODE_PRINTF("JMP\t");
9704 offset = (s8)fetch_byte_imm();
9705 target = (u16)(M.x86.R_IP + offset);
9706 DECODE_PRINTF2("%x\n", target);
9708 M.x86.R_IP = target;
9709 DECODE_CLEAR_SEGOVR();
9713 /****************************************************************************
9716 ****************************************************************************/
9717 void x86emuOp_in_byte_AL_DX(u8 X86EMU_UNUSED(op1))
9720 DECODE_PRINTF("IN\tAL,DX\n");
9722 M.x86.R_AL = (*sys_inb)(M.x86.R_DX);
9723 DECODE_CLEAR_SEGOVR();
9727 /****************************************************************************
9730 ****************************************************************************/
9731 void x86emuOp_in_word_AX_DX(u8 X86EMU_UNUSED(op1))
9734 if (M.x86.mode & SYSMODE_PREFIX_DATA) {
9735 DECODE_PRINTF("IN\tEAX,DX\n");
9737 DECODE_PRINTF("IN\tAX,DX\n");
9740 if (M.x86.mode & SYSMODE_PREFIX_DATA) {
9741 M.x86.R_EAX = (*sys_inl)(M.x86.R_DX);
9743 M.x86.R_AX = (*sys_inw)(M.x86.R_DX);
9745 DECODE_CLEAR_SEGOVR();
9749 /****************************************************************************
9752 ****************************************************************************/
9753 void x86emuOp_out_byte_DX_AL(u8 X86EMU_UNUSED(op1))
9756 DECODE_PRINTF("OUT\tDX,AL\n");
9758 (*sys_outb)(M.x86.R_DX, M.x86.R_AL);
9759 DECODE_CLEAR_SEGOVR();
9763 /****************************************************************************
9766 ****************************************************************************/
9767 void x86emuOp_out_word_DX_AX(u8 X86EMU_UNUSED(op1))
9770 if (M.x86.mode & SYSMODE_PREFIX_DATA) {
9771 DECODE_PRINTF("OUT\tDX,EAX\n");
9773 DECODE_PRINTF("OUT\tDX,AX\n");
9776 if (M.x86.mode & SYSMODE_PREFIX_DATA) {
9777 (*sys_outl)(M.x86.R_DX, M.x86.R_EAX);
9779 (*sys_outw)(M.x86.R_DX, M.x86.R_AX);
9781 DECODE_CLEAR_SEGOVR();
9785 /****************************************************************************
9788 ****************************************************************************/
9789 void x86emuOp_lock(u8 X86EMU_UNUSED(op1))
9792 DECODE_PRINTF("LOCK:\n");
9794 DECODE_CLEAR_SEGOVR();
9798 /*opcode 0xf1 ILLEGAL OPERATION */
9800 /****************************************************************************
9803 ****************************************************************************/
9804 void x86emuOp_repne(u8 X86EMU_UNUSED(op1))
9807 DECODE_PRINTF("REPNE\n");
9809 M.x86.mode |= SYSMODE_PREFIX_REPNE;
9810 DECODE_CLEAR_SEGOVR();
9814 /****************************************************************************
9817 ****************************************************************************/
9818 void x86emuOp_repe(u8 X86EMU_UNUSED(op1))
9821 DECODE_PRINTF("REPE\n");
9823 M.x86.mode |= SYSMODE_PREFIX_REPE;
9824 DECODE_CLEAR_SEGOVR();
9828 /****************************************************************************
9831 ****************************************************************************/
9832 void x86emuOp_halt(u8 X86EMU_UNUSED(op1))
9835 DECODE_PRINTF("HALT\n");
9838 DECODE_CLEAR_SEGOVR();
9842 /****************************************************************************
9845 ****************************************************************************/
9846 void x86emuOp_cmc(u8 X86EMU_UNUSED(op1))
9848 /* complement the carry flag. */
9850 DECODE_PRINTF("CMC\n");
9853 DECODE_CLEAR_SEGOVR();
9857 /****************************************************************************
9860 ****************************************************************************/
9861 void x86emuOp_opcF6_byte_RM(u8 X86EMU_UNUSED(op1))
9868 /* long, drawn out code follows. Double switch for a total
9871 FETCH_DECODE_MODRM(mod, rh, rl);
9873 case 0: /* mod=00 */
9875 case 0: /* test byte imm */
9876 DECODE_PRINTF("TEST\tBYTE PTR ");
9877 destoffset = decode_rm00_address(rl);
9879 srcval = fetch_byte_imm();
9880 DECODE_PRINTF2("%02x\n", srcval);
9881 destval = fetch_data_byte(destoffset);
9883 test_byte(destval, srcval);
9886 DECODE_PRINTF("ILLEGAL OP MOD=00 RH=01 OP=F6\n");
9890 DECODE_PRINTF("NOT\tBYTE PTR ");
9891 destoffset = decode_rm00_address(rl);
9892 DECODE_PRINTF("\n");
9893 destval = fetch_data_byte(destoffset);
9895 destval = not_byte(destval);
9896 store_data_byte(destoffset, destval);
9899 DECODE_PRINTF("NEG\tBYTE PTR ");
9900 destoffset = decode_rm00_address(rl);
9901 DECODE_PRINTF("\n");
9902 destval = fetch_data_byte(destoffset);
9904 destval = neg_byte(destval);
9905 store_data_byte(destoffset, destval);
9908 DECODE_PRINTF("MUL\tBYTE PTR ");
9909 destoffset = decode_rm00_address(rl);
9910 DECODE_PRINTF("\n");
9911 destval = fetch_data_byte(destoffset);
9916 DECODE_PRINTF("IMUL\tBYTE PTR ");
9917 destoffset = decode_rm00_address(rl);
9918 DECODE_PRINTF("\n");
9919 destval = fetch_data_byte(destoffset);
9924 DECODE_PRINTF("DIV\tBYTE PTR ");
9925 destoffset = decode_rm00_address(rl);
9926 DECODE_PRINTF("\n");
9927 destval = fetch_data_byte(destoffset);
9932 DECODE_PRINTF("IDIV\tBYTE PTR ");
9933 destoffset = decode_rm00_address(rl);
9934 DECODE_PRINTF("\n");
9935 destval = fetch_data_byte(destoffset);
9940 break; /* end mod==00 */
9941 case 1: /* mod=01 */
9943 case 0: /* test byte imm */
9944 DECODE_PRINTF("TEST\tBYTE PTR ");
9945 destoffset = decode_rm01_address(rl);
9947 srcval = fetch_byte_imm();
9948 DECODE_PRINTF2("%02x\n", srcval);
9949 destval = fetch_data_byte(destoffset);
9951 test_byte(destval, srcval);
9954 DECODE_PRINTF("ILLEGAL OP MOD=01 RH=01 OP=F6\n");
9958 DECODE_PRINTF("NOT\tBYTE PTR ");
9959 destoffset = decode_rm01_address(rl);
9960 DECODE_PRINTF("\n");
9961 destval = fetch_data_byte(destoffset);
9963 destval = not_byte(destval);
9964 store_data_byte(destoffset, destval);
9967 DECODE_PRINTF("NEG\tBYTE PTR ");
9968 destoffset = decode_rm01_address(rl);
9969 DECODE_PRINTF("\n");
9970 destval = fetch_data_byte(destoffset);
9972 destval = neg_byte(destval);
9973 store_data_byte(destoffset, destval);
9976 DECODE_PRINTF("MUL\tBYTE PTR ");
9977 destoffset = decode_rm01_address(rl);
9978 DECODE_PRINTF("\n");
9979 destval = fetch_data_byte(destoffset);
9984 DECODE_PRINTF("IMUL\tBYTE PTR ");
9985 destoffset = decode_rm01_address(rl);
9986 DECODE_PRINTF("\n");
9987 destval = fetch_data_byte(destoffset);
9992 DECODE_PRINTF("DIV\tBYTE PTR ");
9993 destoffset = decode_rm01_address(rl);
9994 DECODE_PRINTF("\n");
9995 destval = fetch_data_byte(destoffset);
10000 DECODE_PRINTF("IDIV\tBYTE PTR ");
10001 destoffset = decode_rm01_address(rl);
10002 DECODE_PRINTF("\n");
10003 destval = fetch_data_byte(destoffset);
10005 idiv_byte(destval);
10008 break; /* end mod==01 */
10009 case 2: /* mod=10 */
10011 case 0: /* test byte imm */
10012 DECODE_PRINTF("TEST\tBYTE PTR ");
10013 destoffset = decode_rm10_address(rl);
10014 DECODE_PRINTF(",");
10015 srcval = fetch_byte_imm();
10016 DECODE_PRINTF2("%02x\n", srcval);
10017 destval = fetch_data_byte(destoffset);
10019 test_byte(destval, srcval);
10022 DECODE_PRINTF("ILLEGAL OP MOD=10 RH=01 OP=F6\n");
10026 DECODE_PRINTF("NOT\tBYTE PTR ");
10027 destoffset = decode_rm10_address(rl);
10028 DECODE_PRINTF("\n");
10029 destval = fetch_data_byte(destoffset);
10031 destval = not_byte(destval);
10032 store_data_byte(destoffset, destval);
10035 DECODE_PRINTF("NEG\tBYTE PTR ");
10036 destoffset = decode_rm10_address(rl);
10037 DECODE_PRINTF("\n");
10038 destval = fetch_data_byte(destoffset);
10040 destval = neg_byte(destval);
10041 store_data_byte(destoffset, destval);
10044 DECODE_PRINTF("MUL\tBYTE PTR ");
10045 destoffset = decode_rm10_address(rl);
10046 DECODE_PRINTF("\n");
10047 destval = fetch_data_byte(destoffset);
10052 DECODE_PRINTF("IMUL\tBYTE PTR ");
10053 destoffset = decode_rm10_address(rl);
10054 DECODE_PRINTF("\n");
10055 destval = fetch_data_byte(destoffset);
10057 imul_byte(destval);
10060 DECODE_PRINTF("DIV\tBYTE PTR ");
10061 destoffset = decode_rm10_address(rl);
10062 DECODE_PRINTF("\n");
10063 destval = fetch_data_byte(destoffset);
10068 DECODE_PRINTF("IDIV\tBYTE PTR ");
10069 destoffset = decode_rm10_address(rl);
10070 DECODE_PRINTF("\n");
10071 destval = fetch_data_byte(destoffset);
10073 idiv_byte(destval);
10076 break; /* end mod==10 */
10077 case 3: /* mod=11 */
10079 case 0: /* test byte imm */
10080 DECODE_PRINTF("TEST\t");
10081 destreg = DECODE_RM_BYTE_REGISTER(rl);
10082 DECODE_PRINTF(",");
10083 srcval = fetch_byte_imm();
10084 DECODE_PRINTF2("%02x\n", srcval);
10086 test_byte(*destreg, srcval);
10089 DECODE_PRINTF("ILLEGAL OP MOD=00 RH=01 OP=F6\n");
10093 DECODE_PRINTF("NOT\t");
10094 destreg = DECODE_RM_BYTE_REGISTER(rl);
10095 DECODE_PRINTF("\n");
10097 *destreg = not_byte(*destreg);
10100 DECODE_PRINTF("NEG\t");
10101 destreg = DECODE_RM_BYTE_REGISTER(rl);
10102 DECODE_PRINTF("\n");
10104 *destreg = neg_byte(*destreg);
10107 DECODE_PRINTF("MUL\t");
10108 destreg = DECODE_RM_BYTE_REGISTER(rl);
10109 DECODE_PRINTF("\n");
10111 mul_byte(*destreg); /*!!! */
10114 DECODE_PRINTF("IMUL\t");
10115 destreg = DECODE_RM_BYTE_REGISTER(rl);
10116 DECODE_PRINTF("\n");
10118 imul_byte(*destreg);
10121 DECODE_PRINTF("DIV\t");
10122 destreg = DECODE_RM_BYTE_REGISTER(rl);
10123 DECODE_PRINTF("\n");
10125 div_byte(*destreg);
10128 DECODE_PRINTF("IDIV\t");
10129 destreg = DECODE_RM_BYTE_REGISTER(rl);
10130 DECODE_PRINTF("\n");
10132 idiv_byte(*destreg);
10135 break; /* end mod==11 */
10137 DECODE_CLEAR_SEGOVR();
10141 /****************************************************************************
10143 Handles opcode 0xf7
10144 ****************************************************************************/
10145 void x86emuOp_opcF7_word_RM(u8 X86EMU_UNUSED(op1))
10150 /* long, drawn out code follows. Double switch for a total
10153 FETCH_DECODE_MODRM(mod, rh, rl);
10155 case 0: /* mod=00 */
10157 case 0: /* test word imm */
10158 if (M.x86.mode & SYSMODE_PREFIX_DATA) {
10159 u32 destval,srcval;
10161 DECODE_PRINTF("TEST\tDWORD PTR ");
10162 destoffset = decode_rm00_address(rl);
10163 DECODE_PRINTF(",");
10164 srcval = fetch_long_imm();
10165 DECODE_PRINTF2("%x\n", srcval);
10166 destval = fetch_data_long(destoffset);
10168 test_long(destval, srcval);
10170 u16 destval,srcval;
10172 DECODE_PRINTF("TEST\tWORD PTR ");
10173 destoffset = decode_rm00_address(rl);
10174 DECODE_PRINTF(",");
10175 srcval = fetch_word_imm();
10176 DECODE_PRINTF2("%x\n", srcval);
10177 destval = fetch_data_word(destoffset);
10179 test_word(destval, srcval);
10183 DECODE_PRINTF("ILLEGAL OP MOD=00 RH=01 OP=F7\n");
10187 if (M.x86.mode & SYSMODE_PREFIX_DATA) {
10190 DECODE_PRINTF("NOT\tDWORD PTR ");
10191 destoffset = decode_rm00_address(rl);
10192 DECODE_PRINTF("\n");
10193 destval = fetch_data_long(destoffset);
10195 destval = not_long(destval);
10196 store_data_long(destoffset, destval);
10200 DECODE_PRINTF("NOT\tWORD PTR ");
10201 destoffset = decode_rm00_address(rl);
10202 DECODE_PRINTF("\n");
10203 destval = fetch_data_word(destoffset);
10205 destval = not_word(destval);
10206 store_data_word(destoffset, destval);
10210 if (M.x86.mode & SYSMODE_PREFIX_DATA) {
10213 DECODE_PRINTF("NEG\tDWORD PTR ");
10214 destoffset = decode_rm00_address(rl);
10215 DECODE_PRINTF("\n");
10216 destval = fetch_data_long(destoffset);
10218 destval = neg_long(destval);
10219 store_data_long(destoffset, destval);
10223 DECODE_PRINTF("NEG\tWORD PTR ");
10224 destoffset = decode_rm00_address(rl);
10225 DECODE_PRINTF("\n");
10226 destval = fetch_data_word(destoffset);
10228 destval = neg_word(destval);
10229 store_data_word(destoffset, destval);
10233 if (M.x86.mode & SYSMODE_PREFIX_DATA) {
10236 DECODE_PRINTF("MUL\tDWORD PTR ");
10237 destoffset = decode_rm00_address(rl);
10238 DECODE_PRINTF("\n");
10239 destval = fetch_data_long(destoffset);
10245 DECODE_PRINTF("MUL\tWORD PTR ");
10246 destoffset = decode_rm00_address(rl);
10247 DECODE_PRINTF("\n");
10248 destval = fetch_data_word(destoffset);
10254 if (M.x86.mode & SYSMODE_PREFIX_DATA) {
10257 DECODE_PRINTF("IMUL\tDWORD PTR ");
10258 destoffset = decode_rm00_address(rl);
10259 DECODE_PRINTF("\n");
10260 destval = fetch_data_long(destoffset);
10262 imul_long(destval);
10266 DECODE_PRINTF("IMUL\tWORD PTR ");
10267 destoffset = decode_rm00_address(rl);
10268 DECODE_PRINTF("\n");
10269 destval = fetch_data_word(destoffset);
10271 imul_word(destval);
10275 if (M.x86.mode & SYSMODE_PREFIX_DATA) {
10278 DECODE_PRINTF("DIV\tDWORD PTR ");
10279 destoffset = decode_rm00_address(rl);
10280 DECODE_PRINTF("\n");
10281 destval = fetch_data_long(destoffset);
10287 DECODE_PRINTF("DIV\tWORD PTR ");
10288 destoffset = decode_rm00_address(rl);
10289 DECODE_PRINTF("\n");
10290 destval = fetch_data_word(destoffset);
10296 if (M.x86.mode & SYSMODE_PREFIX_DATA) {
10299 DECODE_PRINTF("IDIV\tDWORD PTR ");
10300 destoffset = decode_rm00_address(rl);
10301 DECODE_PRINTF("\n");
10302 destval = fetch_data_long(destoffset);
10304 idiv_long(destval);
10308 DECODE_PRINTF("IDIV\tWORD PTR ");
10309 destoffset = decode_rm00_address(rl);
10310 DECODE_PRINTF("\n");
10311 destval = fetch_data_word(destoffset);
10313 idiv_word(destval);
10317 break; /* end mod==00 */
10318 case 1: /* mod=01 */
10320 case 0: /* test word imm */
10321 if (M.x86.mode & SYSMODE_PREFIX_DATA) {
10322 u32 destval,srcval;
10324 DECODE_PRINTF("TEST\tDWORD PTR ");
10325 destoffset = decode_rm01_address(rl);
10326 DECODE_PRINTF(",");
10327 srcval = fetch_long_imm();
10328 DECODE_PRINTF2("%x\n", srcval);
10329 destval = fetch_data_long(destoffset);
10331 test_long(destval, srcval);
10333 u16 destval,srcval;
10335 DECODE_PRINTF("TEST\tWORD PTR ");
10336 destoffset = decode_rm01_address(rl);
10337 DECODE_PRINTF(",");
10338 srcval = fetch_word_imm();
10339 DECODE_PRINTF2("%x\n", srcval);
10340 destval = fetch_data_word(destoffset);
10342 test_word(destval, srcval);
10346 DECODE_PRINTF("ILLEGAL OP MOD=01 RH=01 OP=F6\n");
10350 if (M.x86.mode & SYSMODE_PREFIX_DATA) {
10353 DECODE_PRINTF("NOT\tDWORD PTR ");
10354 destoffset = decode_rm01_address(rl);
10355 DECODE_PRINTF("\n");
10356 destval = fetch_data_long(destoffset);
10358 destval = not_long(destval);
10359 store_data_long(destoffset, destval);
10363 DECODE_PRINTF("NOT\tWORD PTR ");
10364 destoffset = decode_rm01_address(rl);
10365 DECODE_PRINTF("\n");
10366 destval = fetch_data_word(destoffset);
10368 destval = not_word(destval);
10369 store_data_word(destoffset, destval);
10373 if (M.x86.mode & SYSMODE_PREFIX_DATA) {
10376 DECODE_PRINTF("NEG\tDWORD PTR ");
10377 destoffset = decode_rm01_address(rl);
10378 DECODE_PRINTF("\n");
10379 destval = fetch_data_long(destoffset);
10381 destval = neg_long(destval);
10382 store_data_long(destoffset, destval);
10386 DECODE_PRINTF("NEG\tWORD PTR ");
10387 destoffset = decode_rm01_address(rl);
10388 DECODE_PRINTF("\n");
10389 destval = fetch_data_word(destoffset);
10391 destval = neg_word(destval);
10392 store_data_word(destoffset, destval);
10396 if (M.x86.mode & SYSMODE_PREFIX_DATA) {
10399 DECODE_PRINTF("MUL\tDWORD PTR ");
10400 destoffset = decode_rm01_address(rl);
10401 DECODE_PRINTF("\n");
10402 destval = fetch_data_long(destoffset);
10408 DECODE_PRINTF("MUL\tWORD PTR ");
10409 destoffset = decode_rm01_address(rl);
10410 DECODE_PRINTF("\n");
10411 destval = fetch_data_word(destoffset);
10417 if (M.x86.mode & SYSMODE_PREFIX_DATA) {
10420 DECODE_PRINTF("IMUL\tDWORD PTR ");
10421 destoffset = decode_rm01_address(rl);
10422 DECODE_PRINTF("\n");
10423 destval = fetch_data_long(destoffset);
10425 imul_long(destval);
10429 DECODE_PRINTF("IMUL\tWORD PTR ");
10430 destoffset = decode_rm01_address(rl);
10431 DECODE_PRINTF("\n");
10432 destval = fetch_data_word(destoffset);
10434 imul_word(destval);
10438 if (M.x86.mode & SYSMODE_PREFIX_DATA) {
10441 DECODE_PRINTF("DIV\tDWORD PTR ");
10442 destoffset = decode_rm01_address(rl);
10443 DECODE_PRINTF("\n");
10444 destval = fetch_data_long(destoffset);
10450 DECODE_PRINTF("DIV\tWORD PTR ");
10451 destoffset = decode_rm01_address(rl);
10452 DECODE_PRINTF("\n");
10453 destval = fetch_data_word(destoffset);
10459 if (M.x86.mode & SYSMODE_PREFIX_DATA) {
10462 DECODE_PRINTF("IDIV\tDWORD PTR ");
10463 destoffset = decode_rm01_address(rl);
10464 DECODE_PRINTF("\n");
10465 destval = fetch_data_long(destoffset);
10467 idiv_long(destval);
10471 DECODE_PRINTF("IDIV\tWORD PTR ");
10472 destoffset = decode_rm01_address(rl);
10473 DECODE_PRINTF("\n");
10474 destval = fetch_data_word(destoffset);
10476 idiv_word(destval);
10480 break; /* end mod==01 */
10481 case 2: /* mod=10 */
10483 case 0: /* test word imm */
10484 if (M.x86.mode & SYSMODE_PREFIX_DATA) {
10485 u32 destval,srcval;
10487 DECODE_PRINTF("TEST\tDWORD PTR ");
10488 destoffset = decode_rm10_address(rl);
10489 DECODE_PRINTF(",");
10490 srcval = fetch_long_imm();
10491 DECODE_PRINTF2("%x\n", srcval);
10492 destval = fetch_data_long(destoffset);
10494 test_long(destval, srcval);
10496 u16 destval,srcval;
10498 DECODE_PRINTF("TEST\tWORD PTR ");
10499 destoffset = decode_rm10_address(rl);
10500 DECODE_PRINTF(",");
10501 srcval = fetch_word_imm();
10502 DECODE_PRINTF2("%x\n", srcval);
10503 destval = fetch_data_word(destoffset);
10505 test_word(destval, srcval);
10509 DECODE_PRINTF("ILLEGAL OP MOD=10 RH=01 OP=F6\n");
10513 if (M.x86.mode & SYSMODE_PREFIX_DATA) {
10516 DECODE_PRINTF("NOT\tDWORD PTR ");
10517 destoffset = decode_rm10_address(rl);
10518 DECODE_PRINTF("\n");
10519 destval = fetch_data_long(destoffset);
10521 destval = not_long(destval);
10522 store_data_long(destoffset, destval);
10526 DECODE_PRINTF("NOT\tWORD PTR ");
10527 destoffset = decode_rm10_address(rl);
10528 DECODE_PRINTF("\n");
10529 destval = fetch_data_word(destoffset);
10531 destval = not_word(destval);
10532 store_data_word(destoffset, destval);
10536 if (M.x86.mode & SYSMODE_PREFIX_DATA) {
10539 DECODE_PRINTF("NEG\tDWORD PTR ");
10540 destoffset = decode_rm10_address(rl);
10541 DECODE_PRINTF("\n");
10542 destval = fetch_data_long(destoffset);
10544 destval = neg_long(destval);
10545 store_data_long(destoffset, destval);
10549 DECODE_PRINTF("NEG\tWORD PTR ");
10550 destoffset = decode_rm10_address(rl);
10551 DECODE_PRINTF("\n");
10552 destval = fetch_data_word(destoffset);
10554 destval = neg_word(destval);
10555 store_data_word(destoffset, destval);
10559 if (M.x86.mode & SYSMODE_PREFIX_DATA) {
10562 DECODE_PRINTF("MUL\tDWORD PTR ");
10563 destoffset = decode_rm10_address(rl);
10564 DECODE_PRINTF("\n");
10565 destval = fetch_data_long(destoffset);
10571 DECODE_PRINTF("MUL\tWORD PTR ");
10572 destoffset = decode_rm10_address(rl);
10573 DECODE_PRINTF("\n");
10574 destval = fetch_data_word(destoffset);
10580 if (M.x86.mode & SYSMODE_PREFIX_DATA) {
10583 DECODE_PRINTF("IMUL\tDWORD PTR ");
10584 destoffset = decode_rm10_address(rl);
10585 DECODE_PRINTF("\n");
10586 destval = fetch_data_long(destoffset);
10588 imul_long(destval);
10592 DECODE_PRINTF("IMUL\tWORD PTR ");
10593 destoffset = decode_rm10_address(rl);
10594 DECODE_PRINTF("\n");
10595 destval = fetch_data_word(destoffset);
10597 imul_word(destval);
10601 if (M.x86.mode & SYSMODE_PREFIX_DATA) {
10604 DECODE_PRINTF("DIV\tDWORD PTR ");
10605 destoffset = decode_rm10_address(rl);
10606 DECODE_PRINTF("\n");
10607 destval = fetch_data_long(destoffset);
10613 DECODE_PRINTF("DIV\tWORD PTR ");
10614 destoffset = decode_rm10_address(rl);
10615 DECODE_PRINTF("\n");
10616 destval = fetch_data_word(destoffset);
10622 if (M.x86.mode & SYSMODE_PREFIX_DATA) {
10625 DECODE_PRINTF("IDIV\tDWORD PTR ");
10626 destoffset = decode_rm10_address(rl);
10627 DECODE_PRINTF("\n");
10628 destval = fetch_data_long(destoffset);
10630 idiv_long(destval);
10634 DECODE_PRINTF("IDIV\tWORD PTR ");
10635 destoffset = decode_rm10_address(rl);
10636 DECODE_PRINTF("\n");
10637 destval = fetch_data_word(destoffset);
10639 idiv_word(destval);
10643 break; /* end mod==10 */
10644 case 3: /* mod=11 */
10646 case 0: /* test word imm */
10647 if (M.x86.mode & SYSMODE_PREFIX_DATA) {
10651 DECODE_PRINTF("TEST\t");
10652 destreg = DECODE_RM_LONG_REGISTER(rl);
10653 DECODE_PRINTF(",");
10654 srcval = fetch_long_imm();
10655 DECODE_PRINTF2("%x\n", srcval);
10657 test_long(*destreg, srcval);
10662 DECODE_PRINTF("TEST\t");
10663 destreg = DECODE_RM_WORD_REGISTER(rl);
10664 DECODE_PRINTF(",");
10665 srcval = fetch_word_imm();
10666 DECODE_PRINTF2("%x\n", srcval);
10668 test_word(*destreg, srcval);
10672 DECODE_PRINTF("ILLEGAL OP MOD=00 RH=01 OP=F6\n");
10676 if (M.x86.mode & SYSMODE_PREFIX_DATA) {
10679 DECODE_PRINTF("NOT\t");
10680 destreg = DECODE_RM_LONG_REGISTER(rl);
10681 DECODE_PRINTF("\n");
10683 *destreg = not_long(*destreg);
10687 DECODE_PRINTF("NOT\t");
10688 destreg = DECODE_RM_WORD_REGISTER(rl);
10689 DECODE_PRINTF("\n");
10691 *destreg = not_word(*destreg);
10695 if (M.x86.mode & SYSMODE_PREFIX_DATA) {
10698 DECODE_PRINTF("NEG\t");
10699 destreg = DECODE_RM_LONG_REGISTER(rl);
10700 DECODE_PRINTF("\n");
10702 *destreg = neg_long(*destreg);
10706 DECODE_PRINTF("NEG\t");
10707 destreg = DECODE_RM_WORD_REGISTER(rl);
10708 DECODE_PRINTF("\n");
10710 *destreg = neg_word(*destreg);
10714 if (M.x86.mode & SYSMODE_PREFIX_DATA) {
10717 DECODE_PRINTF("MUL\t");
10718 destreg = DECODE_RM_LONG_REGISTER(rl);
10719 DECODE_PRINTF("\n");
10721 mul_long(*destreg); /*!!! */
10725 DECODE_PRINTF("MUL\t");
10726 destreg = DECODE_RM_WORD_REGISTER(rl);
10727 DECODE_PRINTF("\n");
10729 mul_word(*destreg); /*!!! */
10733 if (M.x86.mode & SYSMODE_PREFIX_DATA) {
10736 DECODE_PRINTF("IMUL\t");
10737 destreg = DECODE_RM_LONG_REGISTER(rl);
10738 DECODE_PRINTF("\n");
10740 imul_long(*destreg);
10744 DECODE_PRINTF("IMUL\t");
10745 destreg = DECODE_RM_WORD_REGISTER(rl);
10746 DECODE_PRINTF("\n");
10748 imul_word(*destreg);
10752 if (M.x86.mode & SYSMODE_PREFIX_DATA) {
10755 DECODE_PRINTF("DIV\t");
10756 destreg = DECODE_RM_LONG_REGISTER(rl);
10757 DECODE_PRINTF("\n");
10759 div_long(*destreg);
10763 DECODE_PRINTF("DIV\t");
10764 destreg = DECODE_RM_WORD_REGISTER(rl);
10765 DECODE_PRINTF("\n");
10767 div_word(*destreg);
10771 if (M.x86.mode & SYSMODE_PREFIX_DATA) {
10774 DECODE_PRINTF("IDIV\t");
10775 destreg = DECODE_RM_LONG_REGISTER(rl);
10776 DECODE_PRINTF("\n");
10778 idiv_long(*destreg);
10782 DECODE_PRINTF("IDIV\t");
10783 destreg = DECODE_RM_WORD_REGISTER(rl);
10784 DECODE_PRINTF("\n");
10786 idiv_word(*destreg);
10790 break; /* end mod==11 */
10792 DECODE_CLEAR_SEGOVR();
10796 /****************************************************************************
10798 Handles opcode 0xf8
10799 ****************************************************************************/
10800 void x86emuOp_clc(u8 X86EMU_UNUSED(op1))
10802 /* clear the carry flag. */
10804 DECODE_PRINTF("CLC\n");
10807 DECODE_CLEAR_SEGOVR();
10811 /****************************************************************************
10813 Handles opcode 0xf9
10814 ****************************************************************************/
10815 void x86emuOp_stc(u8 X86EMU_UNUSED(op1))
10817 /* set the carry flag. */
10819 DECODE_PRINTF("STC\n");
10822 DECODE_CLEAR_SEGOVR();
10826 /****************************************************************************
10828 Handles opcode 0xfa
10829 ****************************************************************************/
10830 void x86emuOp_cli(u8 X86EMU_UNUSED(op1))
10832 /* clear interrupts. */
10834 DECODE_PRINTF("CLI\n");
10837 DECODE_CLEAR_SEGOVR();
10841 /****************************************************************************
10843 Handles opcode 0xfb
10844 ****************************************************************************/
10845 void x86emuOp_sti(u8 X86EMU_UNUSED(op1))
10847 /* enable interrupts. */
10849 DECODE_PRINTF("STI\n");
10852 DECODE_CLEAR_SEGOVR();
10856 /****************************************************************************
10858 Handles opcode 0xfc
10859 ****************************************************************************/
10860 void x86emuOp_cld(u8 X86EMU_UNUSED(op1))
10862 /* clear interrupts. */
10864 DECODE_PRINTF("CLD\n");
10867 DECODE_CLEAR_SEGOVR();
10871 /****************************************************************************
10873 Handles opcode 0xfd
10874 ****************************************************************************/
10875 void x86emuOp_std(u8 X86EMU_UNUSED(op1))
10877 /* clear interrupts. */
10879 DECODE_PRINTF("STD\n");
10882 DECODE_CLEAR_SEGOVR();
10886 /****************************************************************************
10888 Handles opcode 0xfe
10889 ****************************************************************************/
10890 void x86emuOp_opcFE_byte_RM(u8 X86EMU_UNUSED(op1))
10897 /* Yet another special case instruction. */
10899 FETCH_DECODE_MODRM(mod, rh, rl);
10901 if (DEBUG_DECODE()) {
10902 /* XXX DECODE_PRINTF may be changed to something more
10903 general, so that it is important to leave the strings
10904 in the same format, even though the result is that the
10905 above test is done twice. */
10909 DECODE_PRINTF("INC\t");
10912 DECODE_PRINTF("DEC\t");
10920 DECODE_PRINTF2("ILLEGAL OP MAJOR OP 0xFE MINOR OP %x \n", mod);
10928 DECODE_PRINTF("BYTE PTR ");
10929 destoffset = decode_rm00_address(rl);
10930 DECODE_PRINTF("\n");
10932 case 0: /* inc word ptr ... */
10933 destval = fetch_data_byte(destoffset);
10935 destval = inc_byte(destval);
10936 store_data_byte(destoffset, destval);
10938 case 1: /* dec word ptr ... */
10939 destval = fetch_data_byte(destoffset);
10941 destval = dec_byte(destval);
10942 store_data_byte(destoffset, destval);
10947 DECODE_PRINTF("BYTE PTR ");
10948 destoffset = decode_rm01_address(rl);
10949 DECODE_PRINTF("\n");
10952 destval = fetch_data_byte(destoffset);
10954 destval = inc_byte(destval);
10955 store_data_byte(destoffset, destval);
10958 destval = fetch_data_byte(destoffset);
10960 destval = dec_byte(destval);
10961 store_data_byte(destoffset, destval);
10966 DECODE_PRINTF("BYTE PTR ");
10967 destoffset = decode_rm10_address(rl);
10968 DECODE_PRINTF("\n");
10971 destval = fetch_data_byte(destoffset);
10973 destval = inc_byte(destval);
10974 store_data_byte(destoffset, destval);
10977 destval = fetch_data_byte(destoffset);
10979 destval = dec_byte(destval);
10980 store_data_byte(destoffset, destval);
10985 destreg = DECODE_RM_BYTE_REGISTER(rl);
10986 DECODE_PRINTF("\n");
10990 *destreg = inc_byte(*destreg);
10994 *destreg = dec_byte(*destreg);
10999 DECODE_CLEAR_SEGOVR();
11003 /****************************************************************************
11005 Handles opcode 0xff
11006 ****************************************************************************/
11007 void x86emuOp_opcFF_word_RM(u8 X86EMU_UNUSED(op1))
11010 uint destoffset = 0;
11012 u16 destval,destval2;
11014 /* Yet another special case instruction. */
11016 FETCH_DECODE_MODRM(mod, rh, rl);
11018 if (DEBUG_DECODE()) {
11019 /* XXX DECODE_PRINTF may be changed to something more
11020 general, so that it is important to leave the strings
11021 in the same format, even though the result is that the
11022 above test is done twice. */
11026 if (M.x86.mode & SYSMODE_PREFIX_DATA) {
11027 DECODE_PRINTF("INC\tDWORD PTR ");
11029 DECODE_PRINTF("INC\tWORD PTR ");
11033 if (M.x86.mode & SYSMODE_PREFIX_DATA) {
11034 DECODE_PRINTF("DEC\tDWORD PTR ");
11036 DECODE_PRINTF("DEC\tWORD PTR ");
11040 DECODE_PRINTF("CALL\t ");
11043 DECODE_PRINTF("CALL\tFAR ");
11046 DECODE_PRINTF("JMP\t");
11049 DECODE_PRINTF("JMP\tFAR ");
11052 DECODE_PRINTF("PUSH\t");
11055 DECODE_PRINTF("ILLEGAL DECODING OF OPCODE FF\t");
11063 destoffset = decode_rm00_address(rl);
11064 DECODE_PRINTF("\n");
11066 case 0: /* inc word ptr ... */
11067 if (M.x86.mode & SYSMODE_PREFIX_DATA) {
11070 destval = fetch_data_long(destoffset);
11072 destval = inc_long(destval);
11073 store_data_long(destoffset, destval);
11077 destval = fetch_data_word(destoffset);
11079 destval = inc_word(destval);
11080 store_data_word(destoffset, destval);
11083 case 1: /* dec word ptr ... */
11084 if (M.x86.mode & SYSMODE_PREFIX_DATA) {
11087 destval = fetch_data_long(destoffset);
11089 destval = dec_long(destval);
11090 store_data_long(destoffset, destval);
11094 destval = fetch_data_word(destoffset);
11096 destval = dec_word(destval);
11097 store_data_word(destoffset, destval);
11100 case 2: /* call word ptr ... */
11101 destval = fetch_data_word(destoffset);
11103 push_word(M.x86.R_IP);
11104 M.x86.R_IP = destval;
11106 case 3: /* call far ptr ... */
11107 destval = fetch_data_word(destoffset);
11108 destval2 = fetch_data_word(destoffset + 2);
11110 push_word(M.x86.R_CS);
11111 M.x86.R_CS = destval2;
11112 push_word(M.x86.R_IP);
11113 M.x86.R_IP = destval;
11115 case 4: /* jmp word ptr ... */
11116 destval = fetch_data_word(destoffset);
11118 M.x86.R_IP = destval;
11120 case 5: /* jmp far ptr ... */
11121 destval = fetch_data_word(destoffset);
11122 destval2 = fetch_data_word(destoffset + 2);
11124 M.x86.R_IP = destval;
11125 M.x86.R_CS = destval2;
11127 case 6: /* push word ptr ... */
11128 if (M.x86.mode & SYSMODE_PREFIX_DATA) {
11131 destval = fetch_data_long(destoffset);
11133 push_long(destval);
11137 destval = fetch_data_word(destoffset);
11139 push_word(destval);
11145 destoffset = decode_rm01_address(rl);
11146 DECODE_PRINTF("\n");
11149 if (M.x86.mode & SYSMODE_PREFIX_DATA) {
11152 destval = fetch_data_long(destoffset);
11154 destval = inc_long(destval);
11155 store_data_long(destoffset, destval);
11159 destval = fetch_data_word(destoffset);
11161 destval = inc_word(destval);
11162 store_data_word(destoffset, destval);
11166 if (M.x86.mode & SYSMODE_PREFIX_DATA) {
11169 destval = fetch_data_long(destoffset);
11171 destval = dec_long(destval);
11172 store_data_long(destoffset, destval);
11176 destval = fetch_data_word(destoffset);
11178 destval = dec_word(destval);
11179 store_data_word(destoffset, destval);
11182 case 2: /* call word ptr ... */
11183 destval = fetch_data_word(destoffset);
11185 push_word(M.x86.R_IP);
11186 M.x86.R_IP = destval;
11188 case 3: /* call far ptr ... */
11189 destval = fetch_data_word(destoffset);
11190 destval2 = fetch_data_word(destoffset + 2);
11192 push_word(M.x86.R_CS);
11193 M.x86.R_CS = destval2;
11194 push_word(M.x86.R_IP);
11195 M.x86.R_IP = destval;
11197 case 4: /* jmp word ptr ... */
11198 destval = fetch_data_word(destoffset);
11200 M.x86.R_IP = destval;
11202 case 5: /* jmp far ptr ... */
11203 destval = fetch_data_word(destoffset);
11204 destval2 = fetch_data_word(destoffset + 2);
11206 M.x86.R_IP = destval;
11207 M.x86.R_CS = destval2;
11209 case 6: /* push word ptr ... */
11210 if (M.x86.mode & SYSMODE_PREFIX_DATA) {
11213 destval = fetch_data_long(destoffset);
11215 push_long(destval);
11219 destval = fetch_data_word(destoffset);
11221 push_word(destval);
11227 destoffset = decode_rm10_address(rl);
11228 DECODE_PRINTF("\n");
11231 if (M.x86.mode & SYSMODE_PREFIX_DATA) {
11234 destval = fetch_data_long(destoffset);
11236 destval = inc_long(destval);
11237 store_data_long(destoffset, destval);
11241 destval = fetch_data_word(destoffset);
11243 destval = inc_word(destval);
11244 store_data_word(destoffset, destval);
11248 if (M.x86.mode & SYSMODE_PREFIX_DATA) {
11251 destval = fetch_data_long(destoffset);
11253 destval = dec_long(destval);
11254 store_data_long(destoffset, destval);
11258 destval = fetch_data_word(destoffset);
11260 destval = dec_word(destval);
11261 store_data_word(destoffset, destval);
11264 case 2: /* call word ptr ... */
11265 destval = fetch_data_word(destoffset);
11267 push_word(M.x86.R_IP);
11268 M.x86.R_IP = destval;
11270 case 3: /* call far ptr ... */
11271 destval = fetch_data_word(destoffset);
11272 destval2 = fetch_data_word(destoffset + 2);
11274 push_word(M.x86.R_CS);
11275 M.x86.R_CS = destval2;
11276 push_word(M.x86.R_IP);
11277 M.x86.R_IP = destval;
11279 case 4: /* jmp word ptr ... */
11280 destval = fetch_data_word(destoffset);
11282 M.x86.R_IP = destval;
11284 case 5: /* jmp far ptr ... */
11285 destval = fetch_data_word(destoffset);
11286 destval2 = fetch_data_word(destoffset + 2);
11288 M.x86.R_IP = destval;
11289 M.x86.R_CS = destval2;
11291 case 6: /* push word ptr ... */
11292 if (M.x86.mode & SYSMODE_PREFIX_DATA) {
11295 destval = fetch_data_long(destoffset);
11297 push_long(destval);
11301 destval = fetch_data_word(destoffset);
11303 push_word(destval);
11311 if (M.x86.mode & SYSMODE_PREFIX_DATA) {
11314 destreg = DECODE_RM_LONG_REGISTER(rl);
11315 DECODE_PRINTF("\n");
11317 *destreg = inc_long(*destreg);
11321 destreg = DECODE_RM_WORD_REGISTER(rl);
11322 DECODE_PRINTF("\n");
11324 *destreg = inc_word(*destreg);
11328 if (M.x86.mode & SYSMODE_PREFIX_DATA) {
11331 destreg = DECODE_RM_LONG_REGISTER(rl);
11332 DECODE_PRINTF("\n");
11334 *destreg = dec_long(*destreg);
11338 destreg = DECODE_RM_WORD_REGISTER(rl);
11339 DECODE_PRINTF("\n");
11341 *destreg = dec_word(*destreg);
11344 case 2: /* call word ptr ... */
11345 destreg = DECODE_RM_WORD_REGISTER(rl);
11346 DECODE_PRINTF("\n");
11348 push_word(M.x86.R_IP);
11349 M.x86.R_IP = *destreg;
11351 case 3: /* jmp far ptr ... */
11352 DECODE_PRINTF("OPERATION UNDEFINED 0XFF \n");
11357 case 4: /* jmp ... */
11358 destreg = DECODE_RM_WORD_REGISTER(rl);
11359 DECODE_PRINTF("\n");
11361 M.x86.R_IP = (u16) (*destreg);
11363 case 5: /* jmp far ptr ... */
11364 DECODE_PRINTF("OPERATION UNDEFINED 0XFF \n");
11369 if (M.x86.mode & SYSMODE_PREFIX_DATA) {
11372 destreg = DECODE_RM_LONG_REGISTER(rl);
11373 DECODE_PRINTF("\n");
11375 push_long(*destreg);
11379 destreg = DECODE_RM_WORD_REGISTER(rl);
11380 DECODE_PRINTF("\n");
11382 push_word(*destreg);
11388 DECODE_CLEAR_SEGOVR();
11392 /***************************************************************************
11393 * Single byte operation code table:
11394 **************************************************************************/
11395 void (*x86emu_optab[256])(u8) =
11397 /* 0x00 */ x86emuOp_add_byte_RM_R,
11398 /* 0x01 */ x86emuOp_add_word_RM_R,
11399 /* 0x02 */ x86emuOp_add_byte_R_RM,
11400 /* 0x03 */ x86emuOp_add_word_R_RM,
11401 /* 0x04 */ x86emuOp_add_byte_AL_IMM,
11402 /* 0x05 */ x86emuOp_add_word_AX_IMM,
11403 /* 0x06 */ x86emuOp_push_ES,
11404 /* 0x07 */ x86emuOp_pop_ES,
11406 /* 0x08 */ x86emuOp_or_byte_RM_R,
11407 /* 0x09 */ x86emuOp_or_word_RM_R,
11408 /* 0x0a */ x86emuOp_or_byte_R_RM,
11409 /* 0x0b */ x86emuOp_or_word_R_RM,
11410 /* 0x0c */ x86emuOp_or_byte_AL_IMM,
11411 /* 0x0d */ x86emuOp_or_word_AX_IMM,
11412 /* 0x0e */ x86emuOp_push_CS,
11413 /* 0x0f */ x86emuOp_two_byte,
11415 /* 0x10 */ x86emuOp_adc_byte_RM_R,
11416 /* 0x11 */ x86emuOp_adc_word_RM_R,
11417 /* 0x12 */ x86emuOp_adc_byte_R_RM,
11418 /* 0x13 */ x86emuOp_adc_word_R_RM,
11419 /* 0x14 */ x86emuOp_adc_byte_AL_IMM,
11420 /* 0x15 */ x86emuOp_adc_word_AX_IMM,
11421 /* 0x16 */ x86emuOp_push_SS,
11422 /* 0x17 */ x86emuOp_pop_SS,
11424 /* 0x18 */ x86emuOp_sbb_byte_RM_R,
11425 /* 0x19 */ x86emuOp_sbb_word_RM_R,
11426 /* 0x1a */ x86emuOp_sbb_byte_R_RM,
11427 /* 0x1b */ x86emuOp_sbb_word_R_RM,
11428 /* 0x1c */ x86emuOp_sbb_byte_AL_IMM,
11429 /* 0x1d */ x86emuOp_sbb_word_AX_IMM,
11430 /* 0x1e */ x86emuOp_push_DS,
11431 /* 0x1f */ x86emuOp_pop_DS,
11433 /* 0x20 */ x86emuOp_and_byte_RM_R,
11434 /* 0x21 */ x86emuOp_and_word_RM_R,
11435 /* 0x22 */ x86emuOp_and_byte_R_RM,
11436 /* 0x23 */ x86emuOp_and_word_R_RM,
11437 /* 0x24 */ x86emuOp_and_byte_AL_IMM,
11438 /* 0x25 */ x86emuOp_and_word_AX_IMM,
11439 /* 0x26 */ x86emuOp_segovr_ES,
11440 /* 0x27 */ x86emuOp_daa,
11442 /* 0x28 */ x86emuOp_sub_byte_RM_R,
11443 /* 0x29 */ x86emuOp_sub_word_RM_R,
11444 /* 0x2a */ x86emuOp_sub_byte_R_RM,
11445 /* 0x2b */ x86emuOp_sub_word_R_RM,
11446 /* 0x2c */ x86emuOp_sub_byte_AL_IMM,
11447 /* 0x2d */ x86emuOp_sub_word_AX_IMM,
11448 /* 0x2e */ x86emuOp_segovr_CS,
11449 /* 0x2f */ x86emuOp_das,
11451 /* 0x30 */ x86emuOp_xor_byte_RM_R,
11452 /* 0x31 */ x86emuOp_xor_word_RM_R,
11453 /* 0x32 */ x86emuOp_xor_byte_R_RM,
11454 /* 0x33 */ x86emuOp_xor_word_R_RM,
11455 /* 0x34 */ x86emuOp_xor_byte_AL_IMM,
11456 /* 0x35 */ x86emuOp_xor_word_AX_IMM,
11457 /* 0x36 */ x86emuOp_segovr_SS,
11458 /* 0x37 */ x86emuOp_aaa,
11460 /* 0x38 */ x86emuOp_cmp_byte_RM_R,
11461 /* 0x39 */ x86emuOp_cmp_word_RM_R,
11462 /* 0x3a */ x86emuOp_cmp_byte_R_RM,
11463 /* 0x3b */ x86emuOp_cmp_word_R_RM,
11464 /* 0x3c */ x86emuOp_cmp_byte_AL_IMM,
11465 /* 0x3d */ x86emuOp_cmp_word_AX_IMM,
11466 /* 0x3e */ x86emuOp_segovr_DS,
11467 /* 0x3f */ x86emuOp_aas,
11469 /* 0x40 */ x86emuOp_inc_AX,
11470 /* 0x41 */ x86emuOp_inc_CX,
11471 /* 0x42 */ x86emuOp_inc_DX,
11472 /* 0x43 */ x86emuOp_inc_BX,
11473 /* 0x44 */ x86emuOp_inc_SP,
11474 /* 0x45 */ x86emuOp_inc_BP,
11475 /* 0x46 */ x86emuOp_inc_SI,
11476 /* 0x47 */ x86emuOp_inc_DI,
11478 /* 0x48 */ x86emuOp_dec_AX,
11479 /* 0x49 */ x86emuOp_dec_CX,
11480 /* 0x4a */ x86emuOp_dec_DX,
11481 /* 0x4b */ x86emuOp_dec_BX,
11482 /* 0x4c */ x86emuOp_dec_SP,
11483 /* 0x4d */ x86emuOp_dec_BP,
11484 /* 0x4e */ x86emuOp_dec_SI,
11485 /* 0x4f */ x86emuOp_dec_DI,
11487 /* 0x50 */ x86emuOp_push_AX,
11488 /* 0x51 */ x86emuOp_push_CX,
11489 /* 0x52 */ x86emuOp_push_DX,
11490 /* 0x53 */ x86emuOp_push_BX,
11491 /* 0x54 */ x86emuOp_push_SP,
11492 /* 0x55 */ x86emuOp_push_BP,
11493 /* 0x56 */ x86emuOp_push_SI,
11494 /* 0x57 */ x86emuOp_push_DI,
11496 /* 0x58 */ x86emuOp_pop_AX,
11497 /* 0x59 */ x86emuOp_pop_CX,
11498 /* 0x5a */ x86emuOp_pop_DX,
11499 /* 0x5b */ x86emuOp_pop_BX,
11500 /* 0x5c */ x86emuOp_pop_SP,
11501 /* 0x5d */ x86emuOp_pop_BP,
11502 /* 0x5e */ x86emuOp_pop_SI,
11503 /* 0x5f */ x86emuOp_pop_DI,
11505 /* 0x60 */ x86emuOp_push_all,
11506 /* 0x61 */ x86emuOp_pop_all,
11507 /* 0x62 */ x86emuOp_illegal_op, /* bound */
11508 /* 0x63 */ x86emuOp_illegal_op, /* arpl */
11509 /* 0x64 */ x86emuOp_segovr_FS,
11510 /* 0x65 */ x86emuOp_segovr_GS,
11511 /* 0x66 */ x86emuOp_prefix_data,
11512 /* 0x67 */ x86emuOp_prefix_addr,
11514 /* 0x68 */ x86emuOp_push_word_IMM,
11515 /* 0x69 */ x86emuOp_imul_word_IMM,
11516 /* 0x6a */ x86emuOp_push_byte_IMM,
11517 /* 0x6b */ x86emuOp_imul_byte_IMM,
11518 /* 0x6c */ x86emuOp_ins_byte,
11519 /* 0x6d */ x86emuOp_ins_word,
11520 /* 0x6e */ x86emuOp_outs_byte,
11521 /* 0x6f */ x86emuOp_outs_word,
11523 /* 0x70 */ x86emuOp_jump_near_O,
11524 /* 0x71 */ x86emuOp_jump_near_NO,
11525 /* 0x72 */ x86emuOp_jump_near_B,
11526 /* 0x73 */ x86emuOp_jump_near_NB,
11527 /* 0x74 */ x86emuOp_jump_near_Z,
11528 /* 0x75 */ x86emuOp_jump_near_NZ,
11529 /* 0x76 */ x86emuOp_jump_near_BE,
11530 /* 0x77 */ x86emuOp_jump_near_NBE,
11532 /* 0x78 */ x86emuOp_jump_near_S,
11533 /* 0x79 */ x86emuOp_jump_near_NS,
11534 /* 0x7a */ x86emuOp_jump_near_P,
11535 /* 0x7b */ x86emuOp_jump_near_NP,
11536 /* 0x7c */ x86emuOp_jump_near_L,
11537 /* 0x7d */ x86emuOp_jump_near_NL,
11538 /* 0x7e */ x86emuOp_jump_near_LE,
11539 /* 0x7f */ x86emuOp_jump_near_NLE,
11541 /* 0x80 */ x86emuOp_opc80_byte_RM_IMM,
11542 /* 0x81 */ x86emuOp_opc81_word_RM_IMM,
11543 /* 0x82 */ x86emuOp_opc82_byte_RM_IMM,
11544 /* 0x83 */ x86emuOp_opc83_word_RM_IMM,
11545 /* 0x84 */ x86emuOp_test_byte_RM_R,
11546 /* 0x85 */ x86emuOp_test_word_RM_R,
11547 /* 0x86 */ x86emuOp_xchg_byte_RM_R,
11548 /* 0x87 */ x86emuOp_xchg_word_RM_R,
11550 /* 0x88 */ x86emuOp_mov_byte_RM_R,
11551 /* 0x89 */ x86emuOp_mov_word_RM_R,
11552 /* 0x8a */ x86emuOp_mov_byte_R_RM,
11553 /* 0x8b */ x86emuOp_mov_word_R_RM,
11554 /* 0x8c */ x86emuOp_mov_word_RM_SR,
11555 /* 0x8d */ x86emuOp_lea_word_R_M,
11556 /* 0x8e */ x86emuOp_mov_word_SR_RM,
11557 /* 0x8f */ x86emuOp_pop_RM,
11559 /* 0x90 */ x86emuOp_nop,
11560 /* 0x91 */ x86emuOp_xchg_word_AX_CX,
11561 /* 0x92 */ x86emuOp_xchg_word_AX_DX,
11562 /* 0x93 */ x86emuOp_xchg_word_AX_BX,
11563 /* 0x94 */ x86emuOp_xchg_word_AX_SP,
11564 /* 0x95 */ x86emuOp_xchg_word_AX_BP,
11565 /* 0x96 */ x86emuOp_xchg_word_AX_SI,
11566 /* 0x97 */ x86emuOp_xchg_word_AX_DI,
11568 /* 0x98 */ x86emuOp_cbw,
11569 /* 0x99 */ x86emuOp_cwd,
11570 /* 0x9a */ x86emuOp_call_far_IMM,
11571 /* 0x9b */ x86emuOp_wait,
11572 /* 0x9c */ x86emuOp_pushf_word,
11573 /* 0x9d */ x86emuOp_popf_word,
11574 /* 0x9e */ x86emuOp_sahf,
11575 /* 0x9f */ x86emuOp_lahf,
11577 /* 0xa0 */ x86emuOp_mov_AL_M_IMM,
11578 /* 0xa1 */ x86emuOp_mov_AX_M_IMM,
11579 /* 0xa2 */ x86emuOp_mov_M_AL_IMM,
11580 /* 0xa3 */ x86emuOp_mov_M_AX_IMM,
11581 /* 0xa4 */ x86emuOp_movs_byte,
11582 /* 0xa5 */ x86emuOp_movs_word,
11583 /* 0xa6 */ x86emuOp_cmps_byte,
11584 /* 0xa7 */ x86emuOp_cmps_word,
11585 /* 0xa8 */ x86emuOp_test_AL_IMM,
11586 /* 0xa9 */ x86emuOp_test_AX_IMM,
11587 /* 0xaa */ x86emuOp_stos_byte,
11588 /* 0xab */ x86emuOp_stos_word,
11589 /* 0xac */ x86emuOp_lods_byte,
11590 /* 0xad */ x86emuOp_lods_word,
11591 /* 0xac */ x86emuOp_scas_byte,
11592 /* 0xad */ x86emuOp_scas_word,
11595 /* 0xb0 */ x86emuOp_mov_byte_AL_IMM,
11596 /* 0xb1 */ x86emuOp_mov_byte_CL_IMM,
11597 /* 0xb2 */ x86emuOp_mov_byte_DL_IMM,
11598 /* 0xb3 */ x86emuOp_mov_byte_BL_IMM,
11599 /* 0xb4 */ x86emuOp_mov_byte_AH_IMM,
11600 /* 0xb5 */ x86emuOp_mov_byte_CH_IMM,
11601 /* 0xb6 */ x86emuOp_mov_byte_DH_IMM,
11602 /* 0xb7 */ x86emuOp_mov_byte_BH_IMM,
11604 /* 0xb8 */ x86emuOp_mov_word_AX_IMM,
11605 /* 0xb9 */ x86emuOp_mov_word_CX_IMM,
11606 /* 0xba */ x86emuOp_mov_word_DX_IMM,
11607 /* 0xbb */ x86emuOp_mov_word_BX_IMM,
11608 /* 0xbc */ x86emuOp_mov_word_SP_IMM,
11609 /* 0xbd */ x86emuOp_mov_word_BP_IMM,
11610 /* 0xbe */ x86emuOp_mov_word_SI_IMM,
11611 /* 0xbf */ x86emuOp_mov_word_DI_IMM,
11613 /* 0xc0 */ x86emuOp_opcC0_byte_RM_MEM,
11614 /* 0xc1 */ x86emuOp_opcC1_word_RM_MEM,
11615 /* 0xc2 */ x86emuOp_ret_near_IMM,
11616 /* 0xc3 */ x86emuOp_ret_near,
11617 /* 0xc4 */ x86emuOp_les_R_IMM,
11618 /* 0xc5 */ x86emuOp_lds_R_IMM,
11619 /* 0xc6 */ x86emuOp_mov_byte_RM_IMM,
11620 /* 0xc7 */ x86emuOp_mov_word_RM_IMM,
11621 /* 0xc8 */ x86emuOp_enter,
11622 /* 0xc9 */ x86emuOp_leave,
11623 /* 0xca */ x86emuOp_ret_far_IMM,
11624 /* 0xcb */ x86emuOp_ret_far,
11625 /* 0xcc */ x86emuOp_int3,
11626 /* 0xcd */ x86emuOp_int_IMM,
11627 /* 0xce */ x86emuOp_into,
11628 /* 0xcf */ x86emuOp_iret,
11630 /* 0xd0 */ x86emuOp_opcD0_byte_RM_1,
11631 /* 0xd1 */ x86emuOp_opcD1_word_RM_1,
11632 /* 0xd2 */ x86emuOp_opcD2_byte_RM_CL,
11633 /* 0xd3 */ x86emuOp_opcD3_word_RM_CL,
11634 /* 0xd4 */ x86emuOp_aam,
11635 /* 0xd5 */ x86emuOp_aad,
11636 /* 0xd6 */ x86emuOp_illegal_op, /* Undocumented SETALC instruction */
11637 /* 0xd7 */ x86emuOp_xlat,
11638 /* 0xd8 */ x86emuOp_esc_coprocess_d8,
11639 /* 0xd9 */ x86emuOp_esc_coprocess_d9,
11640 /* 0xda */ x86emuOp_esc_coprocess_da,
11641 /* 0xdb */ x86emuOp_esc_coprocess_db,
11642 /* 0xdc */ x86emuOp_esc_coprocess_dc,
11643 /* 0xdd */ x86emuOp_esc_coprocess_dd,
11644 /* 0xde */ x86emuOp_esc_coprocess_de,
11645 /* 0xdf */ x86emuOp_esc_coprocess_df,
11647 /* 0xe0 */ x86emuOp_loopne,
11648 /* 0xe1 */ x86emuOp_loope,
11649 /* 0xe2 */ x86emuOp_loop,
11650 /* 0xe3 */ x86emuOp_jcxz,
11651 /* 0xe4 */ x86emuOp_in_byte_AL_IMM,
11652 /* 0xe5 */ x86emuOp_in_word_AX_IMM,
11653 /* 0xe6 */ x86emuOp_out_byte_IMM_AL,
11654 /* 0xe7 */ x86emuOp_out_word_IMM_AX,
11656 /* 0xe8 */ x86emuOp_call_near_IMM,
11657 /* 0xe9 */ x86emuOp_jump_near_IMM,
11658 /* 0xea */ x86emuOp_jump_far_IMM,
11659 /* 0xeb */ x86emuOp_jump_byte_IMM,
11660 /* 0xec */ x86emuOp_in_byte_AL_DX,
11661 /* 0xed */ x86emuOp_in_word_AX_DX,
11662 /* 0xee */ x86emuOp_out_byte_DX_AL,
11663 /* 0xef */ x86emuOp_out_word_DX_AX,
11665 /* 0xf0 */ x86emuOp_lock,
11666 /* 0xf1 */ x86emuOp_illegal_op,
11667 /* 0xf2 */ x86emuOp_repne,
11668 /* 0xf3 */ x86emuOp_repe,
11669 /* 0xf4 */ x86emuOp_halt,
11670 /* 0xf5 */ x86emuOp_cmc,
11671 /* 0xf6 */ x86emuOp_opcF6_byte_RM,
11672 /* 0xf7 */ x86emuOp_opcF7_word_RM,
11674 /* 0xf8 */ x86emuOp_clc,
11675 /* 0xf9 */ x86emuOp_stc,
11676 /* 0xfa */ x86emuOp_cli,
11677 /* 0xfb */ x86emuOp_sti,
11678 /* 0xfc */ x86emuOp_cld,
11679 /* 0xfd */ x86emuOp_std,
11680 /* 0xfe */ x86emuOp_opcFE_byte_RM,
11681 /* 0xff */ x86emuOp_opcFF_word_RM,
11684 void tables_relocate(unsigned int offset)
11687 for (i=0; i<8; i++)
11689 opc80_byte_operation[i] -= offset;
11690 opc81_word_operation[i] -= offset;
11691 opc81_long_operation[i] -= offset;
11693 opc82_byte_operation[i] -= offset;
11694 opc83_word_operation[i] -= offset;
11695 opc83_long_operation[i] -= offset;
11697 opcD0_byte_operation[i] -= offset;
11698 opcD1_word_operation[i] -= offset;
11699 opcD1_long_operation[i] -= offset;