20 #include "x86emu/x86emui.h" 31 static void x86emuOp_illegal_op(u8 op1)
36 DECODE_PRINTF(
"ILLEGAL X86 OPCODE\n");
39 "%04x:%04x: %02X ILLEGAL X86 OPCODE!\n", M.x86.R_CS, M.x86.R_IP - 1,
60 static void x86emuOp_add_byte_RM_R(u8 X86EMU_UNUSED(op1))
68 DECODE_PRINTF(
"ADD\t");
69 FETCH_DECODE_MODRM(mod, rh, rl);
73 destoffset = decode_rm00_address(rl);
75 destval = fetch_data_byte(destoffset);
76 srcreg = DECODE_RM_BYTE_REGISTER(rh);
79 destval = add_byte(destval, *srcreg);
80 store_data_byte(destoffset, destval);
83 destoffset = decode_rm01_address(rl);
85 destval = fetch_data_byte(destoffset);
86 srcreg = DECODE_RM_BYTE_REGISTER(rh);
89 destval = add_byte(destval, *srcreg);
90 store_data_byte(destoffset, destval);
93 destoffset = decode_rm10_address(rl);
95 destval = fetch_data_byte(destoffset);
96 srcreg = DECODE_RM_BYTE_REGISTER(rh);
99 destval = add_byte(destval, *srcreg);
100 store_data_byte(destoffset, destval);
103 destreg = DECODE_RM_BYTE_REGISTER(rl);
105 srcreg = DECODE_RM_BYTE_REGISTER(rh);
108 *destreg = add_byte(*destreg, *srcreg);
111 DECODE_CLEAR_SEGOVR();
119 static void x86emuOp_add_word_RM_R(u8 X86EMU_UNUSED(op1))
125 DECODE_PRINTF(
"ADD\t");
126 FETCH_DECODE_MODRM(mod, rh, rl);
130 if (M.x86.mode & SYSMODE_PREFIX_DATA)
135 destoffset = decode_rm00_address(rl);
137 destval = fetch_data_long(destoffset);
138 srcreg = DECODE_RM_LONG_REGISTER(rh);
141 destval = add_long(destval, *srcreg);
142 store_data_long(destoffset, destval);
149 destoffset = decode_rm00_address(rl);
151 destval = fetch_data_word(destoffset);
152 srcreg = DECODE_RM_WORD_REGISTER(rh);
155 destval = add_word(destval, *srcreg);
156 store_data_word(destoffset, destval);
160 if (M.x86.mode & SYSMODE_PREFIX_DATA)
165 destoffset = decode_rm01_address(rl);
167 destval = fetch_data_long(destoffset);
168 srcreg = DECODE_RM_LONG_REGISTER(rh);
171 destval = add_long(destval, *srcreg);
172 store_data_long(destoffset, destval);
179 destoffset = decode_rm01_address(rl);
181 destval = fetch_data_word(destoffset);
182 srcreg = DECODE_RM_WORD_REGISTER(rh);
185 destval = add_word(destval, *srcreg);
186 store_data_word(destoffset, destval);
190 if (M.x86.mode & SYSMODE_PREFIX_DATA)
195 destoffset = decode_rm10_address(rl);
197 destval = fetch_data_long(destoffset);
198 srcreg = DECODE_RM_LONG_REGISTER(rh);
201 destval = add_long(destval, *srcreg);
202 store_data_long(destoffset, destval);
209 destoffset = decode_rm10_address(rl);
211 destval = fetch_data_word(destoffset);
212 srcreg = DECODE_RM_WORD_REGISTER(rh);
215 destval = add_word(destval, *srcreg);
216 store_data_word(destoffset, destval);
220 if (M.x86.mode & SYSMODE_PREFIX_DATA)
222 u32 *destreg, *srcreg;
224 destreg = DECODE_RM_LONG_REGISTER(rl);
226 srcreg = DECODE_RM_LONG_REGISTER(rh);
229 *destreg = add_long(*destreg, *srcreg);
233 u16 *destreg, *srcreg;
235 destreg = DECODE_RM_WORD_REGISTER(rl);
237 srcreg = DECODE_RM_WORD_REGISTER(rh);
240 *destreg = add_word(*destreg, *srcreg);
244 DECODE_CLEAR_SEGOVR();
252 static void x86emuOp_add_byte_R_RM(u8 X86EMU_UNUSED(op1))
255 u8 *destreg, *srcreg;
260 DECODE_PRINTF(
"ADD\t");
261 FETCH_DECODE_MODRM(mod, rh, rl);
265 destreg = DECODE_RM_BYTE_REGISTER(rh);
267 srcoffset = decode_rm00_address(rl);
268 srcval = fetch_data_byte(srcoffset);
271 *destreg = add_byte(*destreg, srcval);
274 destreg = DECODE_RM_BYTE_REGISTER(rh);
276 srcoffset = decode_rm01_address(rl);
277 srcval = fetch_data_byte(srcoffset);
280 *destreg = add_byte(*destreg, srcval);
283 destreg = DECODE_RM_BYTE_REGISTER(rh);
285 srcoffset = decode_rm10_address(rl);
286 srcval = fetch_data_byte(srcoffset);
289 *destreg = add_byte(*destreg, srcval);
292 destreg = DECODE_RM_BYTE_REGISTER(rh);
294 srcreg = DECODE_RM_BYTE_REGISTER(rl);
297 *destreg = add_byte(*destreg, *srcreg);
300 DECODE_CLEAR_SEGOVR();
308 static void x86emuOp_add_word_R_RM(u8 X86EMU_UNUSED(op1))
314 DECODE_PRINTF(
"ADD\t");
315 FETCH_DECODE_MODRM(mod, rh, rl);
319 if (M.x86.mode & SYSMODE_PREFIX_DATA)
324 destreg = DECODE_RM_LONG_REGISTER(rh);
326 srcoffset = decode_rm00_address(rl);
327 srcval = fetch_data_long(srcoffset);
330 *destreg = add_long(*destreg, srcval);
337 destreg = DECODE_RM_WORD_REGISTER(rh);
339 srcoffset = decode_rm00_address(rl);
340 srcval = fetch_data_word(srcoffset);
343 *destreg = add_word(*destreg, srcval);
347 if (M.x86.mode & SYSMODE_PREFIX_DATA)
352 destreg = DECODE_RM_LONG_REGISTER(rh);
354 srcoffset = decode_rm01_address(rl);
355 srcval = fetch_data_long(srcoffset);
358 *destreg = add_long(*destreg, srcval);
365 destreg = DECODE_RM_WORD_REGISTER(rh);
367 srcoffset = decode_rm01_address(rl);
368 srcval = fetch_data_word(srcoffset);
371 *destreg = add_word(*destreg, srcval);
375 if (M.x86.mode & SYSMODE_PREFIX_DATA)
380 destreg = DECODE_RM_LONG_REGISTER(rh);
382 srcoffset = decode_rm10_address(rl);
383 srcval = fetch_data_long(srcoffset);
386 *destreg = add_long(*destreg, srcval);
393 destreg = DECODE_RM_WORD_REGISTER(rh);
395 srcoffset = decode_rm10_address(rl);
396 srcval = fetch_data_word(srcoffset);
399 *destreg = add_word(*destreg, srcval);
403 if (M.x86.mode & SYSMODE_PREFIX_DATA)
405 u32 *destreg, *srcreg;
407 destreg = DECODE_RM_LONG_REGISTER(rh);
409 srcreg = DECODE_RM_LONG_REGISTER(rl);
412 *destreg = add_long(*destreg, *srcreg);
416 u16 *destreg, *srcreg;
418 destreg = DECODE_RM_WORD_REGISTER(rh);
420 srcreg = DECODE_RM_WORD_REGISTER(rl);
423 *destreg = add_word(*destreg, *srcreg);
427 DECODE_CLEAR_SEGOVR();
435 static void x86emuOp_add_byte_AL_IMM(u8 X86EMU_UNUSED(op1))
440 DECODE_PRINTF(
"ADD\tAL,");
441 srcval = fetch_byte_imm();
442 DECODE_PRINTF2(
"%x\n", srcval);
444 M.x86.R_AL = add_byte(M.x86.R_AL, srcval);
445 DECODE_CLEAR_SEGOVR();
453 static void x86emuOp_add_word_AX_IMM(u8 X86EMU_UNUSED(op1))
458 if (M.x86.mode & SYSMODE_PREFIX_DATA)
460 DECODE_PRINTF(
"ADD\tEAX,");
461 srcval = fetch_long_imm();
465 DECODE_PRINTF(
"ADD\tAX,");
466 srcval = fetch_word_imm();
468 DECODE_PRINTF2(
"%x\n", srcval);
470 if (M.x86.mode & SYSMODE_PREFIX_DATA)
472 M.x86.R_EAX = add_long(M.x86.R_EAX, srcval);
476 M.x86.R_AX = add_word(M.x86.R_AX, (u16) srcval);
478 DECODE_CLEAR_SEGOVR();
486 static void x86emuOp_push_ES(u8 X86EMU_UNUSED(op1))
489 DECODE_PRINTF(
"PUSH\tES\n");
491 push_word(M.x86.R_ES);
492 DECODE_CLEAR_SEGOVR();
500 static void x86emuOp_pop_ES(u8 X86EMU_UNUSED(op1))
503 DECODE_PRINTF(
"POP\tES\n");
505 M.x86.R_ES = pop_word();
506 DECODE_CLEAR_SEGOVR();
514 static void x86emuOp_or_byte_RM_R(u8 X86EMU_UNUSED(op1))
517 u8 *destreg, *srcreg;
522 DECODE_PRINTF(
"OR\t");
523 FETCH_DECODE_MODRM(mod, rh, rl);
527 destoffset = decode_rm00_address(rl);
529 destval = fetch_data_byte(destoffset);
530 srcreg = DECODE_RM_BYTE_REGISTER(rh);
533 destval = or_byte(destval, *srcreg);
534 store_data_byte(destoffset, destval);
537 destoffset = decode_rm01_address(rl);
539 destval = fetch_data_byte(destoffset);
540 srcreg = DECODE_RM_BYTE_REGISTER(rh);
543 destval = or_byte(destval, *srcreg);
544 store_data_byte(destoffset, destval);
547 destoffset = decode_rm10_address(rl);
549 destval = fetch_data_byte(destoffset);
550 srcreg = DECODE_RM_BYTE_REGISTER(rh);
553 destval = or_byte(destval, *srcreg);
554 store_data_byte(destoffset, destval);
557 destreg = DECODE_RM_BYTE_REGISTER(rl);
559 srcreg = DECODE_RM_BYTE_REGISTER(rh);
562 *destreg = or_byte(*destreg, *srcreg);
565 DECODE_CLEAR_SEGOVR();
573 static void x86emuOp_or_word_RM_R(u8 X86EMU_UNUSED(op1))
579 DECODE_PRINTF(
"OR\t");
580 FETCH_DECODE_MODRM(mod, rh, rl);
584 if (M.x86.mode & SYSMODE_PREFIX_DATA)
589 destoffset = decode_rm00_address(rl);
591 destval = fetch_data_long(destoffset);
592 srcreg = DECODE_RM_LONG_REGISTER(rh);
595 destval = or_long(destval, *srcreg);
596 store_data_long(destoffset, destval);
603 destoffset = decode_rm00_address(rl);
605 destval = fetch_data_word(destoffset);
606 srcreg = DECODE_RM_WORD_REGISTER(rh);
609 destval = or_word(destval, *srcreg);
610 store_data_word(destoffset, destval);
614 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);
633 destoffset = decode_rm01_address(rl);
635 destval = fetch_data_word(destoffset);
636 srcreg = DECODE_RM_WORD_REGISTER(rh);
639 destval = or_word(destval, *srcreg);
640 store_data_word(destoffset, destval);
644 if (M.x86.mode & SYSMODE_PREFIX_DATA)
649 destoffset = decode_rm10_address(rl);
651 destval = fetch_data_long(destoffset);
652 srcreg = DECODE_RM_LONG_REGISTER(rh);
655 destval = or_long(destval, *srcreg);
656 store_data_long(destoffset, destval);
663 destoffset = decode_rm10_address(rl);
665 destval = fetch_data_word(destoffset);
666 srcreg = DECODE_RM_WORD_REGISTER(rh);
669 destval = or_word(destval, *srcreg);
670 store_data_word(destoffset, destval);
674 if (M.x86.mode & SYSMODE_PREFIX_DATA)
676 u32 *destreg, *srcreg;
678 destreg = DECODE_RM_LONG_REGISTER(rl);
680 srcreg = DECODE_RM_LONG_REGISTER(rh);
683 *destreg = or_long(*destreg, *srcreg);
687 u16 *destreg, *srcreg;
689 destreg = DECODE_RM_WORD_REGISTER(rl);
691 srcreg = DECODE_RM_WORD_REGISTER(rh);
694 *destreg = or_word(*destreg, *srcreg);
698 DECODE_CLEAR_SEGOVR();
706 static void x86emuOp_or_byte_R_RM(u8 X86EMU_UNUSED(op1))
709 u8 *destreg, *srcreg;
714 DECODE_PRINTF(
"OR\t");
715 FETCH_DECODE_MODRM(mod, rh, rl);
719 destreg = DECODE_RM_BYTE_REGISTER(rh);
721 srcoffset = decode_rm00_address(rl);
722 srcval = fetch_data_byte(srcoffset);
725 *destreg = or_byte(*destreg, srcval);
728 destreg = DECODE_RM_BYTE_REGISTER(rh);
730 srcoffset = decode_rm01_address(rl);
731 srcval = fetch_data_byte(srcoffset);
734 *destreg = or_byte(*destreg, srcval);
737 destreg = DECODE_RM_BYTE_REGISTER(rh);
739 srcoffset = decode_rm10_address(rl);
740 srcval = fetch_data_byte(srcoffset);
743 *destreg = or_byte(*destreg, srcval);
746 destreg = DECODE_RM_BYTE_REGISTER(rh);
748 srcreg = DECODE_RM_BYTE_REGISTER(rl);
751 *destreg = or_byte(*destreg, *srcreg);
754 DECODE_CLEAR_SEGOVR();
762 static void x86emuOp_or_word_R_RM(u8 X86EMU_UNUSED(op1))
768 DECODE_PRINTF(
"OR\t");
769 FETCH_DECODE_MODRM(mod, rh, rl);
773 if (M.x86.mode & SYSMODE_PREFIX_DATA)
778 destreg = DECODE_RM_LONG_REGISTER(rh);
780 srcoffset = decode_rm00_address(rl);
781 srcval = fetch_data_long(srcoffset);
784 *destreg = or_long(*destreg, srcval);
791 destreg = DECODE_RM_WORD_REGISTER(rh);
793 srcoffset = decode_rm00_address(rl);
794 srcval = fetch_data_word(srcoffset);
797 *destreg = or_word(*destreg, srcval);
801 if (M.x86.mode & SYSMODE_PREFIX_DATA)
806 destreg = DECODE_RM_LONG_REGISTER(rh);
808 srcoffset = decode_rm01_address(rl);
809 srcval = fetch_data_long(srcoffset);
812 *destreg = or_long(*destreg, srcval);
819 destreg = DECODE_RM_WORD_REGISTER(rh);
821 srcoffset = decode_rm01_address(rl);
822 srcval = fetch_data_word(srcoffset);
825 *destreg = or_word(*destreg, srcval);
829 if (M.x86.mode & SYSMODE_PREFIX_DATA)
834 destreg = DECODE_RM_LONG_REGISTER(rh);
836 srcoffset = decode_rm10_address(rl);
837 srcval = fetch_data_long(srcoffset);
840 *destreg = or_long(*destreg, srcval);
847 destreg = DECODE_RM_WORD_REGISTER(rh);
849 srcoffset = decode_rm10_address(rl);
850 srcval = fetch_data_word(srcoffset);
853 *destreg = or_word(*destreg, srcval);
857 if (M.x86.mode & SYSMODE_PREFIX_DATA)
859 u32 *destreg, *srcreg;
861 destreg = DECODE_RM_LONG_REGISTER(rh);
863 srcreg = DECODE_RM_LONG_REGISTER(rl);
866 *destreg = or_long(*destreg, *srcreg);
870 u16 *destreg, *srcreg;
872 destreg = DECODE_RM_WORD_REGISTER(rh);
874 srcreg = DECODE_RM_WORD_REGISTER(rl);
877 *destreg = or_word(*destreg, *srcreg);
881 DECODE_CLEAR_SEGOVR();
889 static void x86emuOp_or_byte_AL_IMM(u8 X86EMU_UNUSED(op1))
894 DECODE_PRINTF(
"OR\tAL,");
895 srcval = fetch_byte_imm();
896 DECODE_PRINTF2(
"%x\n", srcval);
898 M.x86.R_AL = or_byte(M.x86.R_AL, srcval);
899 DECODE_CLEAR_SEGOVR();
907 static void x86emuOp_or_word_AX_IMM(u8 X86EMU_UNUSED(op1))
912 if (M.x86.mode & SYSMODE_PREFIX_DATA)
914 DECODE_PRINTF(
"OR\tEAX,");
915 srcval = fetch_long_imm();
919 DECODE_PRINTF(
"OR\tAX,");
920 srcval = fetch_word_imm();
922 DECODE_PRINTF2(
"%x\n", srcval);
924 if (M.x86.mode & SYSMODE_PREFIX_DATA)
926 M.x86.R_EAX = or_long(M.x86.R_EAX, srcval);
930 M.x86.R_AX = or_word(M.x86.R_AX, (u16) srcval);
932 DECODE_CLEAR_SEGOVR();
940 static void x86emuOp_push_CS(u8 X86EMU_UNUSED(op1))
943 DECODE_PRINTF(
"PUSH\tCS\n");
945 push_word(M.x86.R_CS);
946 DECODE_CLEAR_SEGOVR();
954 static void x86emuOp_two_byte(u8 X86EMU_UNUSED(op1))
956 u8 op2 = (*sys_rdb)(((u32) M.x86.R_CS << 4) + (M.x86.R_IP++));
957 INC_DECODED_INST_LEN(1);
958 (*x86emu_optab2[op2])(op2);
965 static void x86emuOp_adc_byte_RM_R(u8 X86EMU_UNUSED(op1))
968 u8 *destreg, *srcreg;
973 DECODE_PRINTF(
"ADC\t");
974 FETCH_DECODE_MODRM(mod, rh, rl);
978 destoffset = decode_rm00_address(rl);
980 destval = fetch_data_byte(destoffset);
981 srcreg = DECODE_RM_BYTE_REGISTER(rh);
984 destval = adc_byte(destval, *srcreg);
985 store_data_byte(destoffset, destval);
988 destoffset = decode_rm01_address(rl);
990 destval = fetch_data_byte(destoffset);
991 srcreg = DECODE_RM_BYTE_REGISTER(rh);
994 destval = adc_byte(destval, *srcreg);
995 store_data_byte(destoffset, destval);
998 destoffset = decode_rm10_address(rl);
1000 destval = fetch_data_byte(destoffset);
1001 srcreg = DECODE_RM_BYTE_REGISTER(rh);
1002 DECODE_PRINTF(
"\n");
1004 destval = adc_byte(destval, *srcreg);
1005 store_data_byte(destoffset, destval);
1008 destreg = DECODE_RM_BYTE_REGISTER(rl);
1010 srcreg = DECODE_RM_BYTE_REGISTER(rh);
1011 DECODE_PRINTF(
"\n");
1013 *destreg = adc_byte(*destreg, *srcreg);
1016 DECODE_CLEAR_SEGOVR();
1024 static void x86emuOp_adc_word_RM_R(u8 X86EMU_UNUSED(op1))
1030 DECODE_PRINTF(
"ADC\t");
1031 FETCH_DECODE_MODRM(mod, rh, rl);
1035 if (M.x86.mode & SYSMODE_PREFIX_DATA)
1040 destoffset = decode_rm00_address(rl);
1042 destval = fetch_data_long(destoffset);
1043 srcreg = DECODE_RM_LONG_REGISTER(rh);
1044 DECODE_PRINTF(
"\n");
1046 destval = adc_long(destval, *srcreg);
1047 store_data_long(destoffset, destval);
1054 destoffset = decode_rm00_address(rl);
1056 destval = fetch_data_word(destoffset);
1057 srcreg = DECODE_RM_WORD_REGISTER(rh);
1058 DECODE_PRINTF(
"\n");
1060 destval = adc_word(destval, *srcreg);
1061 store_data_word(destoffset, destval);
1065 if (M.x86.mode & SYSMODE_PREFIX_DATA)
1070 destoffset = decode_rm01_address(rl);
1072 destval = fetch_data_long(destoffset);
1073 srcreg = DECODE_RM_LONG_REGISTER(rh);
1074 DECODE_PRINTF(
"\n");
1076 destval = adc_long(destval, *srcreg);
1077 store_data_long(destoffset, destval);
1084 destoffset = decode_rm01_address(rl);
1086 destval = fetch_data_word(destoffset);
1087 srcreg = DECODE_RM_WORD_REGISTER(rh);
1088 DECODE_PRINTF(
"\n");
1090 destval = adc_word(destval, *srcreg);
1091 store_data_word(destoffset, destval);
1095 if (M.x86.mode & SYSMODE_PREFIX_DATA)
1100 destoffset = decode_rm10_address(rl);
1102 destval = fetch_data_long(destoffset);
1103 srcreg = DECODE_RM_LONG_REGISTER(rh);
1104 DECODE_PRINTF(
"\n");
1106 destval = adc_long(destval, *srcreg);
1107 store_data_long(destoffset, destval);
1114 destoffset = decode_rm10_address(rl);
1116 destval = fetch_data_word(destoffset);
1117 srcreg = DECODE_RM_WORD_REGISTER(rh);
1118 DECODE_PRINTF(
"\n");
1120 destval = adc_word(destval, *srcreg);
1121 store_data_word(destoffset, destval);
1125 if (M.x86.mode & SYSMODE_PREFIX_DATA)
1127 u32 *destreg, *srcreg;
1129 destreg = DECODE_RM_LONG_REGISTER(rl);
1131 srcreg = DECODE_RM_LONG_REGISTER(rh);
1132 DECODE_PRINTF(
"\n");
1134 *destreg = adc_long(*destreg, *srcreg);
1138 u16 *destreg, *srcreg;
1140 destreg = DECODE_RM_WORD_REGISTER(rl);
1142 srcreg = DECODE_RM_WORD_REGISTER(rh);
1143 DECODE_PRINTF(
"\n");
1145 *destreg = adc_word(*destreg, *srcreg);
1149 DECODE_CLEAR_SEGOVR();
1157 static void x86emuOp_adc_byte_R_RM(u8 X86EMU_UNUSED(op1))
1160 u8 *destreg, *srcreg;
1165 DECODE_PRINTF(
"ADC\t");
1166 FETCH_DECODE_MODRM(mod, rh, rl);
1170 destreg = DECODE_RM_BYTE_REGISTER(rh);
1172 srcoffset = decode_rm00_address(rl);
1173 srcval = fetch_data_byte(srcoffset);
1174 DECODE_PRINTF(
"\n");
1176 *destreg = adc_byte(*destreg, srcval);
1179 destreg = DECODE_RM_BYTE_REGISTER(rh);
1181 srcoffset = decode_rm01_address(rl);
1182 srcval = fetch_data_byte(srcoffset);
1183 DECODE_PRINTF(
"\n");
1185 *destreg = adc_byte(*destreg, srcval);
1188 destreg = DECODE_RM_BYTE_REGISTER(rh);
1190 srcoffset = decode_rm10_address(rl);
1191 srcval = fetch_data_byte(srcoffset);
1192 DECODE_PRINTF(
"\n");
1194 *destreg = adc_byte(*destreg, srcval);
1197 destreg = DECODE_RM_BYTE_REGISTER(rh);
1199 srcreg = DECODE_RM_BYTE_REGISTER(rl);
1200 DECODE_PRINTF(
"\n");
1202 *destreg = adc_byte(*destreg, *srcreg);
1205 DECODE_CLEAR_SEGOVR();
1213 static void x86emuOp_adc_word_R_RM(u8 X86EMU_UNUSED(op1))
1219 DECODE_PRINTF(
"ADC\t");
1220 FETCH_DECODE_MODRM(mod, rh, rl);
1224 if (M.x86.mode & SYSMODE_PREFIX_DATA)
1229 destreg = DECODE_RM_LONG_REGISTER(rh);
1231 srcoffset = decode_rm00_address(rl);
1232 srcval = fetch_data_long(srcoffset);
1233 DECODE_PRINTF(
"\n");
1235 *destreg = adc_long(*destreg, srcval);
1242 destreg = DECODE_RM_WORD_REGISTER(rh);
1244 srcoffset = decode_rm00_address(rl);
1245 srcval = fetch_data_word(srcoffset);
1246 DECODE_PRINTF(
"\n");
1248 *destreg = adc_word(*destreg, srcval);
1252 if (M.x86.mode & SYSMODE_PREFIX_DATA)
1257 destreg = DECODE_RM_LONG_REGISTER(rh);
1259 srcoffset = decode_rm01_address(rl);
1260 srcval = fetch_data_long(srcoffset);
1261 DECODE_PRINTF(
"\n");
1263 *destreg = adc_long(*destreg, srcval);
1270 destreg = DECODE_RM_WORD_REGISTER(rh);
1272 srcoffset = decode_rm01_address(rl);
1273 srcval = fetch_data_word(srcoffset);
1274 DECODE_PRINTF(
"\n");
1276 *destreg = adc_word(*destreg, srcval);
1280 if (M.x86.mode & SYSMODE_PREFIX_DATA)
1285 destreg = DECODE_RM_LONG_REGISTER(rh);
1287 srcoffset = decode_rm10_address(rl);
1288 srcval = fetch_data_long(srcoffset);
1289 DECODE_PRINTF(
"\n");
1291 *destreg = adc_long(*destreg, srcval);
1298 destreg = DECODE_RM_WORD_REGISTER(rh);
1300 srcoffset = decode_rm10_address(rl);
1301 srcval = fetch_data_word(srcoffset);
1302 DECODE_PRINTF(
"\n");
1304 *destreg = adc_word(*destreg, srcval);
1308 if (M.x86.mode & SYSMODE_PREFIX_DATA)
1310 u32 *destreg, *srcreg;
1312 destreg = DECODE_RM_LONG_REGISTER(rh);
1314 srcreg = DECODE_RM_LONG_REGISTER(rl);
1315 DECODE_PRINTF(
"\n");
1317 *destreg = adc_long(*destreg, *srcreg);
1321 u16 *destreg, *srcreg;
1323 destreg = DECODE_RM_WORD_REGISTER(rh);
1325 srcreg = DECODE_RM_WORD_REGISTER(rl);
1326 DECODE_PRINTF(
"\n");
1328 *destreg = adc_word(*destreg, *srcreg);
1332 DECODE_CLEAR_SEGOVR();
1340 static void x86emuOp_adc_byte_AL_IMM(u8 X86EMU_UNUSED(op1))
1345 DECODE_PRINTF(
"ADC\tAL,");
1346 srcval = fetch_byte_imm();
1347 DECODE_PRINTF2(
"%x\n", srcval);
1349 M.x86.R_AL = adc_byte(M.x86.R_AL, srcval);
1350 DECODE_CLEAR_SEGOVR();
1358 static void x86emuOp_adc_word_AX_IMM(u8 X86EMU_UNUSED(op1))
1363 if (M.x86.mode & SYSMODE_PREFIX_DATA)
1365 DECODE_PRINTF(
"ADC\tEAX,");
1366 srcval = fetch_long_imm();
1370 DECODE_PRINTF(
"ADC\tAX,");
1371 srcval = fetch_word_imm();
1373 DECODE_PRINTF2(
"%x\n", srcval);
1375 if (M.x86.mode & SYSMODE_PREFIX_DATA)
1377 M.x86.R_EAX = adc_long(M.x86.R_EAX, srcval);
1381 M.x86.R_AX = adc_word(M.x86.R_AX, (u16) srcval);
1383 DECODE_CLEAR_SEGOVR();
1391 static void x86emuOp_push_SS(u8 X86EMU_UNUSED(op1))
1394 DECODE_PRINTF(
"PUSH\tSS\n");
1396 push_word(M.x86.R_SS);
1397 DECODE_CLEAR_SEGOVR();
1405 static void x86emuOp_pop_SS(u8 X86EMU_UNUSED(op1))
1408 DECODE_PRINTF(
"POP\tSS\n");
1410 M.x86.R_SS = pop_word();
1411 DECODE_CLEAR_SEGOVR();
1419 static void x86emuOp_sbb_byte_RM_R(u8 X86EMU_UNUSED(op1))
1422 u8 *destreg, *srcreg;
1427 DECODE_PRINTF(
"SBB\t");
1428 FETCH_DECODE_MODRM(mod, rh, rl);
1432 destoffset = decode_rm00_address(rl);
1434 destval = fetch_data_byte(destoffset);
1435 srcreg = DECODE_RM_BYTE_REGISTER(rh);
1436 DECODE_PRINTF(
"\n");
1438 destval = sbb_byte(destval, *srcreg);
1439 store_data_byte(destoffset, destval);
1442 destoffset = decode_rm01_address(rl);
1444 destval = fetch_data_byte(destoffset);
1445 srcreg = DECODE_RM_BYTE_REGISTER(rh);
1446 DECODE_PRINTF(
"\n");
1448 destval = sbb_byte(destval, *srcreg);
1449 store_data_byte(destoffset, destval);
1452 destoffset = decode_rm10_address(rl);
1454 destval = fetch_data_byte(destoffset);
1455 srcreg = DECODE_RM_BYTE_REGISTER(rh);
1456 DECODE_PRINTF(
"\n");
1458 destval = sbb_byte(destval, *srcreg);
1459 store_data_byte(destoffset, destval);
1462 destreg = DECODE_RM_BYTE_REGISTER(rl);
1464 srcreg = DECODE_RM_BYTE_REGISTER(rh);
1465 DECODE_PRINTF(
"\n");
1467 *destreg = sbb_byte(*destreg, *srcreg);
1470 DECODE_CLEAR_SEGOVR();
1478 static void x86emuOp_sbb_word_RM_R(u8 X86EMU_UNUSED(op1))
1484 DECODE_PRINTF(
"SBB\t");
1485 FETCH_DECODE_MODRM(mod, rh, rl);
1489 if (M.x86.mode & SYSMODE_PREFIX_DATA)
1494 destoffset = decode_rm00_address(rl);
1496 destval = fetch_data_long(destoffset);
1497 srcreg = DECODE_RM_LONG_REGISTER(rh);
1498 DECODE_PRINTF(
"\n");
1500 destval = sbb_long(destval, *srcreg);
1501 store_data_long(destoffset, destval);
1508 destoffset = decode_rm00_address(rl);
1510 destval = fetch_data_word(destoffset);
1511 srcreg = DECODE_RM_WORD_REGISTER(rh);
1512 DECODE_PRINTF(
"\n");
1514 destval = sbb_word(destval, *srcreg);
1515 store_data_word(destoffset, destval);
1519 if (M.x86.mode & SYSMODE_PREFIX_DATA)
1524 destoffset = decode_rm01_address(rl);
1526 destval = fetch_data_long(destoffset);
1527 srcreg = DECODE_RM_LONG_REGISTER(rh);
1528 DECODE_PRINTF(
"\n");
1530 destval = sbb_long(destval, *srcreg);
1531 store_data_long(destoffset, destval);
1538 destoffset = decode_rm01_address(rl);
1540 destval = fetch_data_word(destoffset);
1541 srcreg = DECODE_RM_WORD_REGISTER(rh);
1542 DECODE_PRINTF(
"\n");
1544 destval = sbb_word(destval, *srcreg);
1545 store_data_word(destoffset, destval);
1549 if (M.x86.mode & SYSMODE_PREFIX_DATA)
1554 destoffset = decode_rm10_address(rl);
1556 destval = fetch_data_long(destoffset);
1557 srcreg = DECODE_RM_LONG_REGISTER(rh);
1558 DECODE_PRINTF(
"\n");
1560 destval = sbb_long(destval, *srcreg);
1561 store_data_long(destoffset, destval);
1568 destoffset = decode_rm10_address(rl);
1570 destval = fetch_data_word(destoffset);
1571 srcreg = DECODE_RM_WORD_REGISTER(rh);
1572 DECODE_PRINTF(
"\n");
1574 destval = sbb_word(destval, *srcreg);
1575 store_data_word(destoffset, destval);
1579 if (M.x86.mode & SYSMODE_PREFIX_DATA)
1581 u32 *destreg, *srcreg;
1583 destreg = DECODE_RM_LONG_REGISTER(rl);
1585 srcreg = DECODE_RM_LONG_REGISTER(rh);
1586 DECODE_PRINTF(
"\n");
1588 *destreg = sbb_long(*destreg, *srcreg);
1592 u16 *destreg, *srcreg;
1594 destreg = DECODE_RM_WORD_REGISTER(rl);
1596 srcreg = DECODE_RM_WORD_REGISTER(rh);
1597 DECODE_PRINTF(
"\n");
1599 *destreg = sbb_word(*destreg, *srcreg);
1603 DECODE_CLEAR_SEGOVR();
1611 static void x86emuOp_sbb_byte_R_RM(u8 X86EMU_UNUSED(op1))
1614 u8 *destreg, *srcreg;
1619 DECODE_PRINTF(
"SBB\t");
1620 FETCH_DECODE_MODRM(mod, rh, rl);
1624 destreg = DECODE_RM_BYTE_REGISTER(rh);
1626 srcoffset = decode_rm00_address(rl);
1627 srcval = fetch_data_byte(srcoffset);
1628 DECODE_PRINTF(
"\n");
1630 *destreg = sbb_byte(*destreg, srcval);
1633 destreg = DECODE_RM_BYTE_REGISTER(rh);
1635 srcoffset = decode_rm01_address(rl);
1636 srcval = fetch_data_byte(srcoffset);
1637 DECODE_PRINTF(
"\n");
1639 *destreg = sbb_byte(*destreg, srcval);
1642 destreg = DECODE_RM_BYTE_REGISTER(rh);
1644 srcoffset = decode_rm10_address(rl);
1645 srcval = fetch_data_byte(srcoffset);
1646 DECODE_PRINTF(
"\n");
1648 *destreg = sbb_byte(*destreg, srcval);
1651 destreg = DECODE_RM_BYTE_REGISTER(rh);
1653 srcreg = DECODE_RM_BYTE_REGISTER(rl);
1654 DECODE_PRINTF(
"\n");
1656 *destreg = sbb_byte(*destreg, *srcreg);
1659 DECODE_CLEAR_SEGOVR();
1667 static void x86emuOp_sbb_word_R_RM(u8 X86EMU_UNUSED(op1))
1673 DECODE_PRINTF(
"SBB\t");
1674 FETCH_DECODE_MODRM(mod, rh, rl);
1678 if (M.x86.mode & SYSMODE_PREFIX_DATA)
1683 destreg = DECODE_RM_LONG_REGISTER(rh);
1685 srcoffset = decode_rm00_address(rl);
1686 srcval = fetch_data_long(srcoffset);
1687 DECODE_PRINTF(
"\n");
1689 *destreg = sbb_long(*destreg, srcval);
1696 destreg = DECODE_RM_WORD_REGISTER(rh);
1698 srcoffset = decode_rm00_address(rl);
1699 srcval = fetch_data_word(srcoffset);
1700 DECODE_PRINTF(
"\n");
1702 *destreg = sbb_word(*destreg, srcval);
1706 if (M.x86.mode & SYSMODE_PREFIX_DATA)
1711 destreg = DECODE_RM_LONG_REGISTER(rh);
1713 srcoffset = decode_rm01_address(rl);
1714 srcval = fetch_data_long(srcoffset);
1715 DECODE_PRINTF(
"\n");
1717 *destreg = sbb_long(*destreg, srcval);
1724 destreg = DECODE_RM_WORD_REGISTER(rh);
1726 srcoffset = decode_rm01_address(rl);
1727 srcval = fetch_data_word(srcoffset);
1728 DECODE_PRINTF(
"\n");
1730 *destreg = sbb_word(*destreg, srcval);
1734 if (M.x86.mode & SYSMODE_PREFIX_DATA)
1739 destreg = DECODE_RM_LONG_REGISTER(rh);
1741 srcoffset = decode_rm10_address(rl);
1742 srcval = fetch_data_long(srcoffset);
1743 DECODE_PRINTF(
"\n");
1745 *destreg = sbb_long(*destreg, srcval);
1752 destreg = DECODE_RM_WORD_REGISTER(rh);
1754 srcoffset = decode_rm10_address(rl);
1755 srcval = fetch_data_word(srcoffset);
1756 DECODE_PRINTF(
"\n");
1758 *destreg = sbb_word(*destreg, srcval);
1762 if (M.x86.mode & SYSMODE_PREFIX_DATA)
1764 u32 *destreg, *srcreg;
1766 destreg = DECODE_RM_LONG_REGISTER(rh);
1768 srcreg = DECODE_RM_LONG_REGISTER(rl);
1769 DECODE_PRINTF(
"\n");
1771 *destreg = sbb_long(*destreg, *srcreg);
1775 u16 *destreg, *srcreg;
1777 destreg = DECODE_RM_WORD_REGISTER(rh);
1779 srcreg = DECODE_RM_WORD_REGISTER(rl);
1780 DECODE_PRINTF(
"\n");
1782 *destreg = sbb_word(*destreg, *srcreg);
1786 DECODE_CLEAR_SEGOVR();
1794 static void x86emuOp_sbb_byte_AL_IMM(u8 X86EMU_UNUSED(op1))
1799 DECODE_PRINTF(
"SBB\tAL,");
1800 srcval = fetch_byte_imm();
1801 DECODE_PRINTF2(
"%x\n", srcval);
1803 M.x86.R_AL = sbb_byte(M.x86.R_AL, srcval);
1804 DECODE_CLEAR_SEGOVR();
1812 static void x86emuOp_sbb_word_AX_IMM(u8 X86EMU_UNUSED(op1))
1817 if (M.x86.mode & SYSMODE_PREFIX_DATA)
1819 DECODE_PRINTF(
"SBB\tEAX,");
1820 srcval = fetch_long_imm();
1824 DECODE_PRINTF(
"SBB\tAX,");
1825 srcval = fetch_word_imm();
1827 DECODE_PRINTF2(
"%x\n", srcval);
1829 if (M.x86.mode & SYSMODE_PREFIX_DATA)
1831 M.x86.R_EAX = sbb_long(M.x86.R_EAX, srcval);
1835 M.x86.R_AX = sbb_word(M.x86.R_AX, (u16) srcval);
1837 DECODE_CLEAR_SEGOVR();
1845 static void x86emuOp_push_DS(u8 X86EMU_UNUSED(op1))
1848 DECODE_PRINTF(
"PUSH\tDS\n");
1850 push_word(M.x86.R_DS);
1851 DECODE_CLEAR_SEGOVR();
1859 static void x86emuOp_pop_DS(u8 X86EMU_UNUSED(op1))
1862 DECODE_PRINTF(
"POP\tDS\n");
1864 M.x86.R_DS = pop_word();
1865 DECODE_CLEAR_SEGOVR();
1873 static void x86emuOp_and_byte_RM_R(u8 X86EMU_UNUSED(op1))
1876 u8 *destreg, *srcreg;
1881 DECODE_PRINTF(
"AND\t");
1882 FETCH_DECODE_MODRM(mod, rh, rl);
1887 destoffset = decode_rm00_address(rl);
1889 destval = fetch_data_byte(destoffset);
1890 srcreg = DECODE_RM_BYTE_REGISTER(rh);
1891 DECODE_PRINTF(
"\n");
1893 destval = and_byte(destval, *srcreg);
1894 store_data_byte(destoffset, destval);
1898 destoffset = decode_rm01_address(rl);
1900 destval = fetch_data_byte(destoffset);
1901 srcreg = DECODE_RM_BYTE_REGISTER(rh);
1902 DECODE_PRINTF(
"\n");
1904 destval = and_byte(destval, *srcreg);
1905 store_data_byte(destoffset, destval);
1909 destoffset = decode_rm10_address(rl);
1911 destval = fetch_data_byte(destoffset);
1912 srcreg = DECODE_RM_BYTE_REGISTER(rh);
1913 DECODE_PRINTF(
"\n");
1915 destval = and_byte(destval, *srcreg);
1916 store_data_byte(destoffset, destval);
1920 destreg = DECODE_RM_BYTE_REGISTER(rl);
1922 srcreg = DECODE_RM_BYTE_REGISTER(rh);
1923 DECODE_PRINTF(
"\n");
1925 *destreg = and_byte(*destreg, *srcreg);
1928 DECODE_CLEAR_SEGOVR();
1936 static void x86emuOp_and_word_RM_R(u8 X86EMU_UNUSED(op1))
1942 DECODE_PRINTF(
"AND\t");
1943 FETCH_DECODE_MODRM(mod, rh, rl);
1947 if (M.x86.mode & SYSMODE_PREFIX_DATA)
1952 destoffset = decode_rm00_address(rl);
1954 destval = fetch_data_long(destoffset);
1955 srcreg = DECODE_RM_LONG_REGISTER(rh);
1956 DECODE_PRINTF(
"\n");
1958 destval = and_long(destval, *srcreg);
1959 store_data_long(destoffset, destval);
1966 destoffset = decode_rm00_address(rl);
1968 destval = fetch_data_word(destoffset);
1969 srcreg = DECODE_RM_WORD_REGISTER(rh);
1970 DECODE_PRINTF(
"\n");
1972 destval = and_word(destval, *srcreg);
1973 store_data_word(destoffset, destval);
1977 if (M.x86.mode & SYSMODE_PREFIX_DATA)
1982 destoffset = decode_rm01_address(rl);
1984 destval = fetch_data_long(destoffset);
1985 srcreg = DECODE_RM_LONG_REGISTER(rh);
1986 DECODE_PRINTF(
"\n");
1988 destval = and_long(destval, *srcreg);
1989 store_data_long(destoffset, destval);
1996 destoffset = decode_rm01_address(rl);
1998 destval = fetch_data_word(destoffset);
1999 srcreg = DECODE_RM_WORD_REGISTER(rh);
2000 DECODE_PRINTF(
"\n");
2002 destval = and_word(destval, *srcreg);
2003 store_data_word(destoffset, destval);
2007 if (M.x86.mode & SYSMODE_PREFIX_DATA)
2012 destoffset = decode_rm10_address(rl);
2014 destval = fetch_data_long(destoffset);
2015 srcreg = DECODE_RM_LONG_REGISTER(rh);
2016 DECODE_PRINTF(
"\n");
2018 destval = and_long(destval, *srcreg);
2019 store_data_long(destoffset, destval);
2026 destoffset = decode_rm10_address(rl);
2028 destval = fetch_data_word(destoffset);
2029 srcreg = DECODE_RM_WORD_REGISTER(rh);
2030 DECODE_PRINTF(
"\n");
2032 destval = and_word(destval, *srcreg);
2033 store_data_word(destoffset, destval);
2037 if (M.x86.mode & SYSMODE_PREFIX_DATA)
2039 u32 *destreg, *srcreg;
2041 destreg = DECODE_RM_LONG_REGISTER(rl);
2043 srcreg = DECODE_RM_LONG_REGISTER(rh);
2044 DECODE_PRINTF(
"\n");
2046 *destreg = and_long(*destreg, *srcreg);
2050 u16 *destreg, *srcreg;
2052 destreg = DECODE_RM_WORD_REGISTER(rl);
2054 srcreg = DECODE_RM_WORD_REGISTER(rh);
2055 DECODE_PRINTF(
"\n");
2057 *destreg = and_word(*destreg, *srcreg);
2061 DECODE_CLEAR_SEGOVR();
2069 static void x86emuOp_and_byte_R_RM(u8 X86EMU_UNUSED(op1))
2072 u8 *destreg, *srcreg;
2077 DECODE_PRINTF(
"AND\t");
2078 FETCH_DECODE_MODRM(mod, rh, rl);
2082 destreg = DECODE_RM_BYTE_REGISTER(rh);
2084 srcoffset = decode_rm00_address(rl);
2085 srcval = fetch_data_byte(srcoffset);
2086 DECODE_PRINTF(
"\n");
2088 *destreg = and_byte(*destreg, srcval);
2091 destreg = DECODE_RM_BYTE_REGISTER(rh);
2093 srcoffset = decode_rm01_address(rl);
2094 srcval = fetch_data_byte(srcoffset);
2095 DECODE_PRINTF(
"\n");
2097 *destreg = and_byte(*destreg, srcval);
2100 destreg = DECODE_RM_BYTE_REGISTER(rh);
2102 srcoffset = decode_rm10_address(rl);
2103 srcval = fetch_data_byte(srcoffset);
2104 DECODE_PRINTF(
"\n");
2106 *destreg = and_byte(*destreg, srcval);
2109 destreg = DECODE_RM_BYTE_REGISTER(rh);
2111 srcreg = DECODE_RM_BYTE_REGISTER(rl);
2112 DECODE_PRINTF(
"\n");
2114 *destreg = and_byte(*destreg, *srcreg);
2117 DECODE_CLEAR_SEGOVR();
2125 static void x86emuOp_and_word_R_RM(u8 X86EMU_UNUSED(op1))
2131 DECODE_PRINTF(
"AND\t");
2132 FETCH_DECODE_MODRM(mod, rh, rl);
2136 if (M.x86.mode & SYSMODE_PREFIX_DATA)
2141 destreg = DECODE_RM_LONG_REGISTER(rh);
2143 srcoffset = decode_rm00_address(rl);
2144 srcval = fetch_data_long(srcoffset);
2145 DECODE_PRINTF(
"\n");
2147 *destreg = and_long(*destreg, srcval);
2154 destreg = DECODE_RM_WORD_REGISTER(rh);
2156 srcoffset = decode_rm00_address(rl);
2157 srcval = fetch_data_word(srcoffset);
2158 DECODE_PRINTF(
"\n");
2160 *destreg = and_word(*destreg, srcval);
2164 if (M.x86.mode & SYSMODE_PREFIX_DATA)
2169 destreg = DECODE_RM_LONG_REGISTER(rh);
2171 srcoffset = decode_rm01_address(rl);
2172 srcval = fetch_data_long(srcoffset);
2173 DECODE_PRINTF(
"\n");
2175 *destreg = and_long(*destreg, srcval);
2183 destreg = DECODE_RM_WORD_REGISTER(rh);
2185 srcoffset = decode_rm01_address(rl);
2186 srcval = fetch_data_word(srcoffset);
2187 DECODE_PRINTF(
"\n");
2189 *destreg = and_word(*destreg, srcval);
2193 if (M.x86.mode & SYSMODE_PREFIX_DATA)
2198 destreg = DECODE_RM_LONG_REGISTER(rh);
2200 srcoffset = decode_rm10_address(rl);
2201 srcval = fetch_data_long(srcoffset);
2202 DECODE_PRINTF(
"\n");
2204 *destreg = and_long(*destreg, srcval);
2211 destreg = DECODE_RM_WORD_REGISTER(rh);
2213 srcoffset = decode_rm10_address(rl);
2214 srcval = fetch_data_word(srcoffset);
2215 DECODE_PRINTF(
"\n");
2217 *destreg = and_word(*destreg, srcval);
2221 if (M.x86.mode & SYSMODE_PREFIX_DATA)
2223 u32 *destreg, *srcreg;
2225 destreg = DECODE_RM_LONG_REGISTER(rh);
2227 srcreg = DECODE_RM_LONG_REGISTER(rl);
2228 DECODE_PRINTF(
"\n");
2230 *destreg = and_long(*destreg, *srcreg);
2234 u16 *destreg, *srcreg;
2236 destreg = DECODE_RM_WORD_REGISTER(rh);
2238 srcreg = DECODE_RM_WORD_REGISTER(rl);
2239 DECODE_PRINTF(
"\n");
2241 *destreg = and_word(*destreg, *srcreg);
2245 DECODE_CLEAR_SEGOVR();
2253 static void x86emuOp_and_byte_AL_IMM(u8 X86EMU_UNUSED(op1))
2258 DECODE_PRINTF(
"AND\tAL,");
2259 srcval = fetch_byte_imm();
2260 DECODE_PRINTF2(
"%x\n", srcval);
2262 M.x86.R_AL = and_byte(M.x86.R_AL, srcval);
2263 DECODE_CLEAR_SEGOVR();
2271 static void x86emuOp_and_word_AX_IMM(u8 X86EMU_UNUSED(op1))
2276 if (M.x86.mode & SYSMODE_PREFIX_DATA)
2278 DECODE_PRINTF(
"AND\tEAX,");
2279 srcval = fetch_long_imm();
2283 DECODE_PRINTF(
"AND\tAX,");
2284 srcval = fetch_word_imm();
2286 DECODE_PRINTF2(
"%x\n", srcval);
2288 if (M.x86.mode & SYSMODE_PREFIX_DATA)
2290 M.x86.R_EAX = and_long(M.x86.R_EAX, srcval);
2294 M.x86.R_AX = and_word(M.x86.R_AX, (u16) srcval);
2296 DECODE_CLEAR_SEGOVR();
2304 static void x86emuOp_segovr_ES(u8 X86EMU_UNUSED(op1))
2307 DECODE_PRINTF(
"ES:\n");
2309 M.x86.mode |= SYSMODE_SEGOVR_ES;
2321 static void x86emuOp_daa(u8 X86EMU_UNUSED(op1))
2324 DECODE_PRINTF(
"DAA\n");
2326 M.x86.R_AL = daa_byte(M.x86.R_AL);
2327 DECODE_CLEAR_SEGOVR();
2335 static void x86emuOp_sub_byte_RM_R(u8 X86EMU_UNUSED(op1))
2338 u8 *destreg, *srcreg;
2343 DECODE_PRINTF(
"SUB\t");
2344 FETCH_DECODE_MODRM(mod, rh, rl);
2348 destoffset = decode_rm00_address(rl);
2350 destval = fetch_data_byte(destoffset);
2351 srcreg = DECODE_RM_BYTE_REGISTER(rh);
2352 DECODE_PRINTF(
"\n");
2354 destval = sub_byte(destval, *srcreg);
2355 store_data_byte(destoffset, destval);
2358 destoffset = decode_rm01_address(rl);
2360 destval = fetch_data_byte(destoffset);
2361 srcreg = DECODE_RM_BYTE_REGISTER(rh);
2362 DECODE_PRINTF(
"\n");
2364 destval = sub_byte(destval, *srcreg);
2365 store_data_byte(destoffset, destval);
2368 destoffset = decode_rm10_address(rl);
2370 destval = fetch_data_byte(destoffset);
2371 srcreg = DECODE_RM_BYTE_REGISTER(rh);
2372 DECODE_PRINTF(
"\n");
2374 destval = sub_byte(destval, *srcreg);
2375 store_data_byte(destoffset, destval);
2378 destreg = DECODE_RM_BYTE_REGISTER(rl);
2380 srcreg = DECODE_RM_BYTE_REGISTER(rh);
2381 DECODE_PRINTF(
"\n");
2383 *destreg = sub_byte(*destreg, *srcreg);
2386 DECODE_CLEAR_SEGOVR();
2394 static void x86emuOp_sub_word_RM_R(u8 X86EMU_UNUSED(op1))
2400 DECODE_PRINTF(
"SUB\t");
2401 FETCH_DECODE_MODRM(mod, rh, rl);
2405 if (M.x86.mode & SYSMODE_PREFIX_DATA)
2410 destoffset = decode_rm00_address(rl);
2412 destval = fetch_data_long(destoffset);
2413 srcreg = DECODE_RM_LONG_REGISTER(rh);
2414 DECODE_PRINTF(
"\n");
2416 destval = sub_long(destval, *srcreg);
2417 store_data_long(destoffset, destval);
2424 destoffset = decode_rm00_address(rl);
2426 destval = fetch_data_word(destoffset);
2427 srcreg = DECODE_RM_WORD_REGISTER(rh);
2428 DECODE_PRINTF(
"\n");
2430 destval = sub_word(destval, *srcreg);
2431 store_data_word(destoffset, destval);
2435 if (M.x86.mode & SYSMODE_PREFIX_DATA)
2440 destoffset = decode_rm01_address(rl);
2442 destval = fetch_data_long(destoffset);
2443 srcreg = DECODE_RM_LONG_REGISTER(rh);
2444 DECODE_PRINTF(
"\n");
2446 destval = sub_long(destval, *srcreg);
2447 store_data_long(destoffset, destval);
2454 destoffset = decode_rm01_address(rl);
2456 destval = fetch_data_word(destoffset);
2457 srcreg = DECODE_RM_WORD_REGISTER(rh);
2458 DECODE_PRINTF(
"\n");
2460 destval = sub_word(destval, *srcreg);
2461 store_data_word(destoffset, destval);
2465 if (M.x86.mode & SYSMODE_PREFIX_DATA)
2470 destoffset = decode_rm10_address(rl);
2472 destval = fetch_data_long(destoffset);
2473 srcreg = DECODE_RM_LONG_REGISTER(rh);
2474 DECODE_PRINTF(
"\n");
2476 destval = sub_long(destval, *srcreg);
2477 store_data_long(destoffset, destval);
2484 destoffset = decode_rm10_address(rl);
2486 destval = fetch_data_word(destoffset);
2487 srcreg = DECODE_RM_WORD_REGISTER(rh);
2488 DECODE_PRINTF(
"\n");
2490 destval = sub_word(destval, *srcreg);
2491 store_data_word(destoffset, destval);
2495 if (M.x86.mode & SYSMODE_PREFIX_DATA)
2497 u32 *destreg, *srcreg;
2499 destreg = DECODE_RM_LONG_REGISTER(rl);
2501 srcreg = DECODE_RM_LONG_REGISTER(rh);
2502 DECODE_PRINTF(
"\n");
2504 *destreg = sub_long(*destreg, *srcreg);
2508 u16 *destreg, *srcreg;
2510 destreg = DECODE_RM_WORD_REGISTER(rl);
2512 srcreg = DECODE_RM_WORD_REGISTER(rh);
2513 DECODE_PRINTF(
"\n");
2515 *destreg = sub_word(*destreg, *srcreg);
2519 DECODE_CLEAR_SEGOVR();
2527 static void x86emuOp_sub_byte_R_RM(u8 X86EMU_UNUSED(op1))
2530 u8 *destreg, *srcreg;
2535 DECODE_PRINTF(
"SUB\t");
2536 FETCH_DECODE_MODRM(mod, rh, rl);
2540 destreg = DECODE_RM_BYTE_REGISTER(rh);
2542 srcoffset = decode_rm00_address(rl);
2543 srcval = fetch_data_byte(srcoffset);
2544 DECODE_PRINTF(
"\n");
2546 *destreg = sub_byte(*destreg, srcval);
2549 destreg = DECODE_RM_BYTE_REGISTER(rh);
2551 srcoffset = decode_rm01_address(rl);
2552 srcval = fetch_data_byte(srcoffset);
2553 DECODE_PRINTF(
"\n");
2555 *destreg = sub_byte(*destreg, srcval);
2558 destreg = DECODE_RM_BYTE_REGISTER(rh);
2560 srcoffset = decode_rm10_address(rl);
2561 srcval = fetch_data_byte(srcoffset);
2562 DECODE_PRINTF(
"\n");
2564 *destreg = sub_byte(*destreg, srcval);
2567 destreg = DECODE_RM_BYTE_REGISTER(rh);
2569 srcreg = DECODE_RM_BYTE_REGISTER(rl);
2570 DECODE_PRINTF(
"\n");
2572 *destreg = sub_byte(*destreg, *srcreg);
2575 DECODE_CLEAR_SEGOVR();
2583 static void x86emuOp_sub_word_R_RM(u8 X86EMU_UNUSED(op1))
2589 DECODE_PRINTF(
"SUB\t");
2590 FETCH_DECODE_MODRM(mod, rh, rl);
2594 if (M.x86.mode & SYSMODE_PREFIX_DATA)
2599 destreg = DECODE_RM_LONG_REGISTER(rh);
2601 srcoffset = decode_rm00_address(rl);
2602 srcval = fetch_data_long(srcoffset);
2603 DECODE_PRINTF(
"\n");
2605 *destreg = sub_long(*destreg, srcval);
2612 destreg = DECODE_RM_WORD_REGISTER(rh);
2614 srcoffset = decode_rm00_address(rl);
2615 srcval = fetch_data_word(srcoffset);
2616 DECODE_PRINTF(
"\n");
2618 *destreg = sub_word(*destreg, srcval);
2622 if (M.x86.mode & SYSMODE_PREFIX_DATA)
2627 destreg = DECODE_RM_LONG_REGISTER(rh);
2629 srcoffset = decode_rm01_address(rl);
2630 srcval = fetch_data_long(srcoffset);
2631 DECODE_PRINTF(
"\n");
2633 *destreg = sub_long(*destreg, srcval);
2640 destreg = DECODE_RM_WORD_REGISTER(rh);
2642 srcoffset = decode_rm01_address(rl);
2643 srcval = fetch_data_word(srcoffset);
2644 DECODE_PRINTF(
"\n");
2646 *destreg = sub_word(*destreg, srcval);
2650 if (M.x86.mode & SYSMODE_PREFIX_DATA)
2655 destreg = DECODE_RM_LONG_REGISTER(rh);
2657 srcoffset = decode_rm10_address(rl);
2658 srcval = fetch_data_long(srcoffset);
2659 DECODE_PRINTF(
"\n");
2661 *destreg = sub_long(*destreg, srcval);
2668 destreg = DECODE_RM_WORD_REGISTER(rh);
2670 srcoffset = decode_rm10_address(rl);
2671 srcval = fetch_data_word(srcoffset);
2672 DECODE_PRINTF(
"\n");
2674 *destreg = sub_word(*destreg, srcval);
2678 if (M.x86.mode & SYSMODE_PREFIX_DATA)
2680 u32 *destreg, *srcreg;
2682 destreg = DECODE_RM_LONG_REGISTER(rh);
2684 srcreg = DECODE_RM_LONG_REGISTER(rl);
2685 DECODE_PRINTF(
"\n");
2687 *destreg = sub_long(*destreg, *srcreg);
2691 u16 *destreg, *srcreg;
2693 destreg = DECODE_RM_WORD_REGISTER(rh);
2695 srcreg = DECODE_RM_WORD_REGISTER(rl);
2696 DECODE_PRINTF(
"\n");
2698 *destreg = sub_word(*destreg, *srcreg);
2702 DECODE_CLEAR_SEGOVR();
2710 static void x86emuOp_sub_byte_AL_IMM(u8 X86EMU_UNUSED(op1))
2715 DECODE_PRINTF(
"SUB\tAL,");
2716 srcval = fetch_byte_imm();
2717 DECODE_PRINTF2(
"%x\n", srcval);
2719 M.x86.R_AL = sub_byte(M.x86.R_AL, srcval);
2720 DECODE_CLEAR_SEGOVR();
2728 static void x86emuOp_sub_word_AX_IMM(u8 X86EMU_UNUSED(op1))
2733 if (M.x86.mode & SYSMODE_PREFIX_DATA)
2735 DECODE_PRINTF(
"SUB\tEAX,");
2736 srcval = fetch_long_imm();
2740 DECODE_PRINTF(
"SUB\tAX,");
2741 srcval = fetch_word_imm();
2743 DECODE_PRINTF2(
"%x\n", srcval);
2745 if (M.x86.mode & SYSMODE_PREFIX_DATA)
2747 M.x86.R_EAX = sub_long(M.x86.R_EAX, srcval);
2751 M.x86.R_AX = sub_word(M.x86.R_AX, (u16) srcval);
2753 DECODE_CLEAR_SEGOVR();
2761 static void x86emuOp_segovr_CS(u8 X86EMU_UNUSED(op1))
2764 DECODE_PRINTF(
"CS:\n");
2766 M.x86.mode |= SYSMODE_SEGOVR_CS;
2775 static void x86emuOp_das(u8 X86EMU_UNUSED(op1))
2778 DECODE_PRINTF(
"DAS\n");
2780 M.x86.R_AL = das_byte(M.x86.R_AL);
2781 DECODE_CLEAR_SEGOVR();
2789 static void x86emuOp_xor_byte_RM_R(u8 X86EMU_UNUSED(op1))
2792 u8 *destreg, *srcreg;
2797 DECODE_PRINTF(
"XOR\t");
2798 FETCH_DECODE_MODRM(mod, rh, rl);
2802 destoffset = decode_rm00_address(rl);
2804 destval = fetch_data_byte(destoffset);
2805 srcreg = DECODE_RM_BYTE_REGISTER(rh);
2806 DECODE_PRINTF(
"\n");
2808 destval = xor_byte(destval, *srcreg);
2809 store_data_byte(destoffset, destval);
2812 destoffset = decode_rm01_address(rl);
2814 destval = fetch_data_byte(destoffset);
2815 srcreg = DECODE_RM_BYTE_REGISTER(rh);
2816 DECODE_PRINTF(
"\n");
2818 destval = xor_byte(destval, *srcreg);
2819 store_data_byte(destoffset, destval);
2822 destoffset = decode_rm10_address(rl);
2824 destval = fetch_data_byte(destoffset);
2825 srcreg = DECODE_RM_BYTE_REGISTER(rh);
2826 DECODE_PRINTF(
"\n");
2828 destval = xor_byte(destval, *srcreg);
2829 store_data_byte(destoffset, destval);
2832 destreg = DECODE_RM_BYTE_REGISTER(rl);
2834 srcreg = DECODE_RM_BYTE_REGISTER(rh);
2835 DECODE_PRINTF(
"\n");
2837 *destreg = xor_byte(*destreg, *srcreg);
2840 DECODE_CLEAR_SEGOVR();
2848 static void x86emuOp_xor_word_RM_R(u8 X86EMU_UNUSED(op1))
2854 DECODE_PRINTF(
"XOR\t");
2855 FETCH_DECODE_MODRM(mod, rh, rl);
2859 if (M.x86.mode & SYSMODE_PREFIX_DATA)
2864 destoffset = decode_rm00_address(rl);
2866 destval = fetch_data_long(destoffset);
2867 srcreg = DECODE_RM_LONG_REGISTER(rh);
2868 DECODE_PRINTF(
"\n");
2870 destval = xor_long(destval, *srcreg);
2871 store_data_long(destoffset, destval);
2878 destoffset = decode_rm00_address(rl);
2880 destval = fetch_data_word(destoffset);
2881 srcreg = DECODE_RM_WORD_REGISTER(rh);
2882 DECODE_PRINTF(
"\n");
2884 destval = xor_word(destval, *srcreg);
2885 store_data_word(destoffset, destval);
2889 if (M.x86.mode & SYSMODE_PREFIX_DATA)
2894 destoffset = decode_rm01_address(rl);
2896 destval = fetch_data_long(destoffset);
2897 srcreg = DECODE_RM_LONG_REGISTER(rh);
2898 DECODE_PRINTF(
"\n");
2900 destval = xor_long(destval, *srcreg);
2901 store_data_long(destoffset, destval);
2908 destoffset = decode_rm01_address(rl);
2910 destval = fetch_data_word(destoffset);
2911 srcreg = DECODE_RM_WORD_REGISTER(rh);
2912 DECODE_PRINTF(
"\n");
2914 destval = xor_word(destval, *srcreg);
2915 store_data_word(destoffset, destval);
2919 if (M.x86.mode & SYSMODE_PREFIX_DATA)
2924 destoffset = decode_rm10_address(rl);
2926 destval = fetch_data_long(destoffset);
2927 srcreg = DECODE_RM_LONG_REGISTER(rh);
2928 DECODE_PRINTF(
"\n");
2930 destval = xor_long(destval, *srcreg);
2931 store_data_long(destoffset, destval);
2938 destoffset = decode_rm10_address(rl);
2940 destval = fetch_data_word(destoffset);
2941 srcreg = DECODE_RM_WORD_REGISTER(rh);
2942 DECODE_PRINTF(
"\n");
2944 destval = xor_word(destval, *srcreg);
2945 store_data_word(destoffset, destval);
2949 if (M.x86.mode & SYSMODE_PREFIX_DATA)
2951 u32 *destreg, *srcreg;
2953 destreg = DECODE_RM_LONG_REGISTER(rl);
2955 srcreg = DECODE_RM_LONG_REGISTER(rh);
2956 DECODE_PRINTF(
"\n");
2958 *destreg = xor_long(*destreg, *srcreg);
2962 u16 *destreg, *srcreg;
2964 destreg = DECODE_RM_WORD_REGISTER(rl);
2966 srcreg = DECODE_RM_WORD_REGISTER(rh);
2967 DECODE_PRINTF(
"\n");
2969 *destreg = xor_word(*destreg, *srcreg);
2973 DECODE_CLEAR_SEGOVR();
2981 static void x86emuOp_xor_byte_R_RM(u8 X86EMU_UNUSED(op1))
2984 u8 *destreg, *srcreg;
2989 DECODE_PRINTF(
"XOR\t");
2990 FETCH_DECODE_MODRM(mod, rh, rl);
2994 destreg = DECODE_RM_BYTE_REGISTER(rh);
2996 srcoffset = decode_rm00_address(rl);
2997 srcval = fetch_data_byte(srcoffset);
2998 DECODE_PRINTF(
"\n");
3000 *destreg = xor_byte(*destreg, srcval);
3003 destreg = DECODE_RM_BYTE_REGISTER(rh);
3005 srcoffset = decode_rm01_address(rl);
3006 srcval = fetch_data_byte(srcoffset);
3007 DECODE_PRINTF(
"\n");
3009 *destreg = xor_byte(*destreg, srcval);
3012 destreg = DECODE_RM_BYTE_REGISTER(rh);
3014 srcoffset = decode_rm10_address(rl);
3015 srcval = fetch_data_byte(srcoffset);
3016 DECODE_PRINTF(
"\n");
3018 *destreg = xor_byte(*destreg, srcval);
3021 destreg = DECODE_RM_BYTE_REGISTER(rh);
3023 srcreg = DECODE_RM_BYTE_REGISTER(rl);
3024 DECODE_PRINTF(
"\n");
3026 *destreg = xor_byte(*destreg, *srcreg);
3029 DECODE_CLEAR_SEGOVR();
3037 static void x86emuOp_xor_word_R_RM(u8 X86EMU_UNUSED(op1))
3043 DECODE_PRINTF(
"XOR\t");
3044 FETCH_DECODE_MODRM(mod, rh, rl);
3048 if (M.x86.mode & SYSMODE_PREFIX_DATA)
3053 destreg = DECODE_RM_LONG_REGISTER(rh);
3055 srcoffset = decode_rm00_address(rl);
3056 srcval = fetch_data_long(srcoffset);
3057 DECODE_PRINTF(
"\n");
3059 *destreg = xor_long(*destreg, srcval);
3066 destreg = DECODE_RM_WORD_REGISTER(rh);
3068 srcoffset = decode_rm00_address(rl);
3069 srcval = fetch_data_word(srcoffset);
3070 DECODE_PRINTF(
"\n");
3072 *destreg = xor_word(*destreg, srcval);
3076 if (M.x86.mode & SYSMODE_PREFIX_DATA)
3081 destreg = DECODE_RM_LONG_REGISTER(rh);
3083 srcoffset = decode_rm01_address(rl);
3084 srcval = fetch_data_long(srcoffset);
3085 DECODE_PRINTF(
"\n");
3087 *destreg = xor_long(*destreg, srcval);
3094 destreg = DECODE_RM_WORD_REGISTER(rh);
3096 srcoffset = decode_rm01_address(rl);
3097 srcval = fetch_data_word(srcoffset);
3098 DECODE_PRINTF(
"\n");
3100 *destreg = xor_word(*destreg, srcval);
3104 if (M.x86.mode & SYSMODE_PREFIX_DATA)
3109 destreg = DECODE_RM_LONG_REGISTER(rh);
3111 srcoffset = decode_rm10_address(rl);
3112 srcval = fetch_data_long(srcoffset);
3113 DECODE_PRINTF(
"\n");
3115 *destreg = xor_long(*destreg, srcval);
3122 destreg = DECODE_RM_WORD_REGISTER(rh);
3124 srcoffset = decode_rm10_address(rl);
3125 srcval = fetch_data_word(srcoffset);
3126 DECODE_PRINTF(
"\n");
3128 *destreg = xor_word(*destreg, srcval);
3132 if (M.x86.mode & SYSMODE_PREFIX_DATA)
3134 u32 *destreg, *srcreg;
3136 destreg = DECODE_RM_LONG_REGISTER(rh);
3138 srcreg = DECODE_RM_LONG_REGISTER(rl);
3139 DECODE_PRINTF(
"\n");
3141 *destreg = xor_long(*destreg, *srcreg);
3145 u16 *destreg, *srcreg;
3147 destreg = DECODE_RM_WORD_REGISTER(rh);
3149 srcreg = DECODE_RM_WORD_REGISTER(rl);
3150 DECODE_PRINTF(
"\n");
3152 *destreg = xor_word(*destreg, *srcreg);
3156 DECODE_CLEAR_SEGOVR();
3164 static void x86emuOp_xor_byte_AL_IMM(u8 X86EMU_UNUSED(op1))
3169 DECODE_PRINTF(
"XOR\tAL,");
3170 srcval = fetch_byte_imm();
3171 DECODE_PRINTF2(
"%x\n", srcval);
3173 M.x86.R_AL = xor_byte(M.x86.R_AL, srcval);
3174 DECODE_CLEAR_SEGOVR();
3182 static void x86emuOp_xor_word_AX_IMM(u8 X86EMU_UNUSED(op1))
3187 if (M.x86.mode & SYSMODE_PREFIX_DATA)
3189 DECODE_PRINTF(
"XOR\tEAX,");
3190 srcval = fetch_long_imm();
3194 DECODE_PRINTF(
"XOR\tAX,");
3195 srcval = fetch_word_imm();
3197 DECODE_PRINTF2(
"%x\n", srcval);
3199 if (M.x86.mode & SYSMODE_PREFIX_DATA)
3201 M.x86.R_EAX = xor_long(M.x86.R_EAX, srcval);
3205 M.x86.R_AX = xor_word(M.x86.R_AX, (u16) srcval);
3207 DECODE_CLEAR_SEGOVR();
3215 static void x86emuOp_segovr_SS(u8 X86EMU_UNUSED(op1))
3218 DECODE_PRINTF(
"SS:\n");
3220 M.x86.mode |= SYSMODE_SEGOVR_SS;
3229 static void x86emuOp_aaa(u8 X86EMU_UNUSED(op1))
3232 DECODE_PRINTF(
"AAA\n");
3234 M.x86.R_AX = aaa_word(M.x86.R_AX);
3235 DECODE_CLEAR_SEGOVR();
3243 static void x86emuOp_cmp_byte_RM_R(u8 X86EMU_UNUSED(op1))
3247 u8 *destreg, *srcreg;
3251 DECODE_PRINTF(
"CMP\t");
3252 FETCH_DECODE_MODRM(mod, rh, rl);
3256 destoffset = decode_rm00_address(rl);
3258 destval = fetch_data_byte(destoffset);
3259 srcreg = DECODE_RM_BYTE_REGISTER(rh);
3260 DECODE_PRINTF(
"\n");
3262 cmp_byte(destval, *srcreg);
3265 destoffset = decode_rm01_address(rl);
3267 destval = fetch_data_byte(destoffset);
3268 srcreg = DECODE_RM_BYTE_REGISTER(rh);
3269 DECODE_PRINTF(
"\n");
3271 cmp_byte(destval, *srcreg);
3274 destoffset = decode_rm10_address(rl);
3276 destval = fetch_data_byte(destoffset);
3277 srcreg = DECODE_RM_BYTE_REGISTER(rh);
3278 DECODE_PRINTF(
"\n");
3280 cmp_byte(destval, *srcreg);
3283 destreg = DECODE_RM_BYTE_REGISTER(rl);
3285 srcreg = DECODE_RM_BYTE_REGISTER(rh);
3286 DECODE_PRINTF(
"\n");
3288 cmp_byte(*destreg, *srcreg);
3291 DECODE_CLEAR_SEGOVR();
3299 static void x86emuOp_cmp_word_RM_R(u8 X86EMU_UNUSED(op1))
3305 DECODE_PRINTF(
"CMP\t");
3306 FETCH_DECODE_MODRM(mod, rh, rl);
3310 if (M.x86.mode & SYSMODE_PREFIX_DATA)
3315 destoffset = decode_rm00_address(rl);
3317 destval = fetch_data_long(destoffset);
3318 srcreg = DECODE_RM_LONG_REGISTER(rh);
3319 DECODE_PRINTF(
"\n");
3321 cmp_long(destval, *srcreg);
3328 destoffset = decode_rm00_address(rl);
3330 destval = fetch_data_word(destoffset);
3331 srcreg = DECODE_RM_WORD_REGISTER(rh);
3332 DECODE_PRINTF(
"\n");
3334 cmp_word(destval, *srcreg);
3338 if (M.x86.mode & SYSMODE_PREFIX_DATA)
3343 destoffset = decode_rm01_address(rl);
3345 destval = fetch_data_long(destoffset);
3346 srcreg = DECODE_RM_LONG_REGISTER(rh);
3347 DECODE_PRINTF(
"\n");
3349 cmp_long(destval, *srcreg);
3356 destoffset = decode_rm01_address(rl);
3358 destval = fetch_data_word(destoffset);
3359 srcreg = DECODE_RM_WORD_REGISTER(rh);
3360 DECODE_PRINTF(
"\n");
3362 cmp_word(destval, *srcreg);
3366 if (M.x86.mode & SYSMODE_PREFIX_DATA)
3371 destoffset = decode_rm10_address(rl);
3373 destval = fetch_data_long(destoffset);
3374 srcreg = DECODE_RM_LONG_REGISTER(rh);
3375 DECODE_PRINTF(
"\n");
3377 cmp_long(destval, *srcreg);
3384 destoffset = decode_rm10_address(rl);
3386 destval = fetch_data_word(destoffset);
3387 srcreg = DECODE_RM_WORD_REGISTER(rh);
3388 DECODE_PRINTF(
"\n");
3390 cmp_word(destval, *srcreg);
3394 if (M.x86.mode & SYSMODE_PREFIX_DATA)
3396 u32 *destreg, *srcreg;
3398 destreg = DECODE_RM_LONG_REGISTER(rl);
3400 srcreg = DECODE_RM_LONG_REGISTER(rh);
3401 DECODE_PRINTF(
"\n");
3403 cmp_long(*destreg, *srcreg);
3407 u16 *destreg, *srcreg;
3409 destreg = DECODE_RM_WORD_REGISTER(rl);
3411 srcreg = DECODE_RM_WORD_REGISTER(rh);
3412 DECODE_PRINTF(
"\n");
3414 cmp_word(*destreg, *srcreg);
3418 DECODE_CLEAR_SEGOVR();
3426 static void x86emuOp_cmp_byte_R_RM(u8 X86EMU_UNUSED(op1))
3429 u8 *destreg, *srcreg;
3434 DECODE_PRINTF(
"CMP\t");
3435 FETCH_DECODE_MODRM(mod, rh, rl);
3439 destreg = DECODE_RM_BYTE_REGISTER(rh);
3441 srcoffset = decode_rm00_address(rl);
3442 srcval = fetch_data_byte(srcoffset);
3443 DECODE_PRINTF(
"\n");
3445 cmp_byte(*destreg, srcval);
3448 destreg = DECODE_RM_BYTE_REGISTER(rh);
3450 srcoffset = decode_rm01_address(rl);
3451 srcval = fetch_data_byte(srcoffset);
3452 DECODE_PRINTF(
"\n");
3454 cmp_byte(*destreg, srcval);
3457 destreg = DECODE_RM_BYTE_REGISTER(rh);
3459 srcoffset = decode_rm10_address(rl);
3460 srcval = fetch_data_byte(srcoffset);
3461 DECODE_PRINTF(
"\n");
3463 cmp_byte(*destreg, srcval);
3466 destreg = DECODE_RM_BYTE_REGISTER(rh);
3468 srcreg = DECODE_RM_BYTE_REGISTER(rl);
3469 DECODE_PRINTF(
"\n");
3471 cmp_byte(*destreg, *srcreg);
3474 DECODE_CLEAR_SEGOVR();
3482 static void x86emuOp_cmp_word_R_RM(u8 X86EMU_UNUSED(op1))
3488 DECODE_PRINTF(
"CMP\t");
3489 FETCH_DECODE_MODRM(mod, rh, rl);
3493 if (M.x86.mode & SYSMODE_PREFIX_DATA)
3498 destreg = DECODE_RM_LONG_REGISTER(rh);
3500 srcoffset = decode_rm00_address(rl);
3501 srcval = fetch_data_long(srcoffset);
3502 DECODE_PRINTF(
"\n");
3504 cmp_long(*destreg, srcval);
3511 destreg = DECODE_RM_WORD_REGISTER(rh);
3513 srcoffset = decode_rm00_address(rl);
3514 srcval = fetch_data_word(srcoffset);
3515 DECODE_PRINTF(
"\n");
3517 cmp_word(*destreg, srcval);
3521 if (M.x86.mode & SYSMODE_PREFIX_DATA)
3526 destreg = DECODE_RM_LONG_REGISTER(rh);
3528 srcoffset = decode_rm01_address(rl);
3529 srcval = fetch_data_long(srcoffset);
3530 DECODE_PRINTF(
"\n");
3532 cmp_long(*destreg, srcval);
3539 destreg = DECODE_RM_WORD_REGISTER(rh);
3541 srcoffset = decode_rm01_address(rl);
3542 srcval = fetch_data_word(srcoffset);
3543 DECODE_PRINTF(
"\n");
3545 cmp_word(*destreg, srcval);
3549 if (M.x86.mode & SYSMODE_PREFIX_DATA)
3554 destreg = DECODE_RM_LONG_REGISTER(rh);
3556 srcoffset = decode_rm10_address(rl);
3557 srcval = fetch_data_long(srcoffset);
3558 DECODE_PRINTF(
"\n");
3560 cmp_long(*destreg, srcval);
3567 destreg = DECODE_RM_WORD_REGISTER(rh);
3569 srcoffset = decode_rm10_address(rl);
3570 srcval = fetch_data_word(srcoffset);
3571 DECODE_PRINTF(
"\n");
3573 cmp_word(*destreg, srcval);
3577 if (M.x86.mode & SYSMODE_PREFIX_DATA)
3579 u32 *destreg, *srcreg;
3581 destreg = DECODE_RM_LONG_REGISTER(rh);
3583 srcreg = DECODE_RM_LONG_REGISTER(rl);
3584 DECODE_PRINTF(
"\n");
3586 cmp_long(*destreg, *srcreg);
3590 u16 *destreg, *srcreg;
3592 destreg = DECODE_RM_WORD_REGISTER(rh);
3594 srcreg = DECODE_RM_WORD_REGISTER(rl);
3595 DECODE_PRINTF(
"\n");
3597 cmp_word(*destreg, *srcreg);
3601 DECODE_CLEAR_SEGOVR();
3609 static void x86emuOp_cmp_byte_AL_IMM(u8 X86EMU_UNUSED(op1))
3614 DECODE_PRINTF(
"CMP\tAL,");
3615 srcval = fetch_byte_imm();
3616 DECODE_PRINTF2(
"%x\n", srcval);
3618 cmp_byte(M.x86.R_AL, srcval);
3619 DECODE_CLEAR_SEGOVR();
3627 static void x86emuOp_cmp_word_AX_IMM(u8 X86EMU_UNUSED(op1))
3632 if (M.x86.mode & SYSMODE_PREFIX_DATA)
3634 DECODE_PRINTF(
"CMP\tEAX,");
3635 srcval = fetch_long_imm();
3639 DECODE_PRINTF(
"CMP\tAX,");
3640 srcval = fetch_word_imm();
3642 DECODE_PRINTF2(
"%x\n", srcval);
3644 if (M.x86.mode & SYSMODE_PREFIX_DATA)
3646 cmp_long(M.x86.R_EAX, srcval);
3650 cmp_word(M.x86.R_AX, (u16) srcval);
3652 DECODE_CLEAR_SEGOVR();
3660 static void x86emuOp_segovr_DS(u8 X86EMU_UNUSED(op1))
3663 DECODE_PRINTF(
"DS:\n");
3665 M.x86.mode |= SYSMODE_SEGOVR_DS;
3674 static void x86emuOp_aas(u8 X86EMU_UNUSED(op1))
3677 DECODE_PRINTF(
"AAS\n");
3679 M.x86.R_AX = aas_word(M.x86.R_AX);
3680 DECODE_CLEAR_SEGOVR();
3688 static void x86emuOp_inc_AX(u8 X86EMU_UNUSED(op1))
3691 if (M.x86.mode & SYSMODE_PREFIX_DATA)
3693 DECODE_PRINTF(
"INC\tEAX\n");
3697 DECODE_PRINTF(
"INC\tAX\n");
3700 if (M.x86.mode & SYSMODE_PREFIX_DATA)
3702 M.x86.R_EAX = inc_long(M.x86.R_EAX);
3706 M.x86.R_AX = inc_word(M.x86.R_AX);
3708 DECODE_CLEAR_SEGOVR();
3716 static void x86emuOp_inc_CX(u8 X86EMU_UNUSED(op1))
3719 if (M.x86.mode & SYSMODE_PREFIX_DATA)
3721 DECODE_PRINTF(
"INC\tECX\n");
3725 DECODE_PRINTF(
"INC\tCX\n");
3728 if (M.x86.mode & SYSMODE_PREFIX_DATA)
3730 M.x86.R_ECX = inc_long(M.x86.R_ECX);
3734 M.x86.R_CX = inc_word(M.x86.R_CX);
3736 DECODE_CLEAR_SEGOVR();
3744 static void x86emuOp_inc_DX(u8 X86EMU_UNUSED(op1))
3747 if (M.x86.mode & SYSMODE_PREFIX_DATA)
3749 DECODE_PRINTF(
"INC\tEDX\n");
3753 DECODE_PRINTF(
"INC\tDX\n");
3756 if (M.x86.mode & SYSMODE_PREFIX_DATA)
3758 M.x86.R_EDX = inc_long(M.x86.R_EDX);
3762 M.x86.R_DX = inc_word(M.x86.R_DX);
3764 DECODE_CLEAR_SEGOVR();
3772 static void x86emuOp_inc_BX(u8 X86EMU_UNUSED(op1))
3775 if (M.x86.mode & SYSMODE_PREFIX_DATA)
3777 DECODE_PRINTF(
"INC\tEBX\n");
3781 DECODE_PRINTF(
"INC\tBX\n");
3784 if (M.x86.mode & SYSMODE_PREFIX_DATA)
3786 M.x86.R_EBX = inc_long(M.x86.R_EBX);
3790 M.x86.R_BX = inc_word(M.x86.R_BX);
3792 DECODE_CLEAR_SEGOVR();
3800 static void x86emuOp_inc_SP(u8 X86EMU_UNUSED(op1))
3803 if (M.x86.mode & SYSMODE_PREFIX_DATA)
3805 DECODE_PRINTF(
"INC\tESP\n");
3809 DECODE_PRINTF(
"INC\tSP\n");
3812 if (M.x86.mode & SYSMODE_PREFIX_DATA)
3814 M.x86.R_ESP = inc_long(M.x86.R_ESP);
3818 M.x86.R_SP = inc_word(M.x86.R_SP);
3820 DECODE_CLEAR_SEGOVR();
3828 static void x86emuOp_inc_BP(u8 X86EMU_UNUSED(op1))
3831 if (M.x86.mode & SYSMODE_PREFIX_DATA)
3833 DECODE_PRINTF(
"INC\tEBP\n");
3837 DECODE_PRINTF(
"INC\tBP\n");
3840 if (M.x86.mode & SYSMODE_PREFIX_DATA)
3842 M.x86.R_EBP = inc_long(M.x86.R_EBP);
3846 M.x86.R_BP = inc_word(M.x86.R_BP);
3848 DECODE_CLEAR_SEGOVR();
3856 static void x86emuOp_inc_SI(u8 X86EMU_UNUSED(op1))
3859 if (M.x86.mode & SYSMODE_PREFIX_DATA)
3861 DECODE_PRINTF(
"INC\tESI\n");
3865 DECODE_PRINTF(
"INC\tSI\n");
3868 if (M.x86.mode & SYSMODE_PREFIX_DATA)
3870 M.x86.R_ESI = inc_long(M.x86.R_ESI);
3874 M.x86.R_SI = inc_word(M.x86.R_SI);
3876 DECODE_CLEAR_SEGOVR();
3884 static void x86emuOp_inc_DI(u8 X86EMU_UNUSED(op1))
3887 if (M.x86.mode & SYSMODE_PREFIX_DATA)
3889 DECODE_PRINTF(
"INC\tEDI\n");
3893 DECODE_PRINTF(
"INC\tDI\n");
3896 if (M.x86.mode & SYSMODE_PREFIX_DATA)
3898 M.x86.R_EDI = inc_long(M.x86.R_EDI);
3902 M.x86.R_DI = inc_word(M.x86.R_DI);
3904 DECODE_CLEAR_SEGOVR();
3912 static void x86emuOp_dec_AX(u8 X86EMU_UNUSED(op1))
3915 if (M.x86.mode & SYSMODE_PREFIX_DATA)
3917 DECODE_PRINTF(
"DEC\tEAX\n");
3921 DECODE_PRINTF(
"DEC\tAX\n");
3924 if (M.x86.mode & SYSMODE_PREFIX_DATA)
3926 M.x86.R_EAX = dec_long(M.x86.R_EAX);
3930 M.x86.R_AX = dec_word(M.x86.R_AX);
3932 DECODE_CLEAR_SEGOVR();
3940 static void x86emuOp_dec_CX(u8 X86EMU_UNUSED(op1))
3943 if (M.x86.mode & SYSMODE_PREFIX_DATA)
3945 DECODE_PRINTF(
"DEC\tECX\n");
3949 DECODE_PRINTF(
"DEC\tCX\n");
3952 if (M.x86.mode & SYSMODE_PREFIX_DATA)
3954 M.x86.R_ECX = dec_long(M.x86.R_ECX);
3958 M.x86.R_CX = dec_word(M.x86.R_CX);
3960 DECODE_CLEAR_SEGOVR();
3968 static void x86emuOp_dec_DX(u8 X86EMU_UNUSED(op1))
3971 if (M.x86.mode & SYSMODE_PREFIX_DATA)
3973 DECODE_PRINTF(
"DEC\tEDX\n");
3977 DECODE_PRINTF(
"DEC\tDX\n");
3980 if (M.x86.mode & SYSMODE_PREFIX_DATA)
3982 M.x86.R_EDX = dec_long(M.x86.R_EDX);
3986 M.x86.R_DX = dec_word(M.x86.R_DX);
3988 DECODE_CLEAR_SEGOVR();
3996 static void x86emuOp_dec_BX(u8 X86EMU_UNUSED(op1))
3999 if (M.x86.mode & SYSMODE_PREFIX_DATA)
4001 DECODE_PRINTF(
"DEC\tEBX\n");
4005 DECODE_PRINTF(
"DEC\tBX\n");
4008 if (M.x86.mode & SYSMODE_PREFIX_DATA)
4010 M.x86.R_EBX = dec_long(M.x86.R_EBX);
4014 M.x86.R_BX = dec_word(M.x86.R_BX);
4016 DECODE_CLEAR_SEGOVR();
4024 static void x86emuOp_dec_SP(u8 X86EMU_UNUSED(op1))
4027 if (M.x86.mode & SYSMODE_PREFIX_DATA)
4029 DECODE_PRINTF(
"DEC\tESP\n");
4033 DECODE_PRINTF(
"DEC\tSP\n");
4036 if (M.x86.mode & SYSMODE_PREFIX_DATA)
4038 M.x86.R_ESP = dec_long(M.x86.R_ESP);
4042 M.x86.R_SP = dec_word(M.x86.R_SP);
4044 DECODE_CLEAR_SEGOVR();
4052 static void x86emuOp_dec_BP(u8 X86EMU_UNUSED(op1))
4055 if (M.x86.mode & SYSMODE_PREFIX_DATA)
4057 DECODE_PRINTF(
"DEC\tEBP\n");
4061 DECODE_PRINTF(
"DEC\tBP\n");
4064 if (M.x86.mode & SYSMODE_PREFIX_DATA)
4066 M.x86.R_EBP = dec_long(M.x86.R_EBP);
4070 M.x86.R_BP = dec_word(M.x86.R_BP);
4072 DECODE_CLEAR_SEGOVR();
4080 static void x86emuOp_dec_SI(u8 X86EMU_UNUSED(op1))
4083 if (M.x86.mode & SYSMODE_PREFIX_DATA)
4085 DECODE_PRINTF(
"DEC\tESI\n");
4089 DECODE_PRINTF(
"DEC\tSI\n");
4092 if (M.x86.mode & SYSMODE_PREFIX_DATA)
4094 M.x86.R_ESI = dec_long(M.x86.R_ESI);
4098 M.x86.R_SI = dec_word(M.x86.R_SI);
4100 DECODE_CLEAR_SEGOVR();
4108 static void x86emuOp_dec_DI(u8 X86EMU_UNUSED(op1))
4111 if (M.x86.mode & SYSMODE_PREFIX_DATA)
4113 DECODE_PRINTF(
"DEC\tEDI\n");
4117 DECODE_PRINTF(
"DEC\tDI\n");
4120 if (M.x86.mode & SYSMODE_PREFIX_DATA)
4122 M.x86.R_EDI = dec_long(M.x86.R_EDI);
4126 M.x86.R_DI = dec_word(M.x86.R_DI);
4128 DECODE_CLEAR_SEGOVR();
4136 static void x86emuOp_push_AX(u8 X86EMU_UNUSED(op1))
4139 if (M.x86.mode & SYSMODE_PREFIX_DATA)
4141 DECODE_PRINTF(
"PUSH\tEAX\n");
4145 DECODE_PRINTF(
"PUSH\tAX\n");
4148 if (M.x86.mode & SYSMODE_PREFIX_DATA)
4150 push_long(M.x86.R_EAX);
4154 push_word(M.x86.R_AX);
4156 DECODE_CLEAR_SEGOVR();
4164 static void x86emuOp_push_CX(u8 X86EMU_UNUSED(op1))
4167 if (M.x86.mode & SYSMODE_PREFIX_DATA)
4169 DECODE_PRINTF(
"PUSH\tECX\n");
4173 DECODE_PRINTF(
"PUSH\tCX\n");
4176 if (M.x86.mode & SYSMODE_PREFIX_DATA)
4178 push_long(M.x86.R_ECX);
4182 push_word(M.x86.R_CX);
4184 DECODE_CLEAR_SEGOVR();
4192 static void x86emuOp_push_DX(u8 X86EMU_UNUSED(op1))
4195 if (M.x86.mode & SYSMODE_PREFIX_DATA)
4197 DECODE_PRINTF(
"PUSH\tEDX\n");
4201 DECODE_PRINTF(
"PUSH\tDX\n");
4204 if (M.x86.mode & SYSMODE_PREFIX_DATA)
4206 push_long(M.x86.R_EDX);
4210 push_word(M.x86.R_DX);
4212 DECODE_CLEAR_SEGOVR();
4220 static void x86emuOp_push_BX(u8 X86EMU_UNUSED(op1))
4223 if (M.x86.mode & SYSMODE_PREFIX_DATA)
4225 DECODE_PRINTF(
"PUSH\tEBX\n");
4229 DECODE_PRINTF(
"PUSH\tBX\n");
4232 if (M.x86.mode & SYSMODE_PREFIX_DATA)
4234 push_long(M.x86.R_EBX);
4238 push_word(M.x86.R_BX);
4240 DECODE_CLEAR_SEGOVR();
4248 static void x86emuOp_push_SP(u8 X86EMU_UNUSED(op1))
4251 if (M.x86.mode & SYSMODE_PREFIX_DATA)
4253 DECODE_PRINTF(
"PUSH\tESP\n");
4257 DECODE_PRINTF(
"PUSH\tSP\n");
4264 if (M.x86.mode & SYSMODE_PREFIX_DATA)
4266 push_long(M.x86.R_ESP);
4270 push_word((u16)(M.x86.R_SP));
4272 DECODE_CLEAR_SEGOVR();
4280 static void x86emuOp_push_BP(u8 X86EMU_UNUSED(op1))
4283 if (M.x86.mode & SYSMODE_PREFIX_DATA)
4285 DECODE_PRINTF(
"PUSH\tEBP\n");
4289 DECODE_PRINTF(
"PUSH\tBP\n");
4292 if (M.x86.mode & SYSMODE_PREFIX_DATA)
4294 push_long(M.x86.R_EBP);
4298 push_word(M.x86.R_BP);
4300 DECODE_CLEAR_SEGOVR();
4308 static void x86emuOp_push_SI(u8 X86EMU_UNUSED(op1))
4311 if (M.x86.mode & SYSMODE_PREFIX_DATA)
4313 DECODE_PRINTF(
"PUSH\tESI\n");
4317 DECODE_PRINTF(
"PUSH\tSI\n");
4320 if (M.x86.mode & SYSMODE_PREFIX_DATA)
4322 push_long(M.x86.R_ESI);
4326 push_word(M.x86.R_SI);
4328 DECODE_CLEAR_SEGOVR();
4336 static void x86emuOp_push_DI(u8 X86EMU_UNUSED(op1))
4339 if (M.x86.mode & SYSMODE_PREFIX_DATA)
4341 DECODE_PRINTF(
"PUSH\tEDI\n");
4345 DECODE_PRINTF(
"PUSH\tDI\n");
4348 if (M.x86.mode & SYSMODE_PREFIX_DATA)
4350 push_long(M.x86.R_EDI);
4354 push_word(M.x86.R_DI);
4356 DECODE_CLEAR_SEGOVR();
4364 static void x86emuOp_pop_AX(u8 X86EMU_UNUSED(op1))
4367 if (M.x86.mode & SYSMODE_PREFIX_DATA)
4369 DECODE_PRINTF(
"POP\tEAX\n");
4373 DECODE_PRINTF(
"POP\tAX\n");
4376 if (M.x86.mode & SYSMODE_PREFIX_DATA)
4378 M.x86.R_EAX = pop_long();
4382 M.x86.R_AX = pop_word();
4384 DECODE_CLEAR_SEGOVR();
4392 static void x86emuOp_pop_CX(u8 X86EMU_UNUSED(op1))
4395 if (M.x86.mode & SYSMODE_PREFIX_DATA)
4397 DECODE_PRINTF(
"POP\tECX\n");
4401 DECODE_PRINTF(
"POP\tCX\n");
4404 if (M.x86.mode & SYSMODE_PREFIX_DATA)
4406 M.x86.R_ECX = pop_long();
4410 M.x86.R_CX = pop_word();
4412 DECODE_CLEAR_SEGOVR();
4420 static void x86emuOp_pop_DX(u8 X86EMU_UNUSED(op1))
4423 if (M.x86.mode & SYSMODE_PREFIX_DATA)
4425 DECODE_PRINTF(
"POP\tEDX\n");
4429 DECODE_PRINTF(
"POP\tDX\n");
4432 if (M.x86.mode & SYSMODE_PREFIX_DATA)
4434 M.x86.R_EDX = pop_long();
4438 M.x86.R_DX = pop_word();
4440 DECODE_CLEAR_SEGOVR();
4448 static void x86emuOp_pop_BX(u8 X86EMU_UNUSED(op1))
4451 if (M.x86.mode & SYSMODE_PREFIX_DATA)
4453 DECODE_PRINTF(
"POP\tEBX\n");
4457 DECODE_PRINTF(
"POP\tBX\n");
4460 if (M.x86.mode & SYSMODE_PREFIX_DATA)
4462 M.x86.R_EBX = pop_long();
4466 M.x86.R_BX = pop_word();
4468 DECODE_CLEAR_SEGOVR();
4476 static void x86emuOp_pop_SP(u8 X86EMU_UNUSED(op1))
4479 if (M.x86.mode & SYSMODE_PREFIX_DATA)
4481 DECODE_PRINTF(
"POP\tESP\n");
4485 DECODE_PRINTF(
"POP\tSP\n");
4488 if (M.x86.mode & SYSMODE_PREFIX_DATA)
4490 M.x86.R_ESP = pop_long();
4494 M.x86.R_SP = pop_word();
4496 DECODE_CLEAR_SEGOVR();
4504 static void x86emuOp_pop_BP(u8 X86EMU_UNUSED(op1))
4507 if (M.x86.mode & SYSMODE_PREFIX_DATA)
4509 DECODE_PRINTF(
"POP\tEBP\n");
4513 DECODE_PRINTF(
"POP\tBP\n");
4516 if (M.x86.mode & SYSMODE_PREFIX_DATA)
4518 M.x86.R_EBP = pop_long();
4522 M.x86.R_BP = pop_word();
4524 DECODE_CLEAR_SEGOVR();
4532 static void x86emuOp_pop_SI(u8 X86EMU_UNUSED(op1))
4535 if (M.x86.mode & SYSMODE_PREFIX_DATA)
4537 DECODE_PRINTF(
"POP\tESI\n");
4541 DECODE_PRINTF(
"POP\tSI\n");
4544 if (M.x86.mode & SYSMODE_PREFIX_DATA)
4546 M.x86.R_ESI = pop_long();
4550 M.x86.R_SI = pop_word();
4552 DECODE_CLEAR_SEGOVR();
4560 static void x86emuOp_pop_DI(u8 X86EMU_UNUSED(op1))
4563 if (M.x86.mode & SYSMODE_PREFIX_DATA)
4565 DECODE_PRINTF(
"POP\tEDI\n");
4569 DECODE_PRINTF(
"POP\tDI\n");
4572 if (M.x86.mode & SYSMODE_PREFIX_DATA)
4574 M.x86.R_EDI = pop_long();
4578 M.x86.R_DI = pop_word();
4580 DECODE_CLEAR_SEGOVR();
4588 static void x86emuOp_push_all(u8 X86EMU_UNUSED(op1))
4591 if (M.x86.mode & SYSMODE_PREFIX_DATA)
4593 DECODE_PRINTF(
"PUSHAD\n");
4597 DECODE_PRINTF(
"PUSHA\n");
4600 if (M.x86.mode & SYSMODE_PREFIX_DATA)
4602 u32 old_sp = M.x86.R_ESP;
4604 push_long(M.x86.R_EAX);
4605 push_long(M.x86.R_ECX);
4606 push_long(M.x86.R_EDX);
4607 push_long(M.x86.R_EBX);
4609 push_long(M.x86.R_EBP);
4610 push_long(M.x86.R_ESI);
4611 push_long(M.x86.R_EDI);
4615 u16 old_sp = M.x86.R_SP;
4617 push_word(M.x86.R_AX);
4618 push_word(M.x86.R_CX);
4619 push_word(M.x86.R_DX);
4620 push_word(M.x86.R_BX);
4622 push_word(M.x86.R_BP);
4623 push_word(M.x86.R_SI);
4624 push_word(M.x86.R_DI);
4626 DECODE_CLEAR_SEGOVR();
4634 static void x86emuOp_pop_all(u8 X86EMU_UNUSED(op1))
4637 if (M.x86.mode & SYSMODE_PREFIX_DATA)
4639 DECODE_PRINTF(
"POPAD\n");
4643 DECODE_PRINTF(
"POPA\n");
4646 if (M.x86.mode & SYSMODE_PREFIX_DATA)
4648 M.x86.R_EDI = pop_long();
4649 M.x86.R_ESI = pop_long();
4650 M.x86.R_EBP = pop_long();
4652 M.x86.R_EBX = pop_long();
4653 M.x86.R_EDX = pop_long();
4654 M.x86.R_ECX = pop_long();
4655 M.x86.R_EAX = pop_long();
4659 M.x86.R_DI = pop_word();
4660 M.x86.R_SI = pop_word();
4661 M.x86.R_BP = pop_word();
4663 M.x86.R_BX = pop_word();
4664 M.x86.R_DX = pop_word();
4665 M.x86.R_CX = pop_word();
4666 M.x86.R_AX = pop_word();
4668 DECODE_CLEAR_SEGOVR();
4679 static void x86emuOp_segovr_FS(u8 X86EMU_UNUSED(op1))
4682 DECODE_PRINTF(
"FS:\n");
4684 M.x86.mode |= SYSMODE_SEGOVR_FS;
4696 static void x86emuOp_segovr_GS(u8 X86EMU_UNUSED(op1))
4699 DECODE_PRINTF(
"GS:\n");
4701 M.x86.mode |= SYSMODE_SEGOVR_GS;
4713 static void x86emuOp_prefix_data(u8 X86EMU_UNUSED(op1))
4716 DECODE_PRINTF(
"DATA:\n");
4718 M.x86.mode |= SYSMODE_PREFIX_DATA;
4727 static void x86emuOp_prefix_addr(u8 X86EMU_UNUSED(op1))
4730 DECODE_PRINTF(
"ADDR:\n");
4732 M.x86.mode |= SYSMODE_PREFIX_ADDR;
4741 static void x86emuOp_push_word_IMM(u8 X86EMU_UNUSED(op1))
4746 if (M.x86.mode & SYSMODE_PREFIX_DATA)
4748 imm = fetch_long_imm();
4752 imm = fetch_word_imm();
4754 DECODE_PRINTF2(
"PUSH\t%x\n", imm);
4756 if (M.x86.mode & SYSMODE_PREFIX_DATA)
4762 push_word((u16) imm);
4764 DECODE_CLEAR_SEGOVR();
4772 static void x86emuOp_imul_word_IMM(u8 X86EMU_UNUSED(op1))
4778 DECODE_PRINTF(
"IMUL\t");
4779 FETCH_DECODE_MODRM(mod, rh, rl);
4783 if (M.x86.mode & SYSMODE_PREFIX_DATA)
4790 destreg = DECODE_RM_LONG_REGISTER(rh);
4792 srcoffset = decode_rm00_address(rl);
4793 srcval = fetch_data_long(srcoffset);
4794 imm = fetch_long_imm();
4795 DECODE_PRINTF2(
",%d\n", (s32) imm);
4797 imul_long_direct(&res_lo, &res_hi, (s32) srcval, (s32) imm);
4808 *destreg = (u32) res_lo;
4817 destreg = DECODE_RM_WORD_REGISTER(rh);
4819 srcoffset = decode_rm00_address(rl);
4820 srcval = fetch_data_word(srcoffset);
4821 imm = fetch_word_imm();
4822 DECODE_PRINTF2(
",%d\n", (s32) imm);
4824 res = (s16) srcval * (s16) imm;
4835 *destreg = (u16) res;
4839 if (M.x86.mode & SYSMODE_PREFIX_DATA)
4846 destreg = DECODE_RM_LONG_REGISTER(rh);
4848 srcoffset = decode_rm01_address(rl);
4849 srcval = fetch_data_long(srcoffset);
4850 imm = fetch_long_imm();
4851 DECODE_PRINTF2(
",%d\n", (s32) imm);
4853 imul_long_direct(&res_lo, &res_hi, (s32) srcval, (s32) imm);
4864 *destreg = (u32) res_lo;
4873 destreg = DECODE_RM_WORD_REGISTER(rh);
4875 srcoffset = decode_rm01_address(rl);
4876 srcval = fetch_data_word(srcoffset);
4877 imm = fetch_word_imm();
4878 DECODE_PRINTF2(
",%d\n", (s32) imm);
4880 res = (s16) srcval * (s16) imm;
4891 *destreg = (u16) res;
4895 if (M.x86.mode & SYSMODE_PREFIX_DATA)
4902 destreg = DECODE_RM_LONG_REGISTER(rh);
4904 srcoffset = decode_rm10_address(rl);
4905 srcval = fetch_data_long(srcoffset);
4906 imm = fetch_long_imm();
4907 DECODE_PRINTF2(
",%d\n", (s32) imm);
4909 imul_long_direct(&res_lo, &res_hi, (s32) srcval, (s32) imm);
4920 *destreg = (u32) res_lo;
4929 destreg = DECODE_RM_WORD_REGISTER(rh);
4931 srcoffset = decode_rm10_address(rl);
4932 srcval = fetch_data_word(srcoffset);
4933 imm = fetch_word_imm();
4934 DECODE_PRINTF2(
",%d\n", (s32) imm);
4936 res = (s16) srcval * (s16) imm;
4947 *destreg = (u16) res;
4951 if (M.x86.mode & SYSMODE_PREFIX_DATA)
4953 u32 *destreg, *srcreg;
4957 destreg = DECODE_RM_LONG_REGISTER(rh);
4959 srcreg = DECODE_RM_LONG_REGISTER(rl);
4960 imm = fetch_long_imm();
4961 DECODE_PRINTF2(
",%d\n", (s32) imm);
4963 imul_long_direct(&res_lo, &res_hi, (s32) *srcreg, (s32) imm);
4974 *destreg = (u32) res_lo;
4978 u16 *destreg, *srcreg;
4982 destreg = DECODE_RM_WORD_REGISTER(rh);
4984 srcreg = DECODE_RM_WORD_REGISTER(rl);
4985 imm = fetch_word_imm();
4986 DECODE_PRINTF2(
",%d\n", (s32) imm);
4987 res = (s16) *srcreg * (s16) imm;
4998 *destreg = (u16) res;
5002 DECODE_CLEAR_SEGOVR();
5010 static void x86emuOp_push_byte_IMM(u8 X86EMU_UNUSED(op1))
5015 imm = (s8) fetch_byte_imm();
5016 DECODE_PRINTF2(
"PUSH\t%d\n", imm);
5018 if (M.x86.mode & SYSMODE_PREFIX_DATA)
5020 push_long((s32) imm);
5026 DECODE_CLEAR_SEGOVR();
5034 static void x86emuOp_imul_byte_IMM(u8 X86EMU_UNUSED(op1))
5041 DECODE_PRINTF(
"IMUL\t");
5042 FETCH_DECODE_MODRM(mod, rh, rl);
5046 if (M.x86.mode & SYSMODE_PREFIX_DATA)
5052 destreg = DECODE_RM_LONG_REGISTER(rh);
5054 srcoffset = decode_rm00_address(rl);
5055 srcval = fetch_data_long(srcoffset);
5056 imm = fetch_byte_imm();
5057 DECODE_PRINTF2(
",%d\n", (s32) imm);
5059 imul_long_direct(&res_lo, &res_hi, (s32) srcval, (s32) imm);
5070 *destreg = (u32) res_lo;
5078 destreg = DECODE_RM_WORD_REGISTER(rh);
5080 srcoffset = decode_rm00_address(rl);
5081 srcval = fetch_data_word(srcoffset);
5082 imm = fetch_byte_imm();
5083 DECODE_PRINTF2(
",%d\n", (s32) imm);
5085 res = (s16) srcval * (s16) imm;
5096 *destreg = (u16) res;
5100 if (M.x86.mode & SYSMODE_PREFIX_DATA)
5106 destreg = DECODE_RM_LONG_REGISTER(rh);
5108 srcoffset = decode_rm01_address(rl);
5109 srcval = fetch_data_long(srcoffset);
5110 imm = fetch_byte_imm();
5111 DECODE_PRINTF2(
",%d\n", (s32) imm);
5113 imul_long_direct(&res_lo, &res_hi, (s32) srcval, (s32) imm);
5124 *destreg = (u32) res_lo;
5132 destreg = DECODE_RM_WORD_REGISTER(rh);
5134 srcoffset = decode_rm01_address(rl);
5135 srcval = fetch_data_word(srcoffset);
5136 imm = fetch_byte_imm();
5137 DECODE_PRINTF2(
",%d\n", (s32) imm);
5139 res = (s16) srcval * (s16) imm;
5150 *destreg = (u16) res;
5154 if (M.x86.mode & SYSMODE_PREFIX_DATA)
5160 destreg = DECODE_RM_LONG_REGISTER(rh);
5162 srcoffset = decode_rm10_address(rl);
5163 srcval = fetch_data_long(srcoffset);
5164 imm = fetch_byte_imm();
5165 DECODE_PRINTF2(
",%d\n", (s32) imm);
5167 imul_long_direct(&res_lo, &res_hi, (s32) srcval, (s32) imm);
5178 *destreg = (u32) res_lo;
5186 destreg = DECODE_RM_WORD_REGISTER(rh);
5188 srcoffset = decode_rm10_address(rl);
5189 srcval = fetch_data_word(srcoffset);
5190 imm = fetch_byte_imm();
5191 DECODE_PRINTF2(
",%d\n", (s32) imm);
5193 res = (s16) srcval * (s16) imm;
5204 *destreg = (u16) res;
5208 if (M.x86.mode & SYSMODE_PREFIX_DATA)
5210 u32 *destreg, *srcreg;
5213 destreg = DECODE_RM_LONG_REGISTER(rh);
5215 srcreg = DECODE_RM_LONG_REGISTER(rl);
5216 imm = fetch_byte_imm();
5217 DECODE_PRINTF2(
",%d\n", (s32) imm);
5219 imul_long_direct(&res_lo, &res_hi, (s32) *srcreg, (s32) imm);
5230 *destreg = (u32) res_lo;
5234 u16 *destreg, *srcreg;
5237 destreg = DECODE_RM_WORD_REGISTER(rh);
5239 srcreg = DECODE_RM_WORD_REGISTER(rl);
5240 imm = fetch_byte_imm();
5241 DECODE_PRINTF2(
",%d\n", (s32) imm);
5242 res = (s16) *srcreg * (s16) imm;
5253 *destreg = (u16) res;
5257 DECODE_CLEAR_SEGOVR();
5265 static void x86emuOp_ins_byte(u8 X86EMU_UNUSED(op1))
5268 DECODE_PRINTF(
"INSB\n");
5271 DECODE_CLEAR_SEGOVR();
5279 static void x86emuOp_ins_word(u8 X86EMU_UNUSED(op1))
5282 if (M.x86.mode & SYSMODE_PREFIX_DATA)
5284 DECODE_PRINTF(
"INSD\n");
5289 DECODE_PRINTF(
"INSW\n");
5293 DECODE_CLEAR_SEGOVR();
5301 static void x86emuOp_outs_byte(u8 X86EMU_UNUSED(op1))
5304 DECODE_PRINTF(
"OUTSB\n");
5307 DECODE_CLEAR_SEGOVR();
5315 static void x86emuOp_outs_word(u8 X86EMU_UNUSED(op1))
5318 if (M.x86.mode & SYSMODE_PREFIX_DATA)
5320 DECODE_PRINTF(
"OUTSD\n");
5325 DECODE_PRINTF(
"OUTSW\n");
5329 DECODE_CLEAR_SEGOVR();
5337 static void x86emuOp_jump_near_O(u8 X86EMU_UNUSED(op1))
5344 DECODE_PRINTF(
"JO\t");
5345 offset = (s8) fetch_byte_imm();
5346 target = (u16)(M.x86.R_IP + (s16) offset);
5347 DECODE_PRINTF2(
"%x\n", target);
5349 if (ACCESS_FLAG(F_OF))
5350 M.x86.R_IP = target;
5351 DECODE_CLEAR_SEGOVR();
5359 static void x86emuOp_jump_near_NO(u8 X86EMU_UNUSED(op1))
5366 DECODE_PRINTF(
"JNO\t");
5367 offset = (s8) fetch_byte_imm();
5368 target = (u16)(M.x86.R_IP + (s16) offset);
5369 DECODE_PRINTF2(
"%x\n", target);
5371 if (!ACCESS_FLAG(F_OF))
5372 M.x86.R_IP = target;
5373 DECODE_CLEAR_SEGOVR();
5381 static void x86emuOp_jump_near_B(u8 X86EMU_UNUSED(op1))
5388 DECODE_PRINTF(
"JB\t");
5389 offset = (s8) fetch_byte_imm();
5390 target = (u16)(M.x86.R_IP + (s16) offset);
5391 DECODE_PRINTF2(
"%x\n", target);
5393 if (ACCESS_FLAG(F_CF))
5394 M.x86.R_IP = target;
5395 DECODE_CLEAR_SEGOVR();
5403 static void x86emuOp_jump_near_NB(u8 X86EMU_UNUSED(op1))
5410 DECODE_PRINTF(
"JNB\t");
5411 offset = (s8) fetch_byte_imm();
5412 target = (u16)(M.x86.R_IP + (s16) offset);
5413 DECODE_PRINTF2(
"%x\n", target);
5415 if (!ACCESS_FLAG(F_CF))
5416 M.x86.R_IP = target;
5417 DECODE_CLEAR_SEGOVR();
5425 static void x86emuOp_jump_near_Z(u8 X86EMU_UNUSED(op1))
5432 DECODE_PRINTF(
"JZ\t");
5433 offset = (s8) fetch_byte_imm();
5434 target = (u16)(M.x86.R_IP + (s16) offset);
5435 DECODE_PRINTF2(
"%x\n", target);
5437 if (ACCESS_FLAG(F_ZF))
5438 M.x86.R_IP = target;
5439 DECODE_CLEAR_SEGOVR();
5447 static void x86emuOp_jump_near_NZ(u8 X86EMU_UNUSED(op1))
5454 DECODE_PRINTF(
"JNZ\t");
5455 offset = (s8) fetch_byte_imm();
5456 target = (u16)(M.x86.R_IP + (s16) offset);
5457 DECODE_PRINTF2(
"%x\n", target);
5459 if (!ACCESS_FLAG(F_ZF))
5460 M.x86.R_IP = target;
5461 DECODE_CLEAR_SEGOVR();
5469 static void x86emuOp_jump_near_BE(u8 X86EMU_UNUSED(op1))
5477 DECODE_PRINTF(
"JBE\t");
5478 offset = (s8) fetch_byte_imm();
5479 target = (u16)(M.x86.R_IP + (s16) offset);
5480 DECODE_PRINTF2(
"%x\n", target);
5482 if (ACCESS_FLAG(F_CF) || ACCESS_FLAG(F_ZF))
5483 M.x86.R_IP = target;
5484 DECODE_CLEAR_SEGOVR();
5492 static void x86emuOp_jump_near_NBE(u8 X86EMU_UNUSED(op1))
5500 DECODE_PRINTF(
"JNBE\t");
5501 offset = (s8) fetch_byte_imm();
5502 target = (u16)(M.x86.R_IP + (s16) offset);
5503 DECODE_PRINTF2(
"%x\n", target);
5505 if (!(ACCESS_FLAG(F_CF) || ACCESS_FLAG(F_ZF)))
5506 M.x86.R_IP = target;
5507 DECODE_CLEAR_SEGOVR();
5515 static void x86emuOp_jump_near_S(u8 X86EMU_UNUSED(op1))
5522 DECODE_PRINTF(
"JS\t");
5523 offset = (s8) fetch_byte_imm();
5524 target = (u16)(M.x86.R_IP + (s16) offset);
5525 DECODE_PRINTF2(
"%x\n", target);
5527 if (ACCESS_FLAG(F_SF))
5528 M.x86.R_IP = target;
5529 DECODE_CLEAR_SEGOVR();
5537 static void x86emuOp_jump_near_NS(u8 X86EMU_UNUSED(op1))
5544 DECODE_PRINTF(
"JNS\t");
5545 offset = (s8) fetch_byte_imm();
5546 target = (u16)(M.x86.R_IP + (s16) offset);
5547 DECODE_PRINTF2(
"%x\n", target);
5549 if (!ACCESS_FLAG(F_SF))
5550 M.x86.R_IP = target;
5551 DECODE_CLEAR_SEGOVR();
5559 static void x86emuOp_jump_near_P(u8 X86EMU_UNUSED(op1))
5566 DECODE_PRINTF(
"JP\t");
5567 offset = (s8) fetch_byte_imm();
5568 target = (u16)(M.x86.R_IP + (s16) offset);
5569 DECODE_PRINTF2(
"%x\n", target);
5571 if (ACCESS_FLAG(F_PF))
5572 M.x86.R_IP = target;
5573 DECODE_CLEAR_SEGOVR();
5581 static void x86emuOp_jump_near_NP(u8 X86EMU_UNUSED(op1))
5588 DECODE_PRINTF(
"JNP\t");
5589 offset = (s8) fetch_byte_imm();
5590 target = (u16)(M.x86.R_IP + (s16) offset);
5591 DECODE_PRINTF2(
"%x\n", target);
5593 if (!ACCESS_FLAG(F_PF))
5594 M.x86.R_IP = target;
5595 DECODE_CLEAR_SEGOVR();
5603 static void x86emuOp_jump_near_L(u8 X86EMU_UNUSED(op1))
5611 DECODE_PRINTF(
"JL\t");
5612 offset = (s8) fetch_byte_imm();
5613 target = (u16)(M.x86.R_IP + (s16) offset);
5614 DECODE_PRINTF2(
"%x\n", target);
5616 sf = ACCESS_FLAG(F_SF) != 0;
5617 of = ACCESS_FLAG(F_OF) != 0;
5619 M.x86.R_IP = target;
5620 DECODE_CLEAR_SEGOVR();
5628 static void x86emuOp_jump_near_NL(u8 X86EMU_UNUSED(op1))
5636 DECODE_PRINTF(
"JNL\t");
5637 offset = (s8) fetch_byte_imm();
5638 target = (u16)(M.x86.R_IP + (s16) offset);
5639 DECODE_PRINTF2(
"%x\n", target);
5641 sf = ACCESS_FLAG(F_SF) != 0;
5642 of = ACCESS_FLAG(F_OF) != 0;
5645 M.x86.R_IP = target;
5646 DECODE_CLEAR_SEGOVR();
5654 static void x86emuOp_jump_near_LE(u8 X86EMU_UNUSED(op1))
5663 DECODE_PRINTF(
"JLE\t");
5664 offset = (s8) fetch_byte_imm();
5665 target = (u16)(M.x86.R_IP + (s16) offset);
5666 DECODE_PRINTF2(
"%x\n", target);
5668 sf = ACCESS_FLAG(F_SF) != 0;
5669 of = ACCESS_FLAG(F_OF) != 0;
5670 if ((sf ^ of) || ACCESS_FLAG(F_ZF))
5671 M.x86.R_IP = target;
5672 DECODE_CLEAR_SEGOVR();
5680 static void x86emuOp_jump_near_NLE(u8 X86EMU_UNUSED(op1))
5689 DECODE_PRINTF(
"JNLE\t");
5690 offset = (s8) fetch_byte_imm();
5691 target = (u16)(M.x86.R_IP + (s16) offset);
5692 DECODE_PRINTF2(
"%x\n", target);
5694 sf = ACCESS_FLAG(F_SF) != 0;
5695 of = ACCESS_FLAG(F_OF) != 0;
5696 if ((sf == of) && !ACCESS_FLAG(F_ZF))
5697 M.x86.R_IP = target;
5698 DECODE_CLEAR_SEGOVR();
5702 static u8 (*opc80_byte_operation[])(u8 d, u8 s) = {
5717 static void x86emuOp_opc80_byte_RM_IMM(u8 X86EMU_UNUSED(op1))
5731 FETCH_DECODE_MODRM(mod, rh, rl);
5743 DECODE_PRINTF(
"ADD\t");
5746 DECODE_PRINTF(
"OR\t");
5749 DECODE_PRINTF(
"ADC\t");
5752 DECODE_PRINTF(
"SBB\t");
5755 DECODE_PRINTF(
"AND\t");
5758 DECODE_PRINTF(
"SUB\t");
5761 DECODE_PRINTF(
"XOR\t");
5764 DECODE_PRINTF(
"CMP\t");
5774 DECODE_PRINTF(
"BYTE PTR ");
5775 destoffset = decode_rm00_address(rl);
5777 destval = fetch_data_byte(destoffset);
5778 imm = fetch_byte_imm();
5779 DECODE_PRINTF2(
"%x\n", imm);
5781 destval = (*opc80_byte_operation[rh])(destval, imm);
5783 store_data_byte(destoffset, destval);
5786 DECODE_PRINTF(
"BYTE PTR ");
5787 destoffset = decode_rm01_address(rl);
5789 destval = fetch_data_byte(destoffset);
5790 imm = fetch_byte_imm();
5791 DECODE_PRINTF2(
"%x\n", imm);
5793 destval = (*opc80_byte_operation[rh])(destval, imm);
5795 store_data_byte(destoffset, destval);
5798 DECODE_PRINTF(
"BYTE PTR ");
5799 destoffset = decode_rm10_address(rl);
5801 destval = fetch_data_byte(destoffset);
5802 imm = fetch_byte_imm();
5803 DECODE_PRINTF2(
"%x\n", imm);
5805 destval = (*opc80_byte_operation[rh])(destval, imm);
5807 store_data_byte(destoffset, destval);
5810 destreg = DECODE_RM_BYTE_REGISTER(rl);
5812 imm = fetch_byte_imm();
5813 DECODE_PRINTF2(
"%x\n", imm);
5815 destval = (*opc80_byte_operation[rh])(*destreg, imm);
5820 DECODE_CLEAR_SEGOVR();
5824 static u16 (*opc81_word_operation[])(u16 d, u16 s) = {
5835 static u32 (*opc81_long_operation[])(u32 d, u32 s) = {
5850 static void x86emuOp_opc81_word_RM_IMM(u8 X86EMU_UNUSED(op1))
5861 FETCH_DECODE_MODRM(mod, rh, rl);
5873 DECODE_PRINTF(
"ADD\t");
5876 DECODE_PRINTF(
"OR\t");
5879 DECODE_PRINTF(
"ADC\t");
5882 DECODE_PRINTF(
"SBB\t");
5885 DECODE_PRINTF(
"AND\t");
5888 DECODE_PRINTF(
"SUB\t");
5891 DECODE_PRINTF(
"XOR\t");
5894 DECODE_PRINTF(
"CMP\t");
5906 if (M.x86.mode & SYSMODE_PREFIX_DATA)
5910 DECODE_PRINTF(
"DWORD PTR ");
5911 destoffset = decode_rm00_address(rl);
5913 destval = fetch_data_long(destoffset);
5914 imm = fetch_long_imm();
5915 DECODE_PRINTF2(
"%x\n", imm);
5917 destval = (*opc81_long_operation[rh])(destval, imm);
5919 store_data_long(destoffset, destval);
5925 DECODE_PRINTF(
"WORD PTR ");
5926 destoffset = decode_rm00_address(rl);
5928 destval = fetch_data_word(destoffset);
5929 imm = fetch_word_imm();
5930 DECODE_PRINTF2(
"%x\n", imm);
5932 destval = (*opc81_word_operation[rh])(destval, imm);
5934 store_data_word(destoffset, destval);
5938 if (M.x86.mode & SYSMODE_PREFIX_DATA)
5942 DECODE_PRINTF(
"DWORD PTR ");
5943 destoffset = decode_rm01_address(rl);
5945 destval = fetch_data_long(destoffset);
5946 imm = fetch_long_imm();
5947 DECODE_PRINTF2(
"%x\n", imm);
5949 destval = (*opc81_long_operation[rh])(destval, imm);
5951 store_data_long(destoffset, destval);
5957 DECODE_PRINTF(
"WORD PTR ");
5958 destoffset = decode_rm01_address(rl);
5960 destval = fetch_data_word(destoffset);
5961 imm = fetch_word_imm();
5962 DECODE_PRINTF2(
"%x\n", imm);
5964 destval = (*opc81_word_operation[rh])(destval, imm);
5966 store_data_word(destoffset, destval);
5970 if (M.x86.mode & SYSMODE_PREFIX_DATA)
5974 DECODE_PRINTF(
"DWORD PTR ");
5975 destoffset = decode_rm10_address(rl);
5977 destval = fetch_data_long(destoffset);
5978 imm = fetch_long_imm();
5979 DECODE_PRINTF2(
"%x\n", imm);
5981 destval = (*opc81_long_operation[rh])(destval, imm);
5983 store_data_long(destoffset, destval);
5989 DECODE_PRINTF(
"WORD PTR ");
5990 destoffset = decode_rm10_address(rl);
5992 destval = fetch_data_word(destoffset);
5993 imm = fetch_word_imm();
5994 DECODE_PRINTF2(
"%x\n", imm);
5996 destval = (*opc81_word_operation[rh])(destval, imm);
5998 store_data_word(destoffset, destval);
6002 if (M.x86.mode & SYSMODE_PREFIX_DATA)
6007 destreg = DECODE_RM_LONG_REGISTER(rl);
6009 imm = fetch_long_imm();
6010 DECODE_PRINTF2(
"%x\n", imm);
6012 destval = (*opc81_long_operation[rh])(*destreg, imm);
6021 destreg = DECODE_RM_WORD_REGISTER(rl);
6023 imm = fetch_word_imm();
6024 DECODE_PRINTF2(
"%x\n", imm);
6026 destval = (*opc81_word_operation[rh])(*destreg, imm);
6032 DECODE_CLEAR_SEGOVR();
6036 static u8 (*opc82_byte_operation[])(u8 s, u8 d) = {
6054 static void x86emuOp_opc82_byte_RM_IMM(u8 X86EMU_UNUSED(op1))
6069 FETCH_DECODE_MODRM(mod, rh, rl);
6080 DECODE_PRINTF(
"ADD\t");
6083 DECODE_PRINTF(
"OR\t");
6086 DECODE_PRINTF(
"ADC\t");
6089 DECODE_PRINTF(
"SBB\t");
6092 DECODE_PRINTF(
"AND\t");
6095 DECODE_PRINTF(
"SUB\t");
6098 DECODE_PRINTF(
"XOR\t");
6101 DECODE_PRINTF(
"CMP\t");
6111 DECODE_PRINTF(
"BYTE PTR ");
6112 destoffset = decode_rm00_address(rl);
6113 destval = fetch_data_byte(destoffset);
6114 imm = fetch_byte_imm();
6115 DECODE_PRINTF2(
",%x\n", imm);
6117 destval = (*opc82_byte_operation[rh])(destval, imm);
6119 store_data_byte(destoffset, destval);
6122 DECODE_PRINTF(
"BYTE PTR ");
6123 destoffset = decode_rm01_address(rl);
6124 destval = fetch_data_byte(destoffset);
6125 imm = fetch_byte_imm();
6126 DECODE_PRINTF2(
",%x\n", imm);
6128 destval = (*opc82_byte_operation[rh])(destval, imm);
6130 store_data_byte(destoffset, destval);
6133 DECODE_PRINTF(
"BYTE PTR ");
6134 destoffset = decode_rm10_address(rl);
6135 destval = fetch_data_byte(destoffset);
6136 imm = fetch_byte_imm();
6137 DECODE_PRINTF2(
",%x\n", imm);
6139 destval = (*opc82_byte_operation[rh])(destval, imm);
6141 store_data_byte(destoffset, destval);
6144 destreg = DECODE_RM_BYTE_REGISTER(rl);
6145 imm = fetch_byte_imm();
6146 DECODE_PRINTF2(
",%x\n", imm);
6148 destval = (*opc82_byte_operation[rh])(*destreg, imm);
6153 DECODE_CLEAR_SEGOVR();
6157 static u16 (*opc83_word_operation[])(u16 s, u16 d) = {
6171 static u32 (*opc83_long_operation[])(u32 s, u32 d) = {
6189 static void x86emuOp_opc83_word_RM_IMM(u8 X86EMU_UNUSED(op1))
6201 FETCH_DECODE_MODRM(mod, rh, rl);
6212 DECODE_PRINTF(
"ADD\t");
6215 DECODE_PRINTF(
"OR\t");
6218 DECODE_PRINTF(
"ADC\t");
6221 DECODE_PRINTF(
"SBB\t");
6224 DECODE_PRINTF(
"AND\t");
6227 DECODE_PRINTF(
"SUB\t");
6230 DECODE_PRINTF(
"XOR\t");
6233 DECODE_PRINTF(
"CMP\t");
6243 if (M.x86.mode & SYSMODE_PREFIX_DATA)
6247 DECODE_PRINTF(
"DWORD PTR ");
6248 destoffset = decode_rm00_address(rl);
6249 destval = fetch_data_long(destoffset);
6250 imm = (s8) fetch_byte_imm();
6251 DECODE_PRINTF2(
",%x\n", imm);
6253 destval = (*opc83_long_operation[rh])(destval, imm);
6255 store_data_long(destoffset, destval);
6261 DECODE_PRINTF(
"WORD PTR ");
6262 destoffset = decode_rm00_address(rl);
6263 destval = fetch_data_word(destoffset);
6264 imm = (s8) fetch_byte_imm();
6265 DECODE_PRINTF2(
",%x\n", imm);
6267 destval = (*opc83_word_operation[rh])(destval, imm);
6269 store_data_word(destoffset, destval);
6273 if (M.x86.mode & SYSMODE_PREFIX_DATA)
6277 DECODE_PRINTF(
"DWORD PTR ");
6278 destoffset = decode_rm01_address(rl);
6279 destval = fetch_data_long(destoffset);
6280 imm = (s8) fetch_byte_imm();
6281 DECODE_PRINTF2(
",%x\n", imm);
6283 destval = (*opc83_long_operation[rh])(destval, imm);
6285 store_data_long(destoffset, destval);
6291 DECODE_PRINTF(
"WORD PTR ");
6292 destoffset = decode_rm01_address(rl);
6293 destval = fetch_data_word(destoffset);
6294 imm = (s8) fetch_byte_imm();
6295 DECODE_PRINTF2(
",%x\n", imm);
6297 destval = (*opc83_word_operation[rh])(destval, imm);
6299 store_data_word(destoffset, destval);
6303 if (M.x86.mode & SYSMODE_PREFIX_DATA)
6307 DECODE_PRINTF(
"DWORD PTR ");
6308 destoffset = decode_rm10_address(rl);
6309 destval = fetch_data_long(destoffset);
6310 imm = (s8) fetch_byte_imm();
6311 DECODE_PRINTF2(
",%x\n", imm);
6313 destval = (*opc83_long_operation[rh])(destval, imm);
6315 store_data_long(destoffset, destval);
6321 DECODE_PRINTF(
"WORD PTR ");
6322 destoffset = decode_rm10_address(rl);
6323 destval = fetch_data_word(destoffset);
6324 imm = (s8) fetch_byte_imm();
6325 DECODE_PRINTF2(
",%x\n", imm);
6327 destval = (*opc83_word_operation[rh])(destval, imm);
6329 store_data_word(destoffset, destval);
6333 if (M.x86.mode & SYSMODE_PREFIX_DATA)
6338 destreg = DECODE_RM_LONG_REGISTER(rl);
6339 imm = (s8) fetch_byte_imm();
6340 DECODE_PRINTF2(
",%x\n", imm);
6342 destval = (*opc83_long_operation[rh])(*destreg, imm);
6351 destreg = DECODE_RM_WORD_REGISTER(rl);
6352 imm = (s8) fetch_byte_imm();
6353 DECODE_PRINTF2(
",%x\n", imm);
6355 destval = (*opc83_word_operation[rh])(*destreg, imm);
6361 DECODE_CLEAR_SEGOVR();
6369 static void x86emuOp_test_byte_RM_R(u8 X86EMU_UNUSED(op1))
6372 u8 *destreg, *srcreg;
6377 DECODE_PRINTF(
"TEST\t");
6378 FETCH_DECODE_MODRM(mod, rh, rl);
6382 destoffset = decode_rm00_address(rl);
6384 destval = fetch_data_byte(destoffset);
6385 srcreg = DECODE_RM_BYTE_REGISTER(rh);
6386 DECODE_PRINTF(
"\n");
6388 test_byte(destval, *srcreg);
6391 destoffset = decode_rm01_address(rl);
6393 destval = fetch_data_byte(destoffset);
6394 srcreg = DECODE_RM_BYTE_REGISTER(rh);
6395 DECODE_PRINTF(
"\n");
6397 test_byte(destval, *srcreg);
6400 destoffset = decode_rm10_address(rl);
6402 destval = fetch_data_byte(destoffset);
6403 srcreg = DECODE_RM_BYTE_REGISTER(rh);
6404 DECODE_PRINTF(
"\n");
6406 test_byte(destval, *srcreg);
6409 destreg = DECODE_RM_BYTE_REGISTER(rl);
6411 srcreg = DECODE_RM_BYTE_REGISTER(rh);
6412 DECODE_PRINTF(
"\n");
6414 test_byte(*destreg, *srcreg);
6417 DECODE_CLEAR_SEGOVR();
6425 static void x86emuOp_test_word_RM_R(u8 X86EMU_UNUSED(op1))
6431 DECODE_PRINTF(
"TEST\t");
6432 FETCH_DECODE_MODRM(mod, rh, rl);
6436 if (M.x86.mode & SYSMODE_PREFIX_DATA)
6441 destoffset = decode_rm00_address(rl);
6443 destval = fetch_data_long(destoffset);
6444 srcreg = DECODE_RM_LONG_REGISTER(rh);
6445 DECODE_PRINTF(
"\n");
6447 test_long(destval, *srcreg);
6454 destoffset = decode_rm00_address(rl);
6456 destval = fetch_data_word(destoffset);
6457 srcreg = DECODE_RM_WORD_REGISTER(rh);
6458 DECODE_PRINTF(
"\n");
6460 test_word(destval, *srcreg);
6464 if (M.x86.mode & SYSMODE_PREFIX_DATA)
6469 destoffset = decode_rm01_address(rl);
6471 destval = fetch_data_long(destoffset);
6472 srcreg = DECODE_RM_LONG_REGISTER(rh);
6473 DECODE_PRINTF(
"\n");
6475 test_long(destval, *srcreg);
6482 destoffset = decode_rm01_address(rl);
6484 destval = fetch_data_word(destoffset);
6485 srcreg = DECODE_RM_WORD_REGISTER(rh);
6486 DECODE_PRINTF(
"\n");
6488 test_word(destval, *srcreg);
6492 if (M.x86.mode & SYSMODE_PREFIX_DATA)
6497 destoffset = decode_rm10_address(rl);
6499 destval = fetch_data_long(destoffset);
6500 srcreg = DECODE_RM_LONG_REGISTER(rh);
6501 DECODE_PRINTF(
"\n");
6503 test_long(destval, *srcreg);
6510 destoffset = decode_rm10_address(rl);
6512 destval = fetch_data_word(destoffset);
6513 srcreg = DECODE_RM_WORD_REGISTER(rh);
6514 DECODE_PRINTF(
"\n");
6516 test_word(destval, *srcreg);
6520 if (M.x86.mode & SYSMODE_PREFIX_DATA)
6522 u32 *destreg, *srcreg;
6524 destreg = DECODE_RM_LONG_REGISTER(rl);
6526 srcreg = DECODE_RM_LONG_REGISTER(rh);
6527 DECODE_PRINTF(
"\n");
6529 test_long(*destreg, *srcreg);
6533 u16 *destreg, *srcreg;
6535 destreg = DECODE_RM_WORD_REGISTER(rl);
6537 srcreg = DECODE_RM_WORD_REGISTER(rh);
6538 DECODE_PRINTF(
"\n");
6540 test_word(*destreg, *srcreg);
6544 DECODE_CLEAR_SEGOVR();
6552 static void x86emuOp_xchg_byte_RM_R(u8 X86EMU_UNUSED(op1))
6555 u8 *destreg, *srcreg;
6561 DECODE_PRINTF(
"XCHG\t");
6562 FETCH_DECODE_MODRM(mod, rh, rl);
6566 destoffset = decode_rm00_address(rl);
6568 destval = fetch_data_byte(destoffset);
6569 srcreg = DECODE_RM_BYTE_REGISTER(rh);
6570 DECODE_PRINTF(
"\n");
6575 store_data_byte(destoffset, destval);
6578 destoffset = decode_rm01_address(rl);
6580 destval = fetch_data_byte(destoffset);
6581 srcreg = DECODE_RM_BYTE_REGISTER(rh);
6582 DECODE_PRINTF(
"\n");
6587 store_data_byte(destoffset, destval);
6590 destoffset = decode_rm10_address(rl);
6592 destval = fetch_data_byte(destoffset);
6593 srcreg = DECODE_RM_BYTE_REGISTER(rh);
6594 DECODE_PRINTF(
"\n");
6599 store_data_byte(destoffset, destval);
6602 destreg = DECODE_RM_BYTE_REGISTER(rl);
6604 srcreg = DECODE_RM_BYTE_REGISTER(rh);
6605 DECODE_PRINTF(
"\n");
6612 DECODE_CLEAR_SEGOVR();
6620 static void x86emuOp_xchg_word_RM_R(u8 X86EMU_UNUSED(op1))
6626 DECODE_PRINTF(
"XCHG\t");
6627 FETCH_DECODE_MODRM(mod, rh, rl);
6631 if (M.x86.mode & SYSMODE_PREFIX_DATA)
6636 destoffset = decode_rm00_address(rl);
6638 destval = fetch_data_long(destoffset);
6639 srcreg = DECODE_RM_LONG_REGISTER(rh);
6640 DECODE_PRINTF(
"\n");
6645 store_data_long(destoffset, destval);
6652 destoffset = decode_rm00_address(rl);
6654 destval = fetch_data_word(destoffset);
6655 srcreg = DECODE_RM_WORD_REGISTER(rh);
6656 DECODE_PRINTF(
"\n");
6661 store_data_word(destoffset, destval);
6665 if (M.x86.mode & SYSMODE_PREFIX_DATA)
6670 destoffset = decode_rm01_address(rl);
6672 destval = fetch_data_long(destoffset);
6673 srcreg = DECODE_RM_LONG_REGISTER(rh);
6674 DECODE_PRINTF(
"\n");
6679 store_data_long(destoffset, destval);
6686 destoffset = decode_rm01_address(rl);
6688 destval = fetch_data_word(destoffset);
6689 srcreg = DECODE_RM_WORD_REGISTER(rh);
6690 DECODE_PRINTF(
"\n");
6695 store_data_word(destoffset, destval);
6699 if (M.x86.mode & SYSMODE_PREFIX_DATA)
6704 destoffset = decode_rm10_address(rl);
6706 destval = fetch_data_long(destoffset);
6707 srcreg = DECODE_RM_LONG_REGISTER(rh);
6708 DECODE_PRINTF(
"\n");
6713 store_data_long(destoffset, destval);
6720 destoffset = decode_rm10_address(rl);
6722 destval = fetch_data_word(destoffset);
6723 srcreg = DECODE_RM_WORD_REGISTER(rh);
6724 DECODE_PRINTF(
"\n");
6729 store_data_word(destoffset, destval);
6733 if (M.x86.mode & SYSMODE_PREFIX_DATA)
6735 u32 *destreg, *srcreg;
6738 destreg = DECODE_RM_LONG_REGISTER(rl);
6740 srcreg = DECODE_RM_LONG_REGISTER(rh);
6741 DECODE_PRINTF(
"\n");
6749 u16 *destreg, *srcreg;
6752 destreg = DECODE_RM_WORD_REGISTER(rl);
6754 srcreg = DECODE_RM_WORD_REGISTER(rh);
6755 DECODE_PRINTF(
"\n");
6763 DECODE_CLEAR_SEGOVR();
6771 static void x86emuOp_mov_byte_RM_R(u8 X86EMU_UNUSED(op1))
6774 u8 *destreg, *srcreg;
6778 DECODE_PRINTF(
"MOV\t");
6779 FETCH_DECODE_MODRM(mod, rh, rl);
6783 destoffset = decode_rm00_address(rl);
6785 srcreg = DECODE_RM_BYTE_REGISTER(rh);
6786 DECODE_PRINTF(
"\n");
6788 store_data_byte(destoffset, *srcreg);
6791 destoffset = decode_rm01_address(rl);
6793 srcreg = DECODE_RM_BYTE_REGISTER(rh);
6794 DECODE_PRINTF(
"\n");
6796 store_data_byte(destoffset, *srcreg);
6799 destoffset = decode_rm10_address(rl);
6801 srcreg = DECODE_RM_BYTE_REGISTER(rh);
6802 DECODE_PRINTF(
"\n");
6804 store_data_byte(destoffset, *srcreg);
6807 destreg = DECODE_RM_BYTE_REGISTER(rl);
6809 srcreg = DECODE_RM_BYTE_REGISTER(rh);
6810 DECODE_PRINTF(
"\n");
6815 DECODE_CLEAR_SEGOVR();
6823 static void x86emuOp_mov_word_RM_R(u8 X86EMU_UNUSED(op1))
6829 DECODE_PRINTF(
"MOV\t");
6830 FETCH_DECODE_MODRM(mod, rh, rl);
6834 if (M.x86.mode & SYSMODE_PREFIX_DATA)
6838 destoffset = decode_rm00_address(rl);
6840 srcreg = DECODE_RM_LONG_REGISTER(rh);
6841 DECODE_PRINTF(
"\n");
6843 store_data_long(destoffset, *srcreg);
6849 destoffset = decode_rm00_address(rl);
6851 srcreg = DECODE_RM_WORD_REGISTER(rh);
6852 DECODE_PRINTF(
"\n");
6854 store_data_word(destoffset, *srcreg);
6858 if (M.x86.mode & SYSMODE_PREFIX_DATA)
6862 destoffset = decode_rm01_address(rl);
6864 srcreg = DECODE_RM_LONG_REGISTER(rh);
6865 DECODE_PRINTF(
"\n");
6867 store_data_long(destoffset, *srcreg);
6873 destoffset = decode_rm01_address(rl);
6875 srcreg = DECODE_RM_WORD_REGISTER(rh);
6876 DECODE_PRINTF(
"\n");
6878 store_data_word(destoffset, *srcreg);
6882 if (M.x86.mode & SYSMODE_PREFIX_DATA)
6886 destoffset = decode_rm10_address(rl);
6888 srcreg = DECODE_RM_LONG_REGISTER(rh);
6889 DECODE_PRINTF(
"\n");
6891 store_data_long(destoffset, *srcreg);
6897 destoffset = decode_rm10_address(rl);
6899 srcreg = DECODE_RM_WORD_REGISTER(rh);
6900 DECODE_PRINTF(
"\n");
6902 store_data_word(destoffset, *srcreg);
6906 if (M.x86.mode & SYSMODE_PREFIX_DATA)
6908 u32 *destreg, *srcreg;
6910 destreg = DECODE_RM_LONG_REGISTER(rl);
6912 srcreg = DECODE_RM_LONG_REGISTER(rh);
6913 DECODE_PRINTF(
"\n");
6919 u16 *destreg, *srcreg;
6921 destreg = DECODE_RM_WORD_REGISTER(rl);
6923 srcreg = DECODE_RM_WORD_REGISTER(rh);
6924 DECODE_PRINTF(
"\n");
6930 DECODE_CLEAR_SEGOVR();
6938 static void x86emuOp_mov_byte_R_RM(u8 X86EMU_UNUSED(op1))
6941 u8 *destreg, *srcreg;
6946 DECODE_PRINTF(
"MOV\t");
6947 FETCH_DECODE_MODRM(mod, rh, rl);
6951 destreg = DECODE_RM_BYTE_REGISTER(rh);
6953 srcoffset = decode_rm00_address(rl);
6954 srcval = fetch_data_byte(srcoffset);
6955 DECODE_PRINTF(
"\n");
6960 destreg = DECODE_RM_BYTE_REGISTER(rh);
6962 srcoffset = decode_rm01_address(rl);
6963 srcval = fetch_data_byte(srcoffset);
6964 DECODE_PRINTF(
"\n");
6969 destreg = DECODE_RM_BYTE_REGISTER(rh);
6971 srcoffset = decode_rm10_address(rl);
6972 srcval = fetch_data_byte(srcoffset);
6973 DECODE_PRINTF(
"\n");
6978 destreg = DECODE_RM_BYTE_REGISTER(rh);
6980 srcreg = DECODE_RM_BYTE_REGISTER(rl);
6981 DECODE_PRINTF(
"\n");
6986 DECODE_CLEAR_SEGOVR();
6994 static void x86emuOp_mov_word_R_RM(u8 X86EMU_UNUSED(op1))
7000 DECODE_PRINTF(
"MOV\t");
7001 FETCH_DECODE_MODRM(mod, rh, rl);
7005 if (M.x86.mode & SYSMODE_PREFIX_DATA)
7010 destreg = DECODE_RM_LONG_REGISTER(rh);
7012 srcoffset = decode_rm00_address(rl);
7013 srcval = fetch_data_long(srcoffset);
7014 DECODE_PRINTF(
"\n");
7023 destreg = DECODE_RM_WORD_REGISTER(rh);
7025 srcoffset = decode_rm00_address(rl);
7026 srcval = fetch_data_word(srcoffset);
7027 DECODE_PRINTF(
"\n");
7033 if (M.x86.mode & SYSMODE_PREFIX_DATA)
7038 destreg = DECODE_RM_LONG_REGISTER(rh);
7040 srcoffset = decode_rm01_address(rl);
7041 srcval = fetch_data_long(srcoffset);
7042 DECODE_PRINTF(
"\n");
7051 destreg = DECODE_RM_WORD_REGISTER(rh);
7053 srcoffset = decode_rm01_address(rl);
7054 srcval = fetch_data_word(srcoffset);
7055 DECODE_PRINTF(
"\n");
7061 if (M.x86.mode & SYSMODE_PREFIX_DATA)
7066 destreg = DECODE_RM_LONG_REGISTER(rh);
7068 srcoffset = decode_rm10_address(rl);
7069 srcval = fetch_data_long(srcoffset);
7070 DECODE_PRINTF(
"\n");
7079 destreg = DECODE_RM_WORD_REGISTER(rh);
7081 srcoffset = decode_rm10_address(rl);
7082 srcval = fetch_data_word(srcoffset);
7083 DECODE_PRINTF(
"\n");
7089 if (M.x86.mode & SYSMODE_PREFIX_DATA)
7091 u32 *destreg, *srcreg;
7093 destreg = DECODE_RM_LONG_REGISTER(rh);
7095 srcreg = DECODE_RM_LONG_REGISTER(rl);
7096 DECODE_PRINTF(
"\n");
7102 u16 *destreg, *srcreg;
7104 destreg = DECODE_RM_WORD_REGISTER(rh);
7106 srcreg = DECODE_RM_WORD_REGISTER(rl);
7107 DECODE_PRINTF(
"\n");
7113 DECODE_CLEAR_SEGOVR();
7121 static void x86emuOp_mov_word_RM_SR(u8 X86EMU_UNUSED(op1))
7124 u16 *destreg, *srcreg;
7129 DECODE_PRINTF(
"MOV\t");
7130 FETCH_DECODE_MODRM(mod, rh, rl);
7134 destoffset = decode_rm00_address(rl);
7136 srcreg = decode_rm_seg_register(rh);
7137 DECODE_PRINTF(
"\n");
7140 store_data_word(destoffset, destval);
7143 destoffset = decode_rm01_address(rl);
7145 srcreg = decode_rm_seg_register(rh);
7146 DECODE_PRINTF(
"\n");
7149 store_data_word(destoffset, destval);
7152 destoffset = decode_rm10_address(rl);
7154 srcreg = decode_rm_seg_register(rh);
7155 DECODE_PRINTF(
"\n");
7158 store_data_word(destoffset, destval);
7161 destreg = DECODE_RM_WORD_REGISTER(rl);
7163 srcreg = decode_rm_seg_register(rh);
7164 DECODE_PRINTF(
"\n");
7169 DECODE_CLEAR_SEGOVR();
7177 static void x86emuOp_lea_word_R_M(u8 X86EMU_UNUSED(op1))
7190 DECODE_PRINTF(
"LEA\t");
7191 FETCH_DECODE_MODRM(mod, rh, rl);
7195 srcreg = DECODE_RM_WORD_REGISTER(rh);
7197 destoffset = decode_rm00_address(rl);
7198 DECODE_PRINTF(
"\n");
7200 *srcreg = (u16) destoffset;
7203 srcreg = DECODE_RM_WORD_REGISTER(rh);
7205 destoffset = decode_rm01_address(rl);
7206 DECODE_PRINTF(
"\n");
7208 *srcreg = (u16) destoffset;
7211 srcreg = DECODE_RM_WORD_REGISTER(rh);
7213 destoffset = decode_rm10_address(rl);
7214 DECODE_PRINTF(
"\n");
7216 *srcreg = (u16) destoffset;
7222 DECODE_CLEAR_SEGOVR();
7230 static void x86emuOp_mov_word_SR_RM(u8 X86EMU_UNUSED(op1))
7233 u16 *destreg, *srcreg;
7238 DECODE_PRINTF(
"MOV\t");
7239 FETCH_DECODE_MODRM(mod, rh, rl);
7243 destreg = decode_rm_seg_register(rh);
7245 srcoffset = decode_rm00_address(rl);
7246 srcval = fetch_data_word(srcoffset);
7247 DECODE_PRINTF(
"\n");
7252 destreg = decode_rm_seg_register(rh);
7254 srcoffset = decode_rm01_address(rl);
7255 srcval = fetch_data_word(srcoffset);
7256 DECODE_PRINTF(
"\n");
7261 destreg = decode_rm_seg_register(rh);
7263 srcoffset = decode_rm10_address(rl);
7264 srcval = fetch_data_word(srcoffset);
7265 DECODE_PRINTF(
"\n");
7270 destreg = decode_rm_seg_register(rh);
7272 srcreg = DECODE_RM_WORD_REGISTER(rl);
7273 DECODE_PRINTF(
"\n");
7284 DECODE_CLEAR_SEGOVR();
7292 static void x86emuOp_pop_RM(u8 X86EMU_UNUSED(op1))
7298 DECODE_PRINTF(
"POP\t");
7299 FETCH_DECODE_MODRM(mod, rh, rl);
7302 DECODE_PRINTF(
"ILLEGAL DECODE OF OPCODE 8F\n");
7308 if (M.x86.mode & SYSMODE_PREFIX_DATA)
7312 destoffset = decode_rm00_address(rl);
7313 DECODE_PRINTF(
"\n");
7315 destval = pop_long();
7316 store_data_long(destoffset, destval);
7322 destoffset = decode_rm00_address(rl);
7323 DECODE_PRINTF(
"\n");
7325 destval = pop_word();
7326 store_data_word(destoffset, destval);
7330 if (M.x86.mode & SYSMODE_PREFIX_DATA)
7334 destoffset = decode_rm01_address(rl);
7335 DECODE_PRINTF(
"\n");
7337 destval = pop_long();
7338 store_data_long(destoffset, destval);
7344 destoffset = decode_rm01_address(rl);
7345 DECODE_PRINTF(
"\n");
7347 destval = pop_word();
7348 store_data_word(destoffset, destval);
7352 if (M.x86.mode & SYSMODE_PREFIX_DATA)
7356 destoffset = decode_rm10_address(rl);
7357 DECODE_PRINTF(
"\n");
7359 destval = pop_long();
7360 store_data_long(destoffset, destval);
7366 destoffset = decode_rm10_address(rl);
7367 DECODE_PRINTF(
"\n");
7369 destval = pop_word();
7370 store_data_word(destoffset, destval);
7374 if (M.x86.mode & SYSMODE_PREFIX_DATA)
7378 destreg = DECODE_RM_LONG_REGISTER(rl);
7379 DECODE_PRINTF(
"\n");
7381 *destreg = pop_long();
7387 destreg = DECODE_RM_WORD_REGISTER(rl);
7388 DECODE_PRINTF(
"\n");
7390 *destreg = pop_word();
7394 DECODE_CLEAR_SEGOVR();
7402 static void x86emuOp_nop(u8 X86EMU_UNUSED(op1))
7405 DECODE_PRINTF(
"NOP\n");
7407 DECODE_CLEAR_SEGOVR();
7415 static void x86emuOp_xchg_word_AX_CX(u8 X86EMU_UNUSED(op1))
7420 if (M.x86.mode & SYSMODE_PREFIX_DATA)
7422 DECODE_PRINTF(
"XCHG\tEAX,ECX\n");
7426 DECODE_PRINTF(
"XCHG\tAX,CX\n");
7429 if (M.x86.mode & SYSMODE_PREFIX_DATA)
7432 M.x86.R_EAX = M.x86.R_ECX;
7438 M.x86.R_AX = M.x86.R_CX;
7439 M.x86.R_CX = (u16) tmp;
7441 DECODE_CLEAR_SEGOVR();
7449 static void x86emuOp_xchg_word_AX_DX(u8 X86EMU_UNUSED(op1))
7454 if (M.x86.mode & SYSMODE_PREFIX_DATA)
7456 DECODE_PRINTF(
"XCHG\tEAX,EDX\n");
7460 DECODE_PRINTF(
"XCHG\tAX,DX\n");
7463 if (M.x86.mode & SYSMODE_PREFIX_DATA)
7466 M.x86.R_EAX = M.x86.R_EDX;
7472 M.x86.R_AX = M.x86.R_DX;
7473 M.x86.R_DX = (u16) tmp;
7475 DECODE_CLEAR_SEGOVR();
7483 static void x86emuOp_xchg_word_AX_BX(u8 X86EMU_UNUSED(op1))
7488 if (M.x86.mode & SYSMODE_PREFIX_DATA)
7490 DECODE_PRINTF(
"XCHG\tEAX,EBX\n");
7494 DECODE_PRINTF(
"XCHG\tAX,BX\n");
7497 if (M.x86.mode & SYSMODE_PREFIX_DATA)
7500 M.x86.R_EAX = M.x86.R_EBX;
7506 M.x86.R_AX = M.x86.R_BX;
7507 M.x86.R_BX = (u16) tmp;
7509 DECODE_CLEAR_SEGOVR();
7517 static void x86emuOp_xchg_word_AX_SP(u8 X86EMU_UNUSED(op1))
7522 if (M.x86.mode & SYSMODE_PREFIX_DATA)
7524 DECODE_PRINTF(
"XCHG\tEAX,ESP\n");
7528 DECODE_PRINTF(
"XCHG\tAX,SP\n");
7531 if (M.x86.mode & SYSMODE_PREFIX_DATA)
7534 M.x86.R_EAX = M.x86.R_ESP;
7540 M.x86.R_AX = M.x86.R_SP;
7541 M.x86.R_SP = (u16) tmp;
7543 DECODE_CLEAR_SEGOVR();
7551 static void x86emuOp_xchg_word_AX_BP(u8 X86EMU_UNUSED(op1))
7556 if (M.x86.mode & SYSMODE_PREFIX_DATA)
7558 DECODE_PRINTF(
"XCHG\tEAX,EBP\n");
7562 DECODE_PRINTF(
"XCHG\tAX,BP\n");
7565 if (M.x86.mode & SYSMODE_PREFIX_DATA)
7568 M.x86.R_EAX = M.x86.R_EBP;
7574 M.x86.R_AX = M.x86.R_BP;
7575 M.x86.R_BP = (u16) tmp;
7577 DECODE_CLEAR_SEGOVR();
7585 static void x86emuOp_xchg_word_AX_SI(u8 X86EMU_UNUSED(op1))
7590 if (M.x86.mode & SYSMODE_PREFIX_DATA)
7592 DECODE_PRINTF(
"XCHG\tEAX,ESI\n");
7596 DECODE_PRINTF(
"XCHG\tAX,SI\n");
7599 if (M.x86.mode & SYSMODE_PREFIX_DATA)
7602 M.x86.R_EAX = M.x86.R_ESI;
7608 M.x86.R_AX = M.x86.R_SI;
7609 M.x86.R_SI = (u16) tmp;
7611 DECODE_CLEAR_SEGOVR();
7619 static void x86emuOp_xchg_word_AX_DI(u8 X86EMU_UNUSED(op1))
7624 if (M.x86.mode & SYSMODE_PREFIX_DATA)
7626 DECODE_PRINTF(
"XCHG\tEAX,EDI\n");
7630 DECODE_PRINTF(
"XCHG\tAX,DI\n");
7633 if (M.x86.mode & SYSMODE_PREFIX_DATA)
7636 M.x86.R_EAX = M.x86.R_EDI;
7642 M.x86.R_AX = M.x86.R_DI;
7643 M.x86.R_DI = (u16) tmp;
7645 DECODE_CLEAR_SEGOVR();
7653 static void x86emuOp_cbw(u8 X86EMU_UNUSED(op1))
7656 if (M.x86.mode & SYSMODE_PREFIX_DATA)
7658 DECODE_PRINTF(
"CWDE\n");
7662 DECODE_PRINTF(
"CBW\n");
7665 if (M.x86.mode & SYSMODE_PREFIX_DATA)
7667 if (M.x86.R_AX & 0x8000)
7669 M.x86.R_EAX |= 0xffff0000;
7673 M.x86.R_EAX &= 0x0000ffff;
7678 if (M.x86.R_AL & 0x80)
7687 DECODE_CLEAR_SEGOVR();
7695 static void x86emuOp_cwd(u8 X86EMU_UNUSED(op1))
7698 if (M.x86.mode & SYSMODE_PREFIX_DATA)
7700 DECODE_PRINTF(
"CDQ\n");
7704 DECODE_PRINTF(
"CWD\n");
7706 DECODE_PRINTF(
"CWD\n");
7708 if (M.x86.mode & SYSMODE_PREFIX_DATA)
7710 if (M.x86.R_EAX & 0x80000000)
7712 M.x86.R_EDX = 0xffffffff;
7721 if (M.x86.R_AX & 0x8000)
7723 M.x86.R_DX = 0xffff;
7730 DECODE_CLEAR_SEGOVR();
7738 static void x86emuOp_call_far_IMM(u8 X86EMU_UNUSED(op1))
7743 DECODE_PRINTF(
"CALL\t");
7744 faroff = fetch_word_imm();
7745 farseg = fetch_word_imm();
7746 DECODE_PRINTF2(
"%04x:", farseg);
7747 DECODE_PRINTF2(
"%04x\n", faroff);
7748 CALL_TRACE(M.x86.saved_cs, M.x86.saved_ip, farseg, faroff,
"FAR ");
7757 push_word(M.x86.R_CS);
7758 M.x86.R_CS = farseg;
7759 push_word(M.x86.R_IP);
7760 M.x86.R_IP = faroff;
7761 DECODE_CLEAR_SEGOVR();
7769 static void x86emuOp_wait(u8 X86EMU_UNUSED(op1))
7772 DECODE_PRINTF(
"WAIT");
7775 DECODE_CLEAR_SEGOVR();
7783 static void x86emuOp_pushf_word(u8 X86EMU_UNUSED(op1))
7788 if (M.x86.mode & SYSMODE_PREFIX_DATA)
7790 DECODE_PRINTF(
"PUSHFD\n");
7794 DECODE_PRINTF(
"PUSHF\n");
7799 flags = (M.x86.R_EFLG & F_MSK) | F_ALWAYS_ON;
7800 if (M.x86.mode & SYSMODE_PREFIX_DATA)
7806 push_word((u16) flags);
7808 DECODE_CLEAR_SEGOVR();
7816 static void x86emuOp_popf_word(u8 X86EMU_UNUSED(op1))
7819 if (M.x86.mode & SYSMODE_PREFIX_DATA)
7821 DECODE_PRINTF(
"POPFD\n");
7825 DECODE_PRINTF(
"POPF\n");
7828 if (M.x86.mode & SYSMODE_PREFIX_DATA)
7830 M.x86.R_EFLG = pop_long();
7834 M.x86.R_FLG = pop_word();
7836 DECODE_CLEAR_SEGOVR();
7844 static void x86emuOp_sahf(u8 X86EMU_UNUSED(op1))
7847 DECODE_PRINTF(
"SAHF\n");
7850 M.x86.R_FLG &= 0xffffff00;
7852 M.x86.R_FLG |= M.x86.R_AH;
7853 DECODE_CLEAR_SEGOVR();
7861 static void x86emuOp_lahf(u8 X86EMU_UNUSED(op1))
7864 DECODE_PRINTF(
"LAHF\n");
7866 M.x86.R_AH = (u8)(M.x86.R_FLG & 0xff);
7870 DECODE_CLEAR_SEGOVR();
7878 static void x86emuOp_mov_AL_M_IMM(u8 X86EMU_UNUSED(op1))
7883 DECODE_PRINTF(
"MOV\tAL,");
7884 offset = fetch_word_imm();
7885 DECODE_PRINTF2(
"[%04x]\n", offset);
7887 M.x86.R_AL = fetch_data_byte(offset);
7888 DECODE_CLEAR_SEGOVR();
7896 static void x86emuOp_mov_AX_M_IMM(u8 X86EMU_UNUSED(op1))
7901 offset = fetch_word_imm();
7902 if (M.x86.mode & SYSMODE_PREFIX_DATA)
7904 DECODE_PRINTF2(
"MOV\tEAX,[%04x]\n", offset);
7908 DECODE_PRINTF2(
"MOV\tAX,[%04x]\n", offset);
7911 if (M.x86.mode & SYSMODE_PREFIX_DATA)
7913 M.x86.R_EAX = fetch_data_long(offset);
7917 M.x86.R_AX = fetch_data_word(offset);
7919 DECODE_CLEAR_SEGOVR();
7927 static void x86emuOp_mov_M_AL_IMM(u8 X86EMU_UNUSED(op1))
7932 DECODE_PRINTF(
"MOV\t");
7933 offset = fetch_word_imm();
7934 DECODE_PRINTF2(
"[%04x],AL\n", offset);
7936 store_data_byte(offset, M.x86.R_AL);
7937 DECODE_CLEAR_SEGOVR();
7945 static void x86emuOp_mov_M_AX_IMM(u8 X86EMU_UNUSED(op1))
7950 offset = fetch_word_imm();
7951 if (M.x86.mode & SYSMODE_PREFIX_DATA)
7953 DECODE_PRINTF2(
"MOV\t[%04x],EAX\n", offset);
7957 DECODE_PRINTF2(
"MOV\t[%04x],AX\n", offset);
7960 if (M.x86.mode & SYSMODE_PREFIX_DATA)
7962 store_data_long(offset, M.x86.R_EAX);
7966 store_data_word(offset, M.x86.R_AX);
7968 DECODE_CLEAR_SEGOVR();
7976 static void x86emuOp_movs_byte(u8 X86EMU_UNUSED(op1))
7983 DECODE_PRINTF(
"MOVS\tBYTE\n");
7984 if (ACCESS_FLAG(F_DF))
7990 if (M.x86.mode & (SYSMODE_PREFIX_REPE | SYSMODE_PREFIX_REPNE))
7996 M.x86.mode &= ~(SYSMODE_PREFIX_REPE | SYSMODE_PREFIX_REPNE);
8000 val = fetch_data_byte(M.x86.R_SI);
8001 store_data_byte_abs(M.x86.R_ES, M.x86.R_DI, val);
8005 DECODE_CLEAR_SEGOVR();
8013 static void x86emuOp_movs_word(u8 X86EMU_UNUSED(op1))
8020 if (M.x86.mode & SYSMODE_PREFIX_DATA)
8022 DECODE_PRINTF(
"MOVS\tDWORD\n");
8023 if (ACCESS_FLAG(F_DF))
8030 DECODE_PRINTF(
"MOVS\tWORD\n");
8031 if (ACCESS_FLAG(F_DF))
8038 if (M.x86.mode & (SYSMODE_PREFIX_REPE | SYSMODE_PREFIX_REPNE))
8044 M.x86.mode &= ~(SYSMODE_PREFIX_REPE | SYSMODE_PREFIX_REPNE);
8048 if (M.x86.mode & SYSMODE_PREFIX_DATA)
8050 val = fetch_data_long(M.x86.R_SI);
8051 store_data_long_abs(M.x86.R_ES, M.x86.R_DI, val);
8055 val = fetch_data_word(M.x86.R_SI);
8056 store_data_word_abs(M.x86.R_ES, M.x86.R_DI, (u16) val);
8061 DECODE_CLEAR_SEGOVR();
8069 static void x86emuOp_cmps_byte(u8 X86EMU_UNUSED(op1))
8075 DECODE_PRINTF(
"CMPS\tBYTE\n");
8077 if (ACCESS_FLAG(F_DF))
8082 if (M.x86.mode & SYSMODE_PREFIX_REPE)
8086 while (M.x86.R_CX != 0)
8088 val1 = fetch_data_byte(M.x86.R_SI);
8089 val2 = fetch_data_byte_abs(M.x86.R_ES, M.x86.R_DI);
8090 cmp_byte(val1, val2);
8094 if (ACCESS_FLAG(F_ZF) == 0)
8097 M.x86.mode &= ~SYSMODE_PREFIX_REPE;
8099 else if (M.x86.mode & SYSMODE_PREFIX_REPNE)
8103 while (M.x86.R_CX != 0)
8105 val1 = fetch_data_byte(M.x86.R_SI);
8106 val2 = fetch_data_byte_abs(M.x86.R_ES, M.x86.R_DI);
8107 cmp_byte(val1, val2);
8111 if (ACCESS_FLAG(F_ZF))
8114 M.x86.mode &= ~SYSMODE_PREFIX_REPNE;
8118 val1 = fetch_data_byte(M.x86.R_SI);
8119 val2 = fetch_data_byte_abs(M.x86.R_ES, M.x86.R_DI);
8120 cmp_byte(val1, val2);
8124 DECODE_CLEAR_SEGOVR();
8132 static void x86emuOp_cmps_word(u8 X86EMU_UNUSED(op1))
8138 if (M.x86.mode & SYSMODE_PREFIX_DATA)
8140 DECODE_PRINTF(
"CMPS\tDWORD\n");
8141 if (ACCESS_FLAG(F_DF))
8148 DECODE_PRINTF(
"CMPS\tWORD\n");
8149 if (ACCESS_FLAG(F_DF))
8155 if (M.x86.mode & SYSMODE_PREFIX_REPE)
8159 while (M.x86.R_CX != 0)
8161 if (M.x86.mode & SYSMODE_PREFIX_DATA)
8163 val1 = fetch_data_long(M.x86.R_SI);
8164 val2 = fetch_data_long_abs(M.x86.R_ES, M.x86.R_DI);
8165 cmp_long(val1, val2);
8169 val1 = fetch_data_word(M.x86.R_SI);
8170 val2 = fetch_data_word_abs(M.x86.R_ES, M.x86.R_DI);
8171 cmp_word((u16) val1, (u16) val2);
8176 if (ACCESS_FLAG(F_ZF) == 0)
8179 M.x86.mode &= ~SYSMODE_PREFIX_REPE;
8181 else if (M.x86.mode & SYSMODE_PREFIX_REPNE)
8185 while (M.x86.R_CX != 0)
8187 if (M.x86.mode & SYSMODE_PREFIX_DATA)
8189 val1 = fetch_data_long(M.x86.R_SI);
8190 val2 = fetch_data_long_abs(M.x86.R_ES, M.x86.R_DI);
8191 cmp_long(val1, val2);
8195 val1 = fetch_data_word(M.x86.R_SI);
8196 val2 = fetch_data_word_abs(M.x86.R_ES, M.x86.R_DI);
8197 cmp_word((u16) val1, (u16) val2);
8202 if (ACCESS_FLAG(F_ZF))
8205 M.x86.mode &= ~SYSMODE_PREFIX_REPNE;
8209 if (M.x86.mode & SYSMODE_PREFIX_DATA)
8211 val1 = fetch_data_long(M.x86.R_SI);
8212 val2 = fetch_data_long_abs(M.x86.R_ES, M.x86.R_DI);
8213 cmp_long(val1, val2);
8217 val1 = fetch_data_word(M.x86.R_SI);
8218 val2 = fetch_data_word_abs(M.x86.R_ES, M.x86.R_DI);
8219 cmp_word((u16) val1, (u16) val2);
8224 DECODE_CLEAR_SEGOVR();
8232 static void x86emuOp_test_AL_IMM(u8 X86EMU_UNUSED(op1))
8237 DECODE_PRINTF(
"TEST\tAL,");
8238 imm = fetch_byte_imm();
8239 DECODE_PRINTF2(
"%04x\n", imm);
8241 test_byte(M.x86.R_AL, (u8) imm);
8242 DECODE_CLEAR_SEGOVR();
8250 static void x86emuOp_test_AX_IMM(u8 X86EMU_UNUSED(op1))
8255 if (M.x86.mode & SYSMODE_PREFIX_DATA)
8257 DECODE_PRINTF(
"TEST\tEAX,");
8258 srcval = fetch_long_imm();
8262 DECODE_PRINTF(
"TEST\tAX,");
8263 srcval = fetch_word_imm();
8265 DECODE_PRINTF2(
"%x\n", srcval);
8267 if (M.x86.mode & SYSMODE_PREFIX_DATA)
8269 test_long(M.x86.R_EAX, srcval);
8273 test_word(M.x86.R_AX, (u16) srcval);
8275 DECODE_CLEAR_SEGOVR();
8283 static void x86emuOp_stos_byte(u8 X86EMU_UNUSED(op1))
8288 DECODE_PRINTF(
"STOS\tBYTE\n");
8289 if (ACCESS_FLAG(F_DF))
8294 if (M.x86.mode & (SYSMODE_PREFIX_REPE | SYSMODE_PREFIX_REPNE))
8298 while (M.x86.R_CX != 0)
8300 store_data_byte_abs(M.x86.R_ES, M.x86.R_DI, M.x86.R_AL);
8304 M.x86.mode &= ~(SYSMODE_PREFIX_REPE | SYSMODE_PREFIX_REPNE);
8308 store_data_byte_abs(M.x86.R_ES, M.x86.R_DI, M.x86.R_AL);
8311 DECODE_CLEAR_SEGOVR();
8319 static void x86emuOp_stos_word(u8 X86EMU_UNUSED(op1))
8325 if (M.x86.mode & SYSMODE_PREFIX_DATA)
8327 DECODE_PRINTF(
"STOS\tDWORD\n");
8328 if (ACCESS_FLAG(F_DF))
8335 DECODE_PRINTF(
"STOS\tWORD\n");
8336 if (ACCESS_FLAG(F_DF))
8343 if (M.x86.mode & (SYSMODE_PREFIX_REPE | SYSMODE_PREFIX_REPNE))
8349 M.x86.mode &= ~(SYSMODE_PREFIX_REPE | SYSMODE_PREFIX_REPNE);
8353 if (M.x86.mode & SYSMODE_PREFIX_DATA)
8355 store_data_long_abs(M.x86.R_ES, M.x86.R_DI, M.x86.R_EAX);
8359 store_data_word_abs(M.x86.R_ES, M.x86.R_DI, M.x86.R_AX);
8363 DECODE_CLEAR_SEGOVR();
8371 static void x86emuOp_lods_byte(u8 X86EMU_UNUSED(op1))
8376 DECODE_PRINTF(
"LODS\tBYTE\n");
8378 if (ACCESS_FLAG(F_DF))
8382 if (M.x86.mode & (SYSMODE_PREFIX_REPE | SYSMODE_PREFIX_REPNE))
8386 while (M.x86.R_CX != 0)
8388 M.x86.R_AL = fetch_data_byte(M.x86.R_SI);
8392 M.x86.mode &= ~(SYSMODE_PREFIX_REPE | SYSMODE_PREFIX_REPNE);
8396 M.x86.R_AL = fetch_data_byte(M.x86.R_SI);
8399 DECODE_CLEAR_SEGOVR();
8407 static void x86emuOp_lods_word(u8 X86EMU_UNUSED(op1))
8413 if (M.x86.mode & SYSMODE_PREFIX_DATA)
8415 DECODE_PRINTF(
"LODS\tDWORD\n");
8416 if (ACCESS_FLAG(F_DF))
8423 DECODE_PRINTF(
"LODS\tWORD\n");
8424 if (ACCESS_FLAG(F_DF))
8431 if (M.x86.mode & (SYSMODE_PREFIX_REPE | SYSMODE_PREFIX_REPNE))
8437 M.x86.mode &= ~(SYSMODE_PREFIX_REPE | SYSMODE_PREFIX_REPNE);
8441 if (M.x86.mode & SYSMODE_PREFIX_DATA)
8443 M.x86.R_EAX = fetch_data_long(M.x86.R_SI);
8447 M.x86.R_AX = fetch_data_word(M.x86.R_SI);
8451 DECODE_CLEAR_SEGOVR();
8459 static void x86emuOp_scas_byte(u8 X86EMU_UNUSED(op1))
8465 DECODE_PRINTF(
"SCAS\tBYTE\n");
8467 if (ACCESS_FLAG(F_DF))
8471 if (M.x86.mode & SYSMODE_PREFIX_REPE)
8475 while (M.x86.R_CX != 0)
8477 val2 = fetch_data_byte_abs(M.x86.R_ES, M.x86.R_DI);
8478 cmp_byte(M.x86.R_AL, val2);
8481 if (ACCESS_FLAG(F_ZF) == 0)
8484 M.x86.mode &= ~SYSMODE_PREFIX_REPE;
8486 else if (M.x86.mode & SYSMODE_PREFIX_REPNE)
8490 while (M.x86.R_CX != 0)
8492 val2 = fetch_data_byte_abs(M.x86.R_ES, M.x86.R_DI);
8493 cmp_byte(M.x86.R_AL, val2);
8496 if (ACCESS_FLAG(F_ZF))
8499 M.x86.mode &= ~SYSMODE_PREFIX_REPNE;
8503 val2 = fetch_data_byte_abs(M.x86.R_ES, M.x86.R_DI);
8504 cmp_byte(M.x86.R_AL, val2);
8507 DECODE_CLEAR_SEGOVR();
8515 static void x86emuOp_scas_word(u8 X86EMU_UNUSED(op1))
8521 if (M.x86.mode & SYSMODE_PREFIX_DATA)
8523 DECODE_PRINTF(
"SCAS\tDWORD\n");
8524 if (ACCESS_FLAG(F_DF))
8531 DECODE_PRINTF(
"SCAS\tWORD\n");
8532 if (ACCESS_FLAG(F_DF))
8538 if (M.x86.mode & SYSMODE_PREFIX_REPE)
8542 while (M.x86.R_CX != 0)
8544 if (M.x86.mode & SYSMODE_PREFIX_DATA)
8546 val = fetch_data_long_abs(M.x86.R_ES, M.x86.R_DI);
8547 cmp_long(M.x86.R_EAX, val);
8551 val = fetch_data_word_abs(M.x86.R_ES, M.x86.R_DI);
8552 cmp_word(M.x86.R_AX, (u16) val);
8556 if (ACCESS_FLAG(F_ZF) == 0)
8559 M.x86.mode &= ~SYSMODE_PREFIX_REPE;
8561 else if (M.x86.mode & SYSMODE_PREFIX_REPNE)
8565 while (M.x86.R_CX != 0)
8567 if (M.x86.mode & SYSMODE_PREFIX_DATA)
8569 val = fetch_data_long_abs(M.x86.R_ES, M.x86.R_DI);
8570 cmp_long(M.x86.R_EAX, val);
8574 val = fetch_data_word_abs(M.x86.R_ES, M.x86.R_DI);
8575 cmp_word(M.x86.R_AX, (u16) val);
8579 if (ACCESS_FLAG(F_ZF))
8582 M.x86.mode &= ~SYSMODE_PREFIX_REPNE;
8586 if (M.x86.mode & SYSMODE_PREFIX_DATA)
8588 val = fetch_data_long_abs(M.x86.R_ES, M.x86.R_DI);
8589 cmp_long(M.x86.R_EAX, val);
8593 val = fetch_data_word_abs(M.x86.R_ES, M.x86.R_DI);
8594 cmp_word(M.x86.R_AX, (u16) val);
8598 DECODE_CLEAR_SEGOVR();
8606 static void x86emuOp_mov_byte_AL_IMM(u8 X86EMU_UNUSED(op1))
8611 DECODE_PRINTF(
"MOV\tAL,");
8612 imm = fetch_byte_imm();
8613 DECODE_PRINTF2(
"%x\n", imm);
8616 DECODE_CLEAR_SEGOVR();
8624 static void x86emuOp_mov_byte_CL_IMM(u8 X86EMU_UNUSED(op1))
8629 DECODE_PRINTF(
"MOV\tCL,");
8630 imm = fetch_byte_imm();
8631 DECODE_PRINTF2(
"%x\n", imm);
8634 DECODE_CLEAR_SEGOVR();
8642 static void x86emuOp_mov_byte_DL_IMM(u8 X86EMU_UNUSED(op1))
8647 DECODE_PRINTF(
"MOV\tDL,");
8648 imm = fetch_byte_imm();
8649 DECODE_PRINTF2(
"%x\n", imm);
8652 DECODE_CLEAR_SEGOVR();
8660 static void x86emuOp_mov_byte_BL_IMM(u8 X86EMU_UNUSED(op1))
8665 DECODE_PRINTF(
"MOV\tBL,");
8666 imm = fetch_byte_imm();
8667 DECODE_PRINTF2(
"%x\n", imm);
8670 DECODE_CLEAR_SEGOVR();
8678 static void x86emuOp_mov_byte_AH_IMM(u8 X86EMU_UNUSED(op1))
8683 DECODE_PRINTF(
"MOV\tAH,");
8684 imm = fetch_byte_imm();
8685 DECODE_PRINTF2(
"%x\n", imm);
8688 DECODE_CLEAR_SEGOVR();
8696 static void x86emuOp_mov_byte_CH_IMM(u8 X86EMU_UNUSED(op1))
8701 DECODE_PRINTF(
"MOV\tCH,");
8702 imm = fetch_byte_imm();
8703 DECODE_PRINTF2(
"%x\n", imm);
8706 DECODE_CLEAR_SEGOVR();
8714 static void x86emuOp_mov_byte_DH_IMM(u8 X86EMU_UNUSED(op1))
8719 DECODE_PRINTF(
"MOV\tDH,");
8720 imm = fetch_byte_imm();
8721 DECODE_PRINTF2(
"%x\n", imm);
8724 DECODE_CLEAR_SEGOVR();
8732 static void x86emuOp_mov_byte_BH_IMM(u8 X86EMU_UNUSED(op1))
8737 DECODE_PRINTF(
"MOV\tBH,");
8738 imm = fetch_byte_imm();
8739 DECODE_PRINTF2(
"%x\n", imm);
8742 DECODE_CLEAR_SEGOVR();
8750 static void x86emuOp_mov_word_AX_IMM(u8 X86EMU_UNUSED(op1))
8755 if (M.x86.mode & SYSMODE_PREFIX_DATA)
8757 DECODE_PRINTF(
"MOV\tEAX,");
8758 srcval = fetch_long_imm();
8762 DECODE_PRINTF(
"MOV\tAX,");
8763 srcval = fetch_word_imm();
8765 DECODE_PRINTF2(
"%x\n", srcval);
8767 if (M.x86.mode & SYSMODE_PREFIX_DATA)
8769 M.x86.R_EAX = srcval;
8773 M.x86.R_AX = (u16) srcval;
8775 DECODE_CLEAR_SEGOVR();
8783 static void x86emuOp_mov_word_CX_IMM(u8 X86EMU_UNUSED(op1))
8788 if (M.x86.mode & SYSMODE_PREFIX_DATA)
8790 DECODE_PRINTF(
"MOV\tECX,");
8791 srcval = fetch_long_imm();
8795 DECODE_PRINTF(
"MOV\tCX,");
8796 srcval = fetch_word_imm();
8798 DECODE_PRINTF2(
"%x\n", srcval);
8800 if (M.x86.mode & SYSMODE_PREFIX_DATA)
8802 M.x86.R_ECX = srcval;
8806 M.x86.R_CX = (u16) srcval;
8808 DECODE_CLEAR_SEGOVR();
8816 static void x86emuOp_mov_word_DX_IMM(u8 X86EMU_UNUSED(op1))
8821 if (M.x86.mode & SYSMODE_PREFIX_DATA)
8823 DECODE_PRINTF(
"MOV\tEDX,");
8824 srcval = fetch_long_imm();
8828 DECODE_PRINTF(
"MOV\tDX,");
8829 srcval = fetch_word_imm();
8831 DECODE_PRINTF2(
"%x\n", srcval);
8833 if (M.x86.mode & SYSMODE_PREFIX_DATA)
8835 M.x86.R_EDX = srcval;
8839 M.x86.R_DX = (u16) srcval;
8841 DECODE_CLEAR_SEGOVR();
8849 static void x86emuOp_mov_word_BX_IMM(u8 X86EMU_UNUSED(op1))
8854 if (M.x86.mode & SYSMODE_PREFIX_DATA)
8856 DECODE_PRINTF(
"MOV\tEBX,");
8857 srcval = fetch_long_imm();
8861 DECODE_PRINTF(
"MOV\tBX,");
8862 srcval = fetch_word_imm();
8864 DECODE_PRINTF2(
"%x\n", srcval);
8866 if (M.x86.mode & SYSMODE_PREFIX_DATA)
8868 M.x86.R_EBX = srcval;
8872 M.x86.R_BX = (u16) srcval;
8874 DECODE_CLEAR_SEGOVR();
8882 static void x86emuOp_mov_word_SP_IMM(u8 X86EMU_UNUSED(op1))
8887 if (M.x86.mode & SYSMODE_PREFIX_DATA)
8889 DECODE_PRINTF(
"MOV\tESP,");
8890 srcval = fetch_long_imm();
8894 DECODE_PRINTF(
"MOV\tSP,");
8895 srcval = fetch_word_imm();
8897 DECODE_PRINTF2(
"%x\n", srcval);
8899 if (M.x86.mode & SYSMODE_PREFIX_DATA)
8901 M.x86.R_ESP = srcval;
8905 M.x86.R_SP = (u16) srcval;
8907 DECODE_CLEAR_SEGOVR();
8915 static void x86emuOp_mov_word_BP_IMM(u8 X86EMU_UNUSED(op1))
8920 if (M.x86.mode & SYSMODE_PREFIX_DATA)
8922 DECODE_PRINTF(
"MOV\tEBP,");
8923 srcval = fetch_long_imm();
8927 DECODE_PRINTF(
"MOV\tBP,");
8928 srcval = fetch_word_imm();
8930 DECODE_PRINTF2(
"%x\n", srcval);
8932 if (M.x86.mode & SYSMODE_PREFIX_DATA)
8934 M.x86.R_EBP = srcval;
8938 M.x86.R_BP = (u16) srcval;
8940 DECODE_CLEAR_SEGOVR();
8948 static void x86emuOp_mov_word_SI_IMM(u8 X86EMU_UNUSED(op1))
8953 if (M.x86.mode & SYSMODE_PREFIX_DATA)
8955 DECODE_PRINTF(
"MOV\tESI,");
8956 srcval = fetch_long_imm();
8960 DECODE_PRINTF(
"MOV\tSI,");
8961 srcval = fetch_word_imm();
8963 DECODE_PRINTF2(
"%x\n", srcval);
8965 if (M.x86.mode & SYSMODE_PREFIX_DATA)
8967 M.x86.R_ESI = srcval;
8971 M.x86.R_SI = (u16) srcval;
8973 DECODE_CLEAR_SEGOVR();
8981 static void x86emuOp_mov_word_DI_IMM(u8 X86EMU_UNUSED(op1))
8986 if (M.x86.mode & SYSMODE_PREFIX_DATA)
8988 DECODE_PRINTF(
"MOV\tEDI,");
8989 srcval = fetch_long_imm();
8993 DECODE_PRINTF(
"MOV\tDI,");
8994 srcval = fetch_word_imm();
8996 DECODE_PRINTF2(
"%x\n", srcval);
8998 if (M.x86.mode & SYSMODE_PREFIX_DATA)
9000 M.x86.R_EDI = srcval;
9004 M.x86.R_DI = (u16) srcval;
9006 DECODE_CLEAR_SEGOVR();
9011 static u8 (*opcD0_byte_operation[])(u8 d, u8 s) = {
9012 rol_byte, ror_byte, rcl_byte, rcr_byte,
9013 shl_byte, shr_byte, shl_byte,
9021 static void x86emuOp_opcC0_byte_RM_MEM(u8 X86EMU_UNUSED(op1))
9035 FETCH_DECODE_MODRM(mod, rh, rl);
9047 DECODE_PRINTF(
"ROL\t");
9050 DECODE_PRINTF(
"ROR\t");
9053 DECODE_PRINTF(
"RCL\t");
9056 DECODE_PRINTF(
"RCR\t");
9059 DECODE_PRINTF(
"SHL\t");
9062 DECODE_PRINTF(
"SHR\t");
9065 DECODE_PRINTF(
"SAL\t");
9068 DECODE_PRINTF(
"SAR\t");
9078 DECODE_PRINTF(
"BYTE PTR ");
9079 destoffset = decode_rm00_address(rl);
9080 amt = fetch_byte_imm();
9081 DECODE_PRINTF2(
",%x\n", amt);
9082 destval = fetch_data_byte(destoffset);
9084 destval = (*opcD0_byte_operation[rh])(destval, amt);
9085 store_data_byte(destoffset, destval);
9088 DECODE_PRINTF(
"BYTE PTR ");
9089 destoffset = decode_rm01_address(rl);
9090 amt = fetch_byte_imm();
9091 DECODE_PRINTF2(
",%x\n", amt);
9092 destval = fetch_data_byte(destoffset);
9094 destval = (*opcD0_byte_operation[rh])(destval, amt);
9095 store_data_byte(destoffset, destval);
9098 DECODE_PRINTF(
"BYTE PTR ");
9099 destoffset = decode_rm10_address(rl);
9100 amt = fetch_byte_imm();
9101 DECODE_PRINTF2(
",%x\n", amt);
9102 destval = fetch_data_byte(destoffset);
9104 destval = (*opcD0_byte_operation[rh])(destval, amt);
9105 store_data_byte(destoffset, destval);
9108 destreg = DECODE_RM_BYTE_REGISTER(rl);
9109 amt = fetch_byte_imm();
9110 DECODE_PRINTF2(
",%x\n", amt);
9112 destval = (*opcD0_byte_operation[rh])(*destreg, amt);
9116 DECODE_CLEAR_SEGOVR();
9121 static u16 (*opcD1_word_operation[])(u16 s, u8 d) = {
9122 rol_word, ror_word, rcl_word, rcr_word,
9123 shl_word, shr_word, shl_word,
9128 static u32 (*opcD1_long_operation[])(u32 s, u8 d) = {
9129 rol_long, ror_long, rcl_long, rcr_long,
9130 shl_long, shr_long, shl_long,
9138 static void x86emuOp_opcC1_word_RM_MEM(u8 X86EMU_UNUSED(op1))
9150 FETCH_DECODE_MODRM(mod, rh, rl);
9162 DECODE_PRINTF(
"ROL\t");
9165 DECODE_PRINTF(
"ROR\t");
9168 DECODE_PRINTF(
"RCL\t");
9171 DECODE_PRINTF(
"RCR\t");
9174 DECODE_PRINTF(
"SHL\t");
9177 DECODE_PRINTF(
"SHR\t");
9180 DECODE_PRINTF(
"SAL\t");
9183 DECODE_PRINTF(
"SAR\t");
9193 if (M.x86.mode & SYSMODE_PREFIX_DATA)
9197 DECODE_PRINTF(
"DWORD PTR ");
9198 destoffset = decode_rm00_address(rl);
9199 amt = fetch_byte_imm();
9200 DECODE_PRINTF2(
",%x\n", amt);
9201 destval = fetch_data_long(destoffset);
9203 destval = (*opcD1_long_operation[rh])(destval, amt);
9204 store_data_long(destoffset, destval);
9210 DECODE_PRINTF(
"WORD PTR ");
9211 destoffset = decode_rm00_address(rl);
9212 amt = fetch_byte_imm();
9213 DECODE_PRINTF2(
",%x\n", amt);
9214 destval = fetch_data_word(destoffset);
9216 destval = (*opcD1_word_operation[rh])(destval, amt);
9217 store_data_word(destoffset, destval);
9221 if (M.x86.mode & SYSMODE_PREFIX_DATA)
9225 DECODE_PRINTF(
"DWORD PTR ");
9226 destoffset = decode_rm01_address(rl);
9227 amt = fetch_byte_imm();
9228 DECODE_PRINTF2(
",%x\n", amt);
9229 destval = fetch_data_long(destoffset);
9231 destval = (*opcD1_long_operation[rh])(destval, amt);
9232 store_data_long(destoffset, destval);
9238 DECODE_PRINTF(
"WORD PTR ");
9239 destoffset = decode_rm01_address(rl);
9240 amt = fetch_byte_imm();
9241 DECODE_PRINTF2(
",%x\n", amt);
9242 destval = fetch_data_word(destoffset);
9244 destval = (*opcD1_word_operation[rh])(destval, amt);
9245 store_data_word(destoffset, destval);
9249 if (M.x86.mode & SYSMODE_PREFIX_DATA)
9253 DECODE_PRINTF(
"DWORD PTR ");
9254 destoffset = decode_rm10_address(rl);
9255 amt = fetch_byte_imm();
9256 DECODE_PRINTF2(
",%x\n", amt);
9257 destval = fetch_data_long(destoffset);
9259 destval = (*opcD1_long_operation[rh])(destval, amt);
9260 store_data_long(destoffset, destval);
9266 DECODE_PRINTF(
"WORD PTR ");
9267 destoffset = decode_rm10_address(rl);
9268 amt = fetch_byte_imm();
9269 DECODE_PRINTF2(
",%x\n", amt);
9270 destval = fetch_data_word(destoffset);
9272 destval = (*opcD1_word_operation[rh])(destval, amt);
9273 store_data_word(destoffset, destval);
9277 if (M.x86.mode & SYSMODE_PREFIX_DATA)
9281 destreg = DECODE_RM_LONG_REGISTER(rl);
9282 amt = fetch_byte_imm();
9283 DECODE_PRINTF2(
",%x\n", amt);
9285 *destreg = (*opcD1_long_operation[rh])(*destreg, amt);
9291 destreg = DECODE_RM_WORD_REGISTER(rl);
9292 amt = fetch_byte_imm();
9293 DECODE_PRINTF2(
",%x\n", amt);
9295 *destreg = (*opcD1_word_operation[rh])(*destreg, amt);
9299 DECODE_CLEAR_SEGOVR();
9307 static void x86emuOp_ret_near_IMM(u8 X86EMU_UNUSED(op1))
9312 DECODE_PRINTF(
"RET\t");
9313 imm = fetch_word_imm();
9314 DECODE_PRINTF2(
"%x\n", imm);
9315 RETURN_TRACE(
"RET", M.x86.saved_cs, M.x86.saved_ip);
9317 M.x86.R_IP = pop_word();
9319 DECODE_CLEAR_SEGOVR();
9327 static void x86emuOp_ret_near(u8 X86EMU_UNUSED(op1))
9330 DECODE_PRINTF(
"RET\n");
9331 RETURN_TRACE(
"RET", M.x86.saved_cs, M.x86.saved_ip);
9333 M.x86.R_IP = pop_word();
9334 DECODE_CLEAR_SEGOVR();
9342 static void x86emuOp_les_R_IMM(u8 X86EMU_UNUSED(op1))
9349 DECODE_PRINTF(
"LES\t");
9350 FETCH_DECODE_MODRM(mod, rh, rl);
9354 dstreg = DECODE_RM_WORD_REGISTER(rh);
9356 srcoffset = decode_rm00_address(rl);
9357 DECODE_PRINTF(
"\n");
9359 *dstreg = fetch_data_word(srcoffset);
9360 M.x86.R_ES = fetch_data_word(srcoffset + 2);
9363 dstreg = DECODE_RM_WORD_REGISTER(rh);
9365 srcoffset = decode_rm01_address(rl);
9366 DECODE_PRINTF(
"\n");
9368 *dstreg = fetch_data_word(srcoffset);
9369 M.x86.R_ES = fetch_data_word(srcoffset + 2);
9372 dstreg = DECODE_RM_WORD_REGISTER(rh);
9374 srcoffset = decode_rm10_address(rl);
9375 DECODE_PRINTF(
"\n");
9377 *dstreg = fetch_data_word(srcoffset);
9378 M.x86.R_ES = fetch_data_word(srcoffset + 2);
9384 DECODE_CLEAR_SEGOVR();
9392 static void x86emuOp_lds_R_IMM(u8 X86EMU_UNUSED(op1))
9399 DECODE_PRINTF(
"LDS\t");
9400 FETCH_DECODE_MODRM(mod, rh, rl);
9404 dstreg = DECODE_RM_WORD_REGISTER(rh);
9406 srcoffset = decode_rm00_address(rl);
9407 DECODE_PRINTF(
"\n");
9409 *dstreg = fetch_data_word(srcoffset);
9410 M.x86.R_DS = fetch_data_word(srcoffset + 2);
9413 dstreg = DECODE_RM_WORD_REGISTER(rh);
9415 srcoffset = decode_rm01_address(rl);
9416 DECODE_PRINTF(
"\n");
9418 *dstreg = fetch_data_word(srcoffset);
9419 M.x86.R_DS = fetch_data_word(srcoffset + 2);
9422 dstreg = DECODE_RM_WORD_REGISTER(rh);
9424 srcoffset = decode_rm10_address(rl);
9425 DECODE_PRINTF(
"\n");
9427 *dstreg = fetch_data_word(srcoffset);
9428 M.x86.R_DS = fetch_data_word(srcoffset + 2);
9434 DECODE_CLEAR_SEGOVR();
9442 static void x86emuOp_mov_byte_RM_IMM(u8 X86EMU_UNUSED(op1))
9450 DECODE_PRINTF(
"MOV\t");
9451 FETCH_DECODE_MODRM(mod, rh, rl);
9454 DECODE_PRINTF(
"ILLEGAL DECODE OF OPCODE c6\n");
9460 DECODE_PRINTF(
"BYTE PTR ");
9461 destoffset = decode_rm00_address(rl);
9462 imm = fetch_byte_imm();
9463 DECODE_PRINTF2(
",%2x\n", imm);
9465 store_data_byte(destoffset, imm);
9468 DECODE_PRINTF(
"BYTE PTR ");
9469 destoffset = decode_rm01_address(rl);
9470 imm = fetch_byte_imm();
9471 DECODE_PRINTF2(
",%2x\n", imm);
9473 store_data_byte(destoffset, imm);
9476 DECODE_PRINTF(
"BYTE PTR ");
9477 destoffset = decode_rm10_address(rl);
9478 imm = fetch_byte_imm();
9479 DECODE_PRINTF2(
",%2x\n", imm);
9481 store_data_byte(destoffset, imm);
9484 destreg = DECODE_RM_BYTE_REGISTER(rl);
9485 imm = fetch_byte_imm();
9486 DECODE_PRINTF2(
",%2x\n", imm);
9491 DECODE_CLEAR_SEGOVR();
9499 static void x86emuOp_mov_word_RM_IMM(u8 X86EMU_UNUSED(op1))
9505 DECODE_PRINTF(
"MOV\t");
9506 FETCH_DECODE_MODRM(mod, rh, rl);
9509 DECODE_PRINTF(
"ILLEGAL DECODE OF OPCODE 8F\n");
9515 if (M.x86.mode & SYSMODE_PREFIX_DATA)
9519 DECODE_PRINTF(
"DWORD PTR ");
9520 destoffset = decode_rm00_address(rl);
9521 imm = fetch_long_imm();
9522 DECODE_PRINTF2(
",%x\n", imm);
9524 store_data_long(destoffset, imm);
9530 DECODE_PRINTF(
"WORD PTR ");
9531 destoffset = decode_rm00_address(rl);
9532 imm = fetch_word_imm();
9533 DECODE_PRINTF2(
",%x\n", imm);
9535 store_data_word(destoffset, imm);
9539 if (M.x86.mode & SYSMODE_PREFIX_DATA)
9543 DECODE_PRINTF(
"DWORD PTR ");
9544 destoffset = decode_rm01_address(rl);
9545 imm = fetch_long_imm();
9546 DECODE_PRINTF2(
",%x\n", imm);
9548 store_data_long(destoffset, imm);
9554 DECODE_PRINTF(
"WORD PTR ");
9555 destoffset = decode_rm01_address(rl);
9556 imm = fetch_word_imm();
9557 DECODE_PRINTF2(
",%x\n", imm);
9559 store_data_word(destoffset, imm);
9563 if (M.x86.mode & SYSMODE_PREFIX_DATA)
9567 DECODE_PRINTF(
"DWORD PTR ");
9568 destoffset = decode_rm10_address(rl);
9569 imm = fetch_long_imm();
9570 DECODE_PRINTF2(
",%x\n", imm);
9572 store_data_long(destoffset, imm);
9578 DECODE_PRINTF(
"WORD PTR ");
9579 destoffset = decode_rm10_address(rl);
9580 imm = fetch_word_imm();
9581 DECODE_PRINTF2(
",%x\n", imm);
9583 store_data_word(destoffset, imm);
9587 if (M.x86.mode & SYSMODE_PREFIX_DATA)
9592 destreg = DECODE_RM_LONG_REGISTER(rl);
9593 imm = fetch_long_imm();
9594 DECODE_PRINTF2(
",%x\n", imm);
9603 destreg = DECODE_RM_WORD_REGISTER(rl);
9604 imm = fetch_word_imm();
9605 DECODE_PRINTF2(
",%x\n", imm);
9611 DECODE_CLEAR_SEGOVR();
9619 static void x86emuOp_enter(u8 X86EMU_UNUSED(op1))
9621 u16 local, frame_pointer;
9626 local = fetch_word_imm();
9627 nesting = fetch_byte_imm();
9628 DECODE_PRINTF2(
"ENTER %x\n", local);
9629 DECODE_PRINTF2(
",%x\n", nesting);
9631 push_word(M.x86.R_BP);
9632 frame_pointer = M.x86.R_SP;
9635 for (i = 1; i < nesting; i++)
9638 push_word(fetch_data_word_abs(M.x86.R_SS, M.x86.R_BP));
9640 push_word(frame_pointer);
9642 M.x86.R_BP = frame_pointer;
9643 M.x86.R_SP = (u16)(M.x86.R_SP - local);
9644 DECODE_CLEAR_SEGOVR();
9652 static void x86emuOp_leave(u8 X86EMU_UNUSED(op1))
9655 DECODE_PRINTF(
"LEAVE\n");
9657 M.x86.R_SP = M.x86.R_BP;
9658 M.x86.R_BP = pop_word();
9659 DECODE_CLEAR_SEGOVR();
9667 static void x86emuOp_ret_far_IMM(u8 X86EMU_UNUSED(op1))
9672 DECODE_PRINTF(
"RETF\t");
9673 imm = fetch_word_imm();
9674 DECODE_PRINTF2(
"%x\n", imm);
9675 RETURN_TRACE(
"RETF", M.x86.saved_cs, M.x86.saved_ip);
9677 M.x86.R_IP = pop_word();
9678 M.x86.R_CS = pop_word();
9680 DECODE_CLEAR_SEGOVR();
9688 static void x86emuOp_ret_far(u8 X86EMU_UNUSED(op1))
9691 DECODE_PRINTF(
"RETF\n");
9692 RETURN_TRACE(
"RETF", M.x86.saved_cs, M.x86.saved_ip);
9694 M.x86.R_IP = pop_word();
9695 M.x86.R_CS = pop_word();
9696 DECODE_CLEAR_SEGOVR();
9704 static void x86emuOp_int3(u8 X86EMU_UNUSED(op1))
9707 DECODE_PRINTF(
"INT 3\n");
9709 if (_X86EMU_intrTab[3])
9711 (*_X86EMU_intrTab[3])(3);
9715 push_word((u16) M.x86.R_FLG);
9718 push_word(M.x86.R_CS);
9719 M.x86.R_CS = mem_access_word(3 * 4 + 2);
9720 push_word(M.x86.R_IP);
9721 M.x86.R_IP = mem_access_word(3 * 4);
9723 DECODE_CLEAR_SEGOVR();
9731 static void x86emuOp_int_IMM(u8 X86EMU_UNUSED(op1))
9736 DECODE_PRINTF(
"INT\t");
9737 intnum = fetch_byte_imm();
9738 DECODE_PRINTF2(
"%x\n", intnum);
9740 if (_X86EMU_intrTab[intnum])
9742 (*_X86EMU_intrTab[intnum])(intnum);
9746 push_word((u16) M.x86.R_FLG);
9749 push_word(M.x86.R_CS);
9750 M.x86.R_CS = mem_access_word(intnum * 4 + 2);
9751 push_word(M.x86.R_IP);
9752 M.x86.R_IP = mem_access_word(intnum * 4);
9754 DECODE_CLEAR_SEGOVR();
9762 static void x86emuOp_into(u8 X86EMU_UNUSED(op1))
9765 DECODE_PRINTF(
"INTO\n");
9767 if (ACCESS_FLAG(F_OF))
9769 if (_X86EMU_intrTab[4])
9771 (*_X86EMU_intrTab[4])(4);
9775 push_word((u16) M.x86.R_FLG);
9778 push_word(M.x86.R_CS);
9779 M.x86.R_CS = mem_access_word(4 * 4 + 2);
9780 push_word(M.x86.R_IP);
9781 M.x86.R_IP = mem_access_word(4 * 4);
9784 DECODE_CLEAR_SEGOVR();
9792 static void x86emuOp_iret(u8 X86EMU_UNUSED(op1))
9795 DECODE_PRINTF(
"IRET\n");
9799 M.x86.R_IP = pop_word();
9800 M.x86.R_CS = pop_word();
9801 M.x86.R_FLG = pop_word();
9802 DECODE_CLEAR_SEGOVR();
9810 static void x86emuOp_opcD0_byte_RM_1(u8 X86EMU_UNUSED(op1))
9823 FETCH_DECODE_MODRM(mod, rh, rl);
9834 DECODE_PRINTF(
"ROL\t");
9837 DECODE_PRINTF(
"ROR\t");
9840 DECODE_PRINTF(
"RCL\t");
9843 DECODE_PRINTF(
"RCR\t");
9846 DECODE_PRINTF(
"SHL\t");
9849 DECODE_PRINTF(
"SHR\t");
9852 DECODE_PRINTF(
"SAL\t");
9855 DECODE_PRINTF(
"SAR\t");
9865 DECODE_PRINTF(
"BYTE PTR ");
9866 destoffset = decode_rm00_address(rl);
9867 DECODE_PRINTF(
",1\n");
9868 destval = fetch_data_byte(destoffset);
9870 destval = (*opcD0_byte_operation[rh])(destval, 1);
9871 store_data_byte(destoffset, destval);
9874 DECODE_PRINTF(
"BYTE PTR ");
9875 destoffset = decode_rm01_address(rl);
9876 DECODE_PRINTF(
",1\n");
9877 destval = fetch_data_byte(destoffset);
9879 destval = (*opcD0_byte_operation[rh])(destval, 1);
9880 store_data_byte(destoffset, destval);
9883 DECODE_PRINTF(
"BYTE PTR ");
9884 destoffset = decode_rm10_address(rl);
9885 DECODE_PRINTF(
",1\n");
9886 destval = fetch_data_byte(destoffset);
9888 destval = (*opcD0_byte_operation[rh])(destval, 1);
9889 store_data_byte(destoffset, destval);
9892 destreg = DECODE_RM_BYTE_REGISTER(rl);
9893 DECODE_PRINTF(
",1\n");
9895 destval = (*opcD0_byte_operation[rh])(*destreg, 1);
9899 DECODE_CLEAR_SEGOVR();
9907 static void x86emuOp_opcD1_word_RM_1(u8 X86EMU_UNUSED(op1))
9918 FETCH_DECODE_MODRM(mod, rh, rl);
9929 DECODE_PRINTF(
"ROL\t");
9932 DECODE_PRINTF(
"ROR\t");
9935 DECODE_PRINTF(
"RCL\t");
9938 DECODE_PRINTF(
"RCR\t");
9941 DECODE_PRINTF(
"SHL\t");
9944 DECODE_PRINTF(
"SHR\t");
9947 DECODE_PRINTF(
"SAL\t");
9950 DECODE_PRINTF(
"SAR\t");
9960 if (M.x86.mode & SYSMODE_PREFIX_DATA)
9964 DECODE_PRINTF(
"DWORD PTR ");
9965 destoffset = decode_rm00_address(rl);
9966 DECODE_PRINTF(
",1\n");
9967 destval = fetch_data_long(destoffset);
9969 destval = (*opcD1_long_operation[rh])(destval, 1);
9970 store_data_long(destoffset, destval);
9976 DECODE_PRINTF(
"WORD PTR ");
9977 destoffset = decode_rm00_address(rl);
9978 DECODE_PRINTF(
",1\n");
9979 destval = fetch_data_word(destoffset);
9981 destval = (*opcD1_word_operation[rh])(destval, 1);
9982 store_data_word(destoffset, destval);
9986 if (M.x86.mode & SYSMODE_PREFIX_DATA)
9990 DECODE_PRINTF(
"DWORD PTR ");
9991 destoffset = decode_rm01_address(rl);
9992 DECODE_PRINTF(
",1\n");
9993 destval = fetch_data_long(destoffset);
9995 destval = (*opcD1_long_operation[rh])(destval, 1);
9996 store_data_long(destoffset, destval);
10002 DECODE_PRINTF(
"WORD PTR ");
10003 destoffset = decode_rm01_address(rl);
10004 DECODE_PRINTF(
",1\n");
10005 destval = fetch_data_word(destoffset);
10007 destval = (*opcD1_word_operation[rh])(destval, 1);
10008 store_data_word(destoffset, destval);
10012 if (M.x86.mode & SYSMODE_PREFIX_DATA)
10016 DECODE_PRINTF(
"DWORD PTR ");
10017 destoffset = decode_rm10_address(rl);
10018 DECODE_PRINTF(
",1\n");
10019 destval = fetch_data_long(destoffset);
10021 destval = (*opcD1_long_operation[rh])(destval, 1);
10022 store_data_long(destoffset, destval);
10028 DECODE_PRINTF(
"BYTE PTR ");
10029 destoffset = decode_rm10_address(rl);
10030 DECODE_PRINTF(
",1\n");
10031 destval = fetch_data_word(destoffset);
10033 destval = (*opcD1_word_operation[rh])(destval, 1);
10034 store_data_word(destoffset, destval);
10038 if (M.x86.mode & SYSMODE_PREFIX_DATA)
10043 destreg = DECODE_RM_LONG_REGISTER(rl);
10044 DECODE_PRINTF(
",1\n");
10046 destval = (*opcD1_long_operation[rh])(*destreg, 1);
10047 *destreg = destval;
10054 destreg = DECODE_RM_WORD_REGISTER(rl);
10055 DECODE_PRINTF(
",1\n");
10057 destval = (*opcD1_word_operation[rh])(*destreg, 1);
10058 *destreg = destval;
10062 DECODE_CLEAR_SEGOVR();
10070 static void x86emuOp_opcD2_byte_RM_CL(u8 X86EMU_UNUSED(op1))
10084 FETCH_DECODE_MODRM(mod, rh, rl);
10086 if (DEBUG_DECODE())
10095 DECODE_PRINTF(
"ROL\t");
10098 DECODE_PRINTF(
"ROR\t");
10101 DECODE_PRINTF(
"RCL\t");
10104 DECODE_PRINTF(
"RCR\t");
10107 DECODE_PRINTF(
"SHL\t");
10110 DECODE_PRINTF(
"SHR\t");
10113 DECODE_PRINTF(
"SAL\t");
10116 DECODE_PRINTF(
"SAR\t");
10127 DECODE_PRINTF(
"BYTE PTR ");
10128 destoffset = decode_rm00_address(rl);
10129 DECODE_PRINTF(
",CL\n");
10130 destval = fetch_data_byte(destoffset);
10132 destval = (*opcD0_byte_operation[rh])(destval, amt);
10133 store_data_byte(destoffset, destval);
10136 DECODE_PRINTF(
"BYTE PTR ");
10137 destoffset = decode_rm01_address(rl);
10138 DECODE_PRINTF(
",CL\n");
10139 destval = fetch_data_byte(destoffset);
10141 destval = (*opcD0_byte_operation[rh])(destval, amt);
10142 store_data_byte(destoffset, destval);
10145 DECODE_PRINTF(
"BYTE PTR ");
10146 destoffset = decode_rm10_address(rl);
10147 DECODE_PRINTF(
",CL\n");
10148 destval = fetch_data_byte(destoffset);
10150 destval = (*opcD0_byte_operation[rh])(destval, amt);
10151 store_data_byte(destoffset, destval);
10154 destreg = DECODE_RM_BYTE_REGISTER(rl);
10155 DECODE_PRINTF(
",CL\n");
10157 destval = (*opcD0_byte_operation[rh])(*destreg, amt);
10158 *destreg = destval;
10161 DECODE_CLEAR_SEGOVR();
10169 static void x86emuOp_opcD3_word_RM_CL(u8 X86EMU_UNUSED(op1))
10181 FETCH_DECODE_MODRM(mod, rh, rl);
10183 if (DEBUG_DECODE())
10192 DECODE_PRINTF(
"ROL\t");
10195 DECODE_PRINTF(
"ROR\t");
10198 DECODE_PRINTF(
"RCL\t");
10201 DECODE_PRINTF(
"RCR\t");
10204 DECODE_PRINTF(
"SHL\t");
10207 DECODE_PRINTF(
"SHR\t");
10210 DECODE_PRINTF(
"SAL\t");
10213 DECODE_PRINTF(
"SAR\t");
10224 if (M.x86.mode & SYSMODE_PREFIX_DATA)
10228 DECODE_PRINTF(
"DWORD PTR ");
10229 destoffset = decode_rm00_address(rl);
10230 DECODE_PRINTF(
",CL\n");
10231 destval = fetch_data_long(destoffset);
10233 destval = (*opcD1_long_operation[rh])(destval, amt);
10234 store_data_long(destoffset, destval);
10240 DECODE_PRINTF(
"WORD PTR ");
10241 destoffset = decode_rm00_address(rl);
10242 DECODE_PRINTF(
",CL\n");
10243 destval = fetch_data_word(destoffset);
10245 destval = (*opcD1_word_operation[rh])(destval, amt);
10246 store_data_word(destoffset, destval);
10250 if (M.x86.mode & SYSMODE_PREFIX_DATA)
10254 DECODE_PRINTF(
"DWORD PTR ");
10255 destoffset = decode_rm01_address(rl);
10256 DECODE_PRINTF(
",CL\n");
10257 destval = fetch_data_long(destoffset);
10259 destval = (*opcD1_long_operation[rh])(destval, amt);
10260 store_data_long(destoffset, destval);
10266 DECODE_PRINTF(
"WORD PTR ");
10267 destoffset = decode_rm01_address(rl);
10268 DECODE_PRINTF(
",CL\n");
10269 destval = fetch_data_word(destoffset);
10271 destval = (*opcD1_word_operation[rh])(destval, amt);
10272 store_data_word(destoffset, destval);
10276 if (M.x86.mode & SYSMODE_PREFIX_DATA)
10280 DECODE_PRINTF(
"DWORD PTR ");
10281 destoffset = decode_rm10_address(rl);
10282 DECODE_PRINTF(
",CL\n");
10283 destval = fetch_data_long(destoffset);
10285 destval = (*opcD1_long_operation[rh])(destval, amt);
10286 store_data_long(destoffset, destval);
10292 DECODE_PRINTF(
"WORD PTR ");
10293 destoffset = decode_rm10_address(rl);
10294 DECODE_PRINTF(
",CL\n");
10295 destval = fetch_data_word(destoffset);
10297 destval = (*opcD1_word_operation[rh])(destval, amt);
10298 store_data_word(destoffset, destval);
10302 if (M.x86.mode & SYSMODE_PREFIX_DATA)
10306 destreg = DECODE_RM_LONG_REGISTER(rl);
10307 DECODE_PRINTF(
",CL\n");
10309 *destreg = (*opcD1_long_operation[rh])(*destreg, amt);
10315 destreg = DECODE_RM_WORD_REGISTER(rl);
10316 DECODE_PRINTF(
",CL\n");
10318 *destreg = (*opcD1_word_operation[rh])(*destreg, amt);
10322 DECODE_CLEAR_SEGOVR();
10330 static void x86emuOp_aam(u8 X86EMU_UNUSED(op1))
10335 DECODE_PRINTF(
"AAM\n");
10336 a = fetch_byte_imm();
10341 DECODE_PRINTF(
"ERROR DECODING AAM\n");
10347 M.x86.R_AX = aam_word(M.x86.R_AL);
10348 DECODE_CLEAR_SEGOVR();
10356 static void x86emuOp_aad(u8 X86EMU_UNUSED(op1))
10361 DECODE_PRINTF(
"AAD\n");
10362 a = fetch_byte_imm();
10367 DECODE_PRINTF(
"ERROR DECODING AAM\n");
10372 M.x86.R_AX = aad_word(M.x86.R_AX);
10373 DECODE_CLEAR_SEGOVR();
10383 static void x86emuOp_xlat(u8 X86EMU_UNUSED(op1))
10388 DECODE_PRINTF(
"XLAT\n");
10390 addr = (u16)(M.x86.R_BX + (u8) M.x86.R_AL);
10391 M.x86.R_AL = fetch_data_byte(addr);
10392 DECODE_CLEAR_SEGOVR();
10402 static void x86emuOp_loopne(u8 X86EMU_UNUSED(op1))
10407 DECODE_PRINTF(
"LOOPNE\t");
10408 ip = (s8) fetch_byte_imm();
10409 ip += (s16) M.x86.R_IP;
10410 DECODE_PRINTF2(
"%04x\n", ip);
10413 if (M.x86.R_CX != 0 && !ACCESS_FLAG(F_ZF))
10415 DECODE_CLEAR_SEGOVR();
10423 static void x86emuOp_loope(u8 X86EMU_UNUSED(op1))
10428 DECODE_PRINTF(
"LOOPE\t");
10429 ip = (s8) fetch_byte_imm();
10430 ip += (s16) M.x86.R_IP;
10431 DECODE_PRINTF2(
"%04x\n", ip);
10434 if (M.x86.R_CX != 0 && ACCESS_FLAG(F_ZF))
10436 DECODE_CLEAR_SEGOVR();
10444 static void x86emuOp_loop(u8 X86EMU_UNUSED(op1))
10449 DECODE_PRINTF(
"LOOP\t");
10450 ip = (s8) fetch_byte_imm();
10451 ip += (s16) M.x86.R_IP;
10452 DECODE_PRINTF2(
"%04x\n", ip);
10455 if (M.x86.R_CX != 0)
10457 DECODE_CLEAR_SEGOVR();
10465 static void x86emuOp_jcxz(u8 X86EMU_UNUSED(op1))
10472 DECODE_PRINTF(
"JCXZ\t");
10473 offset = (s8) fetch_byte_imm();
10474 target = (u16)(M.x86.R_IP + offset);
10475 DECODE_PRINTF2(
"%x\n", target);
10477 if (M.x86.R_CX == 0)
10478 M.x86.R_IP = target;
10479 DECODE_CLEAR_SEGOVR();
10487 static void x86emuOp_in_byte_AL_IMM(u8 X86EMU_UNUSED(op1))
10492 DECODE_PRINTF(
"IN\t");
10493 port = (u8) fetch_byte_imm();
10494 DECODE_PRINTF2(
"%x,AL\n", port);
10496 M.x86.R_AL = (*sys_inb)(port);
10497 DECODE_CLEAR_SEGOVR();
10505 static void x86emuOp_in_word_AX_IMM(u8 X86EMU_UNUSED(op1))
10510 DECODE_PRINTF(
"IN\t");
10511 port = (u8) fetch_byte_imm();
10512 if (M.x86.mode & SYSMODE_PREFIX_DATA)
10514 DECODE_PRINTF2(
"EAX,%x\n", port);
10518 DECODE_PRINTF2(
"AX,%x\n", port);
10521 if (M.x86.mode & SYSMODE_PREFIX_DATA)
10523 M.x86.R_EAX = (*sys_inl)(port);
10527 M.x86.R_AX = (*sys_inw)(port);
10529 DECODE_CLEAR_SEGOVR();
10537 static void x86emuOp_out_byte_IMM_AL(u8 X86EMU_UNUSED(op1))
10542 DECODE_PRINTF(
"OUT\t");
10543 port = (u8) fetch_byte_imm();
10544 DECODE_PRINTF2(
"%x,AL\n", port);
10546 (*sys_outb)(port, M.x86.R_AL);
10547 DECODE_CLEAR_SEGOVR();
10555 static void x86emuOp_out_word_IMM_AX(u8 X86EMU_UNUSED(op1))
10560 DECODE_PRINTF(
"OUT\t");
10561 port = (u8) fetch_byte_imm();
10562 if (M.x86.mode & SYSMODE_PREFIX_DATA)
10564 DECODE_PRINTF2(
"%x,EAX\n", port);
10568 DECODE_PRINTF2(
"%x,AX\n", port);
10571 if (M.x86.mode & SYSMODE_PREFIX_DATA)
10573 (*sys_outl)(port, M.x86.R_EAX);
10577 (*sys_outw)(port, M.x86.R_AX);
10579 DECODE_CLEAR_SEGOVR();
10587 static void x86emuOp_call_near_IMM(u8 X86EMU_UNUSED(op1))
10592 DECODE_PRINTF(
"CALL\t");
10593 ip = (s16) fetch_word_imm();
10594 ip += (s16) M.x86.R_IP;
10595 DECODE_PRINTF2(
"%04x\n", (u16) ip);
10596 CALL_TRACE(M.x86.saved_cs, M.x86.saved_ip, M.x86.R_CS, ip,
"");
10598 push_word(M.x86.R_IP);
10600 DECODE_CLEAR_SEGOVR();
10608 static void x86emuOp_jump_near_IMM(u8 X86EMU_UNUSED(op1))
10613 DECODE_PRINTF(
"JMP\t");
10614 ip = (s16) fetch_word_imm();
10615 ip += (s16) M.x86.R_IP;
10616 DECODE_PRINTF2(
"%04x\n", (u16) ip);
10618 M.x86.R_IP = (u16) ip;
10619 DECODE_CLEAR_SEGOVR();
10627 static void x86emuOp_jump_far_IMM(u8 X86EMU_UNUSED(op1))
10632 DECODE_PRINTF(
"JMP\tFAR ");
10633 ip = fetch_word_imm();
10634 cs = fetch_word_imm();
10635 DECODE_PRINTF2(
"%04x:", cs);
10636 DECODE_PRINTF2(
"%04x\n", ip);
10640 DECODE_CLEAR_SEGOVR();
10648 static void x86emuOp_jump_byte_IMM(u8 X86EMU_UNUSED(op1))
10654 DECODE_PRINTF(
"JMP\t");
10655 offset = (s8) fetch_byte_imm();
10656 target = (u16)(M.x86.R_IP + offset);
10657 DECODE_PRINTF2(
"%x\n", target);
10659 M.x86.R_IP = target;
10660 DECODE_CLEAR_SEGOVR();
10668 static void x86emuOp_in_byte_AL_DX(u8 X86EMU_UNUSED(op1))
10671 DECODE_PRINTF(
"IN\tAL,DX\n");
10673 M.x86.R_AL = (*sys_inb)(M.x86.R_DX);
10674 DECODE_CLEAR_SEGOVR();
10682 static void x86emuOp_in_word_AX_DX(u8 X86EMU_UNUSED(op1))
10685 if (M.x86.mode & SYSMODE_PREFIX_DATA)
10687 DECODE_PRINTF(
"IN\tEAX,DX\n");
10691 DECODE_PRINTF(
"IN\tAX,DX\n");
10694 if (M.x86.mode & SYSMODE_PREFIX_DATA)
10696 M.x86.R_EAX = (*sys_inl)(M.x86.R_DX);
10700 M.x86.R_AX = (*sys_inw)(M.x86.R_DX);
10702 DECODE_CLEAR_SEGOVR();
10710 static void x86emuOp_out_byte_DX_AL(u8 X86EMU_UNUSED(op1))
10713 DECODE_PRINTF(
"OUT\tDX,AL\n");
10715 (*sys_outb)(M.x86.R_DX, M.x86.R_AL);
10716 DECODE_CLEAR_SEGOVR();
10724 static void x86emuOp_out_word_DX_AX(u8 X86EMU_UNUSED(op1))
10727 if (M.x86.mode & SYSMODE_PREFIX_DATA)
10729 DECODE_PRINTF(
"OUT\tDX,EAX\n");
10733 DECODE_PRINTF(
"OUT\tDX,AX\n");
10736 if (M.x86.mode & SYSMODE_PREFIX_DATA)
10738 (*sys_outl)(M.x86.R_DX, M.x86.R_EAX);
10742 (*sys_outw)(M.x86.R_DX, M.x86.R_AX);
10744 DECODE_CLEAR_SEGOVR();
10752 static void x86emuOp_lock(u8 X86EMU_UNUSED(op1))
10755 DECODE_PRINTF(
"LOCK:\n");
10757 DECODE_CLEAR_SEGOVR();
10767 static void x86emuOp_repne(u8 X86EMU_UNUSED(op1))
10770 DECODE_PRINTF(
"REPNE\n");
10772 M.x86.mode |= SYSMODE_PREFIX_REPNE;
10773 DECODE_CLEAR_SEGOVR();
10781 static void x86emuOp_repe(u8 X86EMU_UNUSED(op1))
10784 DECODE_PRINTF(
"REPE\n");
10786 M.x86.mode |= SYSMODE_PREFIX_REPE;
10787 DECODE_CLEAR_SEGOVR();
10795 static void x86emuOp_halt(u8 X86EMU_UNUSED(op1))
10798 DECODE_PRINTF(
"HALT\n");
10801 DECODE_CLEAR_SEGOVR();
10809 static void x86emuOp_cmc(u8 X86EMU_UNUSED(op1))
10813 DECODE_PRINTF(
"CMC\n");
10816 DECODE_CLEAR_SEGOVR();
10824 static void x86emuOp_opcF6_byte_RM(u8 X86EMU_UNUSED(op1))
10829 u8 destval, srcval;
10834 FETCH_DECODE_MODRM(mod, rh, rl);
10841 DECODE_PRINTF(
"TEST\tBYTE PTR ");
10842 destoffset = decode_rm00_address(rl);
10843 DECODE_PRINTF(
",");
10844 srcval = fetch_byte_imm();
10845 DECODE_PRINTF2(
"%02x\n", srcval);
10846 destval = fetch_data_byte(destoffset);
10848 test_byte(destval, srcval);
10851 DECODE_PRINTF(
"ILLEGAL OP MOD=00 RH=01 OP=F6\n");
10855 DECODE_PRINTF(
"NOT\tBYTE PTR ");
10856 destoffset = decode_rm00_address(rl);
10857 DECODE_PRINTF(
"\n");
10858 destval = fetch_data_byte(destoffset);
10860 destval = not_byte(destval);
10861 store_data_byte(destoffset, destval);
10864 DECODE_PRINTF(
"NEG\tBYTE PTR ");
10865 destoffset = decode_rm00_address(rl);
10866 DECODE_PRINTF(
"\n");
10867 destval = fetch_data_byte(destoffset);
10869 destval = neg_byte(destval);
10870 store_data_byte(destoffset, destval);
10873 DECODE_PRINTF(
"MUL\tBYTE PTR ");
10874 destoffset = decode_rm00_address(rl);
10875 DECODE_PRINTF(
"\n");
10876 destval = fetch_data_byte(destoffset);
10881 DECODE_PRINTF(
"IMUL\tBYTE PTR ");
10882 destoffset = decode_rm00_address(rl);
10883 DECODE_PRINTF(
"\n");
10884 destval = fetch_data_byte(destoffset);
10886 imul_byte(destval);
10889 DECODE_PRINTF(
"DIV\tBYTE PTR ");
10890 destoffset = decode_rm00_address(rl);
10891 DECODE_PRINTF(
"\n");
10892 destval = fetch_data_byte(destoffset);
10897 DECODE_PRINTF(
"IDIV\tBYTE PTR ");
10898 destoffset = decode_rm00_address(rl);
10899 DECODE_PRINTF(
"\n");
10900 destval = fetch_data_byte(destoffset);
10902 idiv_byte(destval);
10910 DECODE_PRINTF(
"TEST\tBYTE PTR ");
10911 destoffset = decode_rm01_address(rl);
10912 DECODE_PRINTF(
",");
10913 srcval = fetch_byte_imm();
10914 DECODE_PRINTF2(
"%02x\n", srcval);
10915 destval = fetch_data_byte(destoffset);
10917 test_byte(destval, srcval);
10920 DECODE_PRINTF(
"ILLEGAL OP MOD=01 RH=01 OP=F6\n");
10924 DECODE_PRINTF(
"NOT\tBYTE PTR ");
10925 destoffset = decode_rm01_address(rl);
10926 DECODE_PRINTF(
"\n");
10927 destval = fetch_data_byte(destoffset);
10929 destval = not_byte(destval);
10930 store_data_byte(destoffset, destval);
10933 DECODE_PRINTF(
"NEG\tBYTE PTR ");
10934 destoffset = decode_rm01_address(rl);
10935 DECODE_PRINTF(
"\n");
10936 destval = fetch_data_byte(destoffset);
10938 destval = neg_byte(destval);
10939 store_data_byte(destoffset, destval);
10942 DECODE_PRINTF(
"MUL\tBYTE PTR ");
10943 destoffset = decode_rm01_address(rl);
10944 DECODE_PRINTF(
"\n");
10945 destval = fetch_data_byte(destoffset);
10950 DECODE_PRINTF(
"IMUL\tBYTE PTR ");
10951 destoffset = decode_rm01_address(rl);
10952 DECODE_PRINTF(
"\n");
10953 destval = fetch_data_byte(destoffset);
10955 imul_byte(destval);
10958 DECODE_PRINTF(
"DIV\tBYTE PTR ");
10959 destoffset = decode_rm01_address(rl);
10960 DECODE_PRINTF(
"\n");
10961 destval = fetch_data_byte(destoffset);
10966 DECODE_PRINTF(
"IDIV\tBYTE PTR ");
10967 destoffset = decode_rm01_address(rl);
10968 DECODE_PRINTF(
"\n");
10969 destval = fetch_data_byte(destoffset);
10971 idiv_byte(destval);
10979 DECODE_PRINTF(
"TEST\tBYTE PTR ");
10980 destoffset = decode_rm10_address(rl);
10981 DECODE_PRINTF(
",");
10982 srcval = fetch_byte_imm();
10983 DECODE_PRINTF2(
"%02x\n", srcval);
10984 destval = fetch_data_byte(destoffset);
10986 test_byte(destval, srcval);
10989 DECODE_PRINTF(
"ILLEGAL OP MOD=10 RH=01 OP=F6\n");
10993 DECODE_PRINTF(
"NOT\tBYTE PTR ");
10994 destoffset = decode_rm10_address(rl);
10995 DECODE_PRINTF(
"\n");
10996 destval = fetch_data_byte(destoffset);
10998 destval = not_byte(destval);
10999 store_data_byte(destoffset, destval);
11002 DECODE_PRINTF(
"NEG\tBYTE PTR ");
11003 destoffset = decode_rm10_address(rl);
11004 DECODE_PRINTF(
"\n");
11005 destval = fetch_data_byte(destoffset);
11007 destval = neg_byte(destval);
11008 store_data_byte(destoffset, destval);
11011 DECODE_PRINTF(
"MUL\tBYTE PTR ");
11012 destoffset = decode_rm10_address(rl);
11013 DECODE_PRINTF(
"\n");
11014 destval = fetch_data_byte(destoffset);
11019 DECODE_PRINTF(
"IMUL\tBYTE PTR ");
11020 destoffset = decode_rm10_address(rl);
11021 DECODE_PRINTF(
"\n");
11022 destval = fetch_data_byte(destoffset);
11024 imul_byte(destval);
11027 DECODE_PRINTF(
"DIV\tBYTE PTR ");
11028 destoffset = decode_rm10_address(rl);
11029 DECODE_PRINTF(
"\n");
11030 destval = fetch_data_byte(destoffset);
11035 DECODE_PRINTF(
"IDIV\tBYTE PTR ");
11036 destoffset = decode_rm10_address(rl);
11037 DECODE_PRINTF(
"\n");
11038 destval = fetch_data_byte(destoffset);
11040 idiv_byte(destval);
11048 DECODE_PRINTF(
"TEST\t");
11049 destreg = DECODE_RM_BYTE_REGISTER(rl);
11050 DECODE_PRINTF(
",");
11051 srcval = fetch_byte_imm();
11052 DECODE_PRINTF2(
"%02x\n", srcval);
11054 test_byte(*destreg, srcval);
11057 DECODE_PRINTF(
"ILLEGAL OP MOD=00 RH=01 OP=F6\n");
11061 DECODE_PRINTF(
"NOT\t");
11062 destreg = DECODE_RM_BYTE_REGISTER(rl);
11063 DECODE_PRINTF(
"\n");
11065 *destreg = not_byte(*destreg);
11068 DECODE_PRINTF(
"NEG\t");
11069 destreg = DECODE_RM_BYTE_REGISTER(rl);
11070 DECODE_PRINTF(
"\n");
11072 *destreg = neg_byte(*destreg);
11075 DECODE_PRINTF(
"MUL\t");
11076 destreg = DECODE_RM_BYTE_REGISTER(rl);
11077 DECODE_PRINTF(
"\n");
11079 mul_byte(*destreg);
11082 DECODE_PRINTF(
"IMUL\t");
11083 destreg = DECODE_RM_BYTE_REGISTER(rl);
11084 DECODE_PRINTF(
"\n");
11086 imul_byte(*destreg);
11089 DECODE_PRINTF(
"DIV\t");
11090 destreg = DECODE_RM_BYTE_REGISTER(rl);
11091 DECODE_PRINTF(
"\n");
11093 div_byte(*destreg);
11096 DECODE_PRINTF(
"IDIV\t");
11097 destreg = DECODE_RM_BYTE_REGISTER(rl);
11098 DECODE_PRINTF(
"\n");
11100 idiv_byte(*destreg);
11105 DECODE_CLEAR_SEGOVR();
11113 static void x86emuOp_opcF7_word_RM(u8 X86EMU_UNUSED(op1))
11121 FETCH_DECODE_MODRM(mod, rh, rl);
11128 if (M.x86.mode & SYSMODE_PREFIX_DATA)
11130 u32 destval, srcval;
11132 DECODE_PRINTF(
"TEST\tDWORD PTR ");
11133 destoffset = decode_rm00_address(rl);
11134 DECODE_PRINTF(
",");
11135 srcval = fetch_long_imm();
11136 DECODE_PRINTF2(
"%x\n", srcval);
11137 destval = fetch_data_long(destoffset);
11139 test_long(destval, srcval);
11143 u16 destval, srcval;
11145 DECODE_PRINTF(
"TEST\tWORD PTR ");
11146 destoffset = decode_rm00_address(rl);
11147 DECODE_PRINTF(
",");
11148 srcval = fetch_word_imm();
11149 DECODE_PRINTF2(
"%x\n", srcval);
11150 destval = fetch_data_word(destoffset);
11152 test_word(destval, srcval);
11156 DECODE_PRINTF(
"ILLEGAL OP MOD=00 RH=01 OP=F7\n");
11160 if (M.x86.mode & SYSMODE_PREFIX_DATA)
11164 DECODE_PRINTF(
"NOT\tDWORD PTR ");
11165 destoffset = decode_rm00_address(rl);
11166 DECODE_PRINTF(
"\n");
11167 destval = fetch_data_long(destoffset);
11169 destval = not_long(destval);
11170 store_data_long(destoffset, destval);
11176 DECODE_PRINTF(
"NOT\tWORD PTR ");
11177 destoffset = decode_rm00_address(rl);
11178 DECODE_PRINTF(
"\n");
11179 destval = fetch_data_word(destoffset);
11181 destval = not_word(destval);
11182 store_data_word(destoffset, destval);
11186 if (M.x86.mode & SYSMODE_PREFIX_DATA)
11190 DECODE_PRINTF(
"NEG\tDWORD PTR ");
11191 destoffset = decode_rm00_address(rl);
11192 DECODE_PRINTF(
"\n");
11193 destval = fetch_data_long(destoffset);
11195 destval = neg_long(destval);
11196 store_data_long(destoffset, destval);
11202 DECODE_PRINTF(
"NEG\tWORD PTR ");
11203 destoffset = decode_rm00_address(rl);
11204 DECODE_PRINTF(
"\n");
11205 destval = fetch_data_word(destoffset);
11207 destval = neg_word(destval);
11208 store_data_word(destoffset, destval);
11212 if (M.x86.mode & SYSMODE_PREFIX_DATA)
11216 DECODE_PRINTF(
"MUL\tDWORD PTR ");
11217 destoffset = decode_rm00_address(rl);
11218 DECODE_PRINTF(
"\n");
11219 destval = fetch_data_long(destoffset);
11227 DECODE_PRINTF(
"MUL\tWORD PTR ");
11228 destoffset = decode_rm00_address(rl);
11229 DECODE_PRINTF(
"\n");
11230 destval = fetch_data_word(destoffset);
11236 if (M.x86.mode & SYSMODE_PREFIX_DATA)
11240 DECODE_PRINTF(
"IMUL\tDWORD PTR ");
11241 destoffset = decode_rm00_address(rl);
11242 DECODE_PRINTF(
"\n");
11243 destval = fetch_data_long(destoffset);
11245 imul_long(destval);
11251 DECODE_PRINTF(
"IMUL\tWORD PTR ");
11252 destoffset = decode_rm00_address(rl);
11253 DECODE_PRINTF(
"\n");
11254 destval = fetch_data_word(destoffset);
11256 imul_word(destval);
11260 if (M.x86.mode & SYSMODE_PREFIX_DATA)
11264 DECODE_PRINTF(
"DIV\tDWORD PTR ");
11265 destoffset = decode_rm00_address(rl);
11266 DECODE_PRINTF(
"\n");
11267 destval = fetch_data_long(destoffset);
11275 DECODE_PRINTF(
"DIV\tWORD PTR ");
11276 destoffset = decode_rm00_address(rl);
11277 DECODE_PRINTF(
"\n");
11278 destval = fetch_data_word(destoffset);
11284 if (M.x86.mode & SYSMODE_PREFIX_DATA)
11288 DECODE_PRINTF(
"IDIV\tDWORD PTR ");
11289 destoffset = decode_rm00_address(rl);
11290 DECODE_PRINTF(
"\n");
11291 destval = fetch_data_long(destoffset);
11293 idiv_long(destval);
11299 DECODE_PRINTF(
"IDIV\tWORD PTR ");
11300 destoffset = decode_rm00_address(rl);
11301 DECODE_PRINTF(
"\n");
11302 destval = fetch_data_word(destoffset);
11304 idiv_word(destval);
11313 if (M.x86.mode & SYSMODE_PREFIX_DATA)
11315 u32 destval, srcval;
11317 DECODE_PRINTF(
"TEST\tDWORD PTR ");
11318 destoffset = decode_rm01_address(rl);
11319 DECODE_PRINTF(
",");
11320 srcval = fetch_long_imm();
11321 DECODE_PRINTF2(
"%x\n", srcval);
11322 destval = fetch_data_long(destoffset);
11324 test_long(destval, srcval);
11328 u16 destval, srcval;
11330 DECODE_PRINTF(
"TEST\tWORD PTR ");
11331 destoffset = decode_rm01_address(rl);
11332 DECODE_PRINTF(
",");
11333 srcval = fetch_word_imm();
11334 DECODE_PRINTF2(
"%x\n", srcval);
11335 destval = fetch_data_word(destoffset);
11337 test_word(destval, srcval);
11341 DECODE_PRINTF(
"ILLEGAL OP MOD=01 RH=01 OP=F6\n");
11345 if (M.x86.mode & SYSMODE_PREFIX_DATA)
11349 DECODE_PRINTF(
"NOT\tDWORD PTR ");
11350 destoffset = decode_rm01_address(rl);
11351 DECODE_PRINTF(
"\n");
11352 destval = fetch_data_long(destoffset);
11354 destval = not_long(destval);
11355 store_data_long(destoffset, destval);
11361 DECODE_PRINTF(
"NOT\tWORD PTR ");
11362 destoffset = decode_rm01_address(rl);
11363 DECODE_PRINTF(
"\n");
11364 destval = fetch_data_word(destoffset);
11366 destval = not_word(destval);
11367 store_data_word(destoffset, destval);
11371 if (M.x86.mode & SYSMODE_PREFIX_DATA)
11375 DECODE_PRINTF(
"NEG\tDWORD PTR ");
11376 destoffset = decode_rm01_address(rl);
11377 DECODE_PRINTF(
"\n");
11378 destval = fetch_data_long(destoffset);
11380 destval = neg_long(destval);
11381 store_data_long(destoffset, destval);
11387 DECODE_PRINTF(
"NEG\tWORD PTR ");
11388 destoffset = decode_rm01_address(rl);
11389 DECODE_PRINTF(
"\n");
11390 destval = fetch_data_word(destoffset);
11392 destval = neg_word(destval);
11393 store_data_word(destoffset, destval);
11397 if (M.x86.mode & SYSMODE_PREFIX_DATA)
11401 DECODE_PRINTF(
"MUL\tDWORD PTR ");
11402 destoffset = decode_rm01_address(rl);
11403 DECODE_PRINTF(
"\n");
11404 destval = fetch_data_long(destoffset);
11412 DECODE_PRINTF(
"MUL\tWORD PTR ");
11413 destoffset = decode_rm01_address(rl);
11414 DECODE_PRINTF(
"\n");
11415 destval = fetch_data_word(destoffset);
11421 if (M.x86.mode & SYSMODE_PREFIX_DATA)
11425 DECODE_PRINTF(
"IMUL\tDWORD PTR ");
11426 destoffset = decode_rm01_address(rl);
11427 DECODE_PRINTF(
"\n");
11428 destval = fetch_data_long(destoffset);
11430 imul_long(destval);
11436 DECODE_PRINTF(
"IMUL\tWORD PTR ");
11437 destoffset = decode_rm01_address(rl);
11438 DECODE_PRINTF(
"\n");
11439 destval = fetch_data_word(destoffset);
11441 imul_word(destval);
11445 if (M.x86.mode & SYSMODE_PREFIX_DATA)
11449 DECODE_PRINTF(
"DIV\tDWORD PTR ");
11450 destoffset = decode_rm01_address(rl);
11451 DECODE_PRINTF(
"\n");
11452 destval = fetch_data_long(destoffset);
11460 DECODE_PRINTF(
"DIV\tWORD PTR ");
11461 destoffset = decode_rm01_address(rl);
11462 DECODE_PRINTF(
"\n");
11463 destval = fetch_data_word(destoffset);
11469 if (M.x86.mode & SYSMODE_PREFIX_DATA)
11473 DECODE_PRINTF(
"IDIV\tDWORD PTR ");
11474 destoffset = decode_rm01_address(rl);
11475 DECODE_PRINTF(
"\n");
11476 destval = fetch_data_long(destoffset);
11478 idiv_long(destval);
11484 DECODE_PRINTF(
"IDIV\tWORD PTR ");
11485 destoffset = decode_rm01_address(rl);
11486 DECODE_PRINTF(
"\n");
11487 destval = fetch_data_word(destoffset);
11489 idiv_word(destval);
11498 if (M.x86.mode & SYSMODE_PREFIX_DATA)
11500 u32 destval, srcval;
11502 DECODE_PRINTF(
"TEST\tDWORD PTR ");
11503 destoffset = decode_rm10_address(rl);
11504 DECODE_PRINTF(
",");
11505 srcval = fetch_long_imm();
11506 DECODE_PRINTF2(
"%x\n", srcval);
11507 destval = fetch_data_long(destoffset);
11509 test_long(destval, srcval);
11513 u16 destval, srcval;
11515 DECODE_PRINTF(
"TEST\tWORD PTR ");
11516 destoffset = decode_rm10_address(rl);
11517 DECODE_PRINTF(
",");
11518 srcval = fetch_word_imm();
11519 DECODE_PRINTF2(
"%x\n", srcval);
11520 destval = fetch_data_word(destoffset);
11522 test_word(destval, srcval);
11526 DECODE_PRINTF(
"ILLEGAL OP MOD=10 RH=01 OP=F6\n");
11530 if (M.x86.mode & SYSMODE_PREFIX_DATA)
11534 DECODE_PRINTF(
"NOT\tDWORD PTR ");
11535 destoffset = decode_rm10_address(rl);
11536 DECODE_PRINTF(
"\n");
11537 destval = fetch_data_long(destoffset);
11539 destval = not_long(destval);
11540 store_data_long(destoffset, destval);
11546 DECODE_PRINTF(
"NOT\tWORD PTR ");
11547 destoffset = decode_rm10_address(rl);
11548 DECODE_PRINTF(
"\n");
11549 destval = fetch_data_word(destoffset);
11551 destval = not_word(destval);
11552 store_data_word(destoffset, destval);
11556 if (M.x86.mode & SYSMODE_PREFIX_DATA)
11560 DECODE_PRINTF(
"NEG\tDWORD PTR ");
11561 destoffset = decode_rm10_address(rl);
11562 DECODE_PRINTF(
"\n");
11563 destval = fetch_data_long(destoffset);
11565 destval = neg_long(destval);
11566 store_data_long(destoffset, destval);
11572 DECODE_PRINTF(
"NEG\tWORD PTR ");
11573 destoffset = decode_rm10_address(rl);
11574 DECODE_PRINTF(
"\n");
11575 destval = fetch_data_word(destoffset);
11577 destval = neg_word(destval);
11578 store_data_word(destoffset, destval);
11582 if (M.x86.mode & SYSMODE_PREFIX_DATA)
11586 DECODE_PRINTF(
"MUL\tDWORD PTR ");
11587 destoffset = decode_rm10_address(rl);
11588 DECODE_PRINTF(
"\n");
11589 destval = fetch_data_long(destoffset);
11597 DECODE_PRINTF(
"MUL\tWORD PTR ");
11598 destoffset = decode_rm10_address(rl);
11599 DECODE_PRINTF(
"\n");
11600 destval = fetch_data_word(destoffset);
11606 if (M.x86.mode & SYSMODE_PREFIX_DATA)
11610 DECODE_PRINTF(
"IMUL\tDWORD PTR ");
11611 destoffset = decode_rm10_address(rl);
11612 DECODE_PRINTF(
"\n");
11613 destval = fetch_data_long(destoffset);
11615 imul_long(destval);
11621 DECODE_PRINTF(
"IMUL\tWORD PTR ");
11622 destoffset = decode_rm10_address(rl);
11623 DECODE_PRINTF(
"\n");
11624 destval = fetch_data_word(destoffset);
11626 imul_word(destval);
11630 if (M.x86.mode & SYSMODE_PREFIX_DATA)
11634 DECODE_PRINTF(
"DIV\tDWORD PTR ");
11635 destoffset = decode_rm10_address(rl);
11636 DECODE_PRINTF(
"\n");
11637 destval = fetch_data_long(destoffset);
11645 DECODE_PRINTF(
"DIV\tWORD PTR ");
11646 destoffset = decode_rm10_address(rl);
11647 DECODE_PRINTF(
"\n");
11648 destval = fetch_data_word(destoffset);
11654 if (M.x86.mode & SYSMODE_PREFIX_DATA)
11658 DECODE_PRINTF(
"IDIV\tDWORD PTR ");
11659 destoffset = decode_rm10_address(rl);
11660 DECODE_PRINTF(
"\n");
11661 destval = fetch_data_long(destoffset);
11663 idiv_long(destval);
11669 DECODE_PRINTF(
"IDIV\tWORD PTR ");
11670 destoffset = decode_rm10_address(rl);
11671 DECODE_PRINTF(
"\n");
11672 destval = fetch_data_word(destoffset);
11674 idiv_word(destval);
11683 if (M.x86.mode & SYSMODE_PREFIX_DATA)
11688 DECODE_PRINTF(
"TEST\t");
11689 destreg = DECODE_RM_LONG_REGISTER(rl);
11690 DECODE_PRINTF(
",");
11691 srcval = fetch_long_imm();
11692 DECODE_PRINTF2(
"%x\n", srcval);
11694 test_long(*destreg, srcval);
11701 DECODE_PRINTF(
"TEST\t");
11702 destreg = DECODE_RM_WORD_REGISTER(rl);
11703 DECODE_PRINTF(
",");
11704 srcval = fetch_word_imm();
11705 DECODE_PRINTF2(
"%x\n", srcval);
11707 test_word(*destreg, srcval);
11711 DECODE_PRINTF(
"ILLEGAL OP MOD=00 RH=01 OP=F6\n");
11715 if (M.x86.mode & SYSMODE_PREFIX_DATA)
11719 DECODE_PRINTF(
"NOT\t");
11720 destreg = DECODE_RM_LONG_REGISTER(rl);
11721 DECODE_PRINTF(
"\n");
11723 *destreg = not_long(*destreg);
11729 DECODE_PRINTF(
"NOT\t");
11730 destreg = DECODE_RM_WORD_REGISTER(rl);
11731 DECODE_PRINTF(
"\n");
11733 *destreg = not_word(*destreg);
11737 if (M.x86.mode & SYSMODE_PREFIX_DATA)
11741 DECODE_PRINTF(
"NEG\t");
11742 destreg = DECODE_RM_LONG_REGISTER(rl);
11743 DECODE_PRINTF(
"\n");
11745 *destreg = neg_long(*destreg);
11751 DECODE_PRINTF(
"NEG\t");
11752 destreg = DECODE_RM_WORD_REGISTER(rl);
11753 DECODE_PRINTF(
"\n");
11755 *destreg = neg_word(*destreg);
11759 if (M.x86.mode & SYSMODE_PREFIX_DATA)
11763 DECODE_PRINTF(
"MUL\t");
11764 destreg = DECODE_RM_LONG_REGISTER(rl);
11765 DECODE_PRINTF(
"\n");
11767 mul_long(*destreg);
11773 DECODE_PRINTF(
"MUL\t");
11774 destreg = DECODE_RM_WORD_REGISTER(rl);
11775 DECODE_PRINTF(
"\n");
11777 mul_word(*destreg);
11781 if (M.x86.mode & SYSMODE_PREFIX_DATA)
11785 DECODE_PRINTF(
"IMUL\t");
11786 destreg = DECODE_RM_LONG_REGISTER(rl);
11787 DECODE_PRINTF(
"\n");
11789 imul_long(*destreg);
11795 DECODE_PRINTF(
"IMUL\t");
11796 destreg = DECODE_RM_WORD_REGISTER(rl);
11797 DECODE_PRINTF(
"\n");
11799 imul_word(*destreg);
11803 if (M.x86.mode & SYSMODE_PREFIX_DATA)
11807 DECODE_PRINTF(
"DIV\t");
11808 destreg = DECODE_RM_LONG_REGISTER(rl);
11809 DECODE_PRINTF(
"\n");
11811 div_long(*destreg);
11817 DECODE_PRINTF(
"DIV\t");
11818 destreg = DECODE_RM_WORD_REGISTER(rl);
11819 DECODE_PRINTF(
"\n");
11821 div_word(*destreg);
11825 if (M.x86.mode & SYSMODE_PREFIX_DATA)
11829 DECODE_PRINTF(
"IDIV\t");
11830 destreg = DECODE_RM_LONG_REGISTER(rl);
11831 DECODE_PRINTF(
"\n");
11833 idiv_long(*destreg);
11839 DECODE_PRINTF(
"IDIV\t");
11840 destreg = DECODE_RM_WORD_REGISTER(rl);
11841 DECODE_PRINTF(
"\n");
11843 idiv_word(*destreg);
11849 DECODE_CLEAR_SEGOVR();
11857 static void x86emuOp_clc(u8 X86EMU_UNUSED(op1))
11861 DECODE_PRINTF(
"CLC\n");
11864 DECODE_CLEAR_SEGOVR();
11872 static void x86emuOp_stc(u8 X86EMU_UNUSED(op1))
11876 DECODE_PRINTF(
"STC\n");
11879 DECODE_CLEAR_SEGOVR();
11887 static void x86emuOp_cli(u8 X86EMU_UNUSED(op1))
11891 DECODE_PRINTF(
"CLI\n");
11894 DECODE_CLEAR_SEGOVR();
11902 static void x86emuOp_sti(u8 X86EMU_UNUSED(op1))
11906 DECODE_PRINTF(
"STI\n");
11909 DECODE_CLEAR_SEGOVR();
11917 static void x86emuOp_cld(u8 X86EMU_UNUSED(op1))
11921 DECODE_PRINTF(
"CLD\n");
11924 DECODE_CLEAR_SEGOVR();
11932 static void x86emuOp_std(u8 X86EMU_UNUSED(op1))
11936 DECODE_PRINTF(
"STD\n");
11939 DECODE_CLEAR_SEGOVR();
11947 static void x86emuOp_opcFE_byte_RM(u8 X86EMU_UNUSED(op1))
11956 FETCH_DECODE_MODRM(mod, rh, rl);
11958 if (DEBUG_DECODE())
11968 DECODE_PRINTF(
"INC\t");
11971 DECODE_PRINTF(
"DEC\t");
11979 DECODE_PRINTF2(
"ILLEGAL OP MAJOR OP 0xFE MINOR OP %x \n", mod);
11988 DECODE_PRINTF(
"BYTE PTR ");
11989 destoffset = decode_rm00_address(rl);
11990 DECODE_PRINTF(
"\n");
11994 destval = fetch_data_byte(destoffset);
11996 destval = inc_byte(destval);
11997 store_data_byte(destoffset, destval);
12000 destval = fetch_data_byte(destoffset);
12002 destval = dec_byte(destval);
12003 store_data_byte(destoffset, destval);
12008 DECODE_PRINTF(
"BYTE PTR ");
12009 destoffset = decode_rm01_address(rl);
12010 DECODE_PRINTF(
"\n");
12014 destval = fetch_data_byte(destoffset);
12016 destval = inc_byte(destval);
12017 store_data_byte(destoffset, destval);
12020 destval = fetch_data_byte(destoffset);
12022 destval = dec_byte(destval);
12023 store_data_byte(destoffset, destval);
12028 DECODE_PRINTF(
"BYTE PTR ");
12029 destoffset = decode_rm10_address(rl);
12030 DECODE_PRINTF(
"\n");
12034 destval = fetch_data_byte(destoffset);
12036 destval = inc_byte(destval);
12037 store_data_byte(destoffset, destval);
12040 destval = fetch_data_byte(destoffset);
12042 destval = dec_byte(destval);
12043 store_data_byte(destoffset, destval);
12048 destreg = DECODE_RM_BYTE_REGISTER(rl);
12049 DECODE_PRINTF(
"\n");
12054 *destreg = inc_byte(*destreg);
12058 *destreg = dec_byte(*destreg);
12063 DECODE_CLEAR_SEGOVR();
12071 static void x86emuOp_opcFF_word_RM(u8 X86EMU_UNUSED(op1))
12074 uint destoffset = 0;
12076 u16 destval, destval2;
12080 FETCH_DECODE_MODRM(mod, rh, rl);
12082 if (DEBUG_DECODE())
12092 if (M.x86.mode & SYSMODE_PREFIX_DATA)
12094 DECODE_PRINTF(
"INC\tDWORD PTR ");
12098 DECODE_PRINTF(
"INC\tWORD PTR ");
12102 if (M.x86.mode & SYSMODE_PREFIX_DATA)
12104 DECODE_PRINTF(
"DEC\tDWORD PTR ");
12108 DECODE_PRINTF(
"DEC\tWORD PTR ");
12112 DECODE_PRINTF(
"CALL\t");
12115 DECODE_PRINTF(
"CALL\tFAR ");
12118 DECODE_PRINTF(
"JMP\t");
12121 DECODE_PRINTF(
"JMP\tFAR ");
12124 DECODE_PRINTF(
"PUSH\t");
12127 DECODE_PRINTF(
"ILLEGAL DECODING OF OPCODE FF\t");
12136 destoffset = decode_rm00_address(rl);
12137 DECODE_PRINTF(
"\n");
12141 if (M.x86.mode & SYSMODE_PREFIX_DATA)
12145 destval = fetch_data_long(destoffset);
12147 destval = inc_long(destval);
12148 store_data_long(destoffset, destval);
12154 destval = fetch_data_word(destoffset);
12156 destval = inc_word(destval);
12157 store_data_word(destoffset, destval);
12161 if (M.x86.mode & SYSMODE_PREFIX_DATA)
12165 destval = fetch_data_long(destoffset);
12167 destval = dec_long(destval);
12168 store_data_long(destoffset, destval);
12174 destval = fetch_data_word(destoffset);
12176 destval = dec_word(destval);
12177 store_data_word(destoffset, destval);
12181 destval = fetch_data_word(destoffset);
12183 push_word(M.x86.R_IP);
12184 M.x86.R_IP = destval;
12187 destval = fetch_data_word(destoffset);
12188 destval2 = fetch_data_word(destoffset + 2);
12190 push_word(M.x86.R_CS);
12191 M.x86.R_CS = destval2;
12192 push_word(M.x86.R_IP);
12193 M.x86.R_IP = destval;
12196 destval = fetch_data_word(destoffset);
12198 M.x86.R_IP = destval;
12201 destval = fetch_data_word(destoffset);
12202 destval2 = fetch_data_word(destoffset + 2);
12204 M.x86.R_IP = destval;
12205 M.x86.R_CS = destval2;
12208 if (M.x86.mode & SYSMODE_PREFIX_DATA)
12212 destval = fetch_data_long(destoffset);
12214 push_long(destval);
12220 destval = fetch_data_word(destoffset);
12222 push_word(destval);
12228 destoffset = decode_rm01_address(rl);
12229 DECODE_PRINTF(
"\n");
12233 if (M.x86.mode & SYSMODE_PREFIX_DATA)
12237 destval = fetch_data_long(destoffset);
12239 destval = inc_long(destval);
12240 store_data_long(destoffset, destval);
12246 destval = fetch_data_word(destoffset);
12248 destval = inc_word(destval);
12249 store_data_word(destoffset, destval);
12253 if (M.x86.mode & SYSMODE_PREFIX_DATA)
12257 destval = fetch_data_long(destoffset);
12259 destval = dec_long(destval);
12260 store_data_long(destoffset, destval);
12266 destval = fetch_data_word(destoffset);
12268 destval = dec_word(destval);
12269 store_data_word(destoffset, destval);
12273 destval = fetch_data_word(destoffset);
12275 push_word(M.x86.R_IP);
12276 M.x86.R_IP = destval;
12279 destval = fetch_data_word(destoffset);
12280 destval2 = fetch_data_word(destoffset + 2);
12282 push_word(M.x86.R_CS);
12283 M.x86.R_CS = destval2;
12284 push_word(M.x86.R_IP);
12285 M.x86.R_IP = destval;
12288 destval = fetch_data_word(destoffset);
12290 M.x86.R_IP = destval;
12293 destval = fetch_data_word(destoffset);
12294 destval2 = fetch_data_word(destoffset + 2);
12296 M.x86.R_IP = destval;
12297 M.x86.R_CS = destval2;
12300 if (M.x86.mode & SYSMODE_PREFIX_DATA)
12304 destval = fetch_data_long(destoffset);
12306 push_long(destval);
12312 destval = fetch_data_word(destoffset);
12314 push_word(destval);
12320 destoffset = decode_rm10_address(rl);
12321 DECODE_PRINTF(
"\n");
12325 if (M.x86.mode & SYSMODE_PREFIX_DATA)
12329 destval = fetch_data_long(destoffset);
12331 destval = inc_long(destval);
12332 store_data_long(destoffset, destval);
12338 destval = fetch_data_word(destoffset);
12340 destval = inc_word(destval);
12341 store_data_word(destoffset, destval);
12345 if (M.x86.mode & SYSMODE_PREFIX_DATA)
12349 destval = fetch_data_long(destoffset);
12351 destval = dec_long(destval);
12352 store_data_long(destoffset, destval);
12358 destval = fetch_data_word(destoffset);
12360 destval = dec_word(destval);
12361 store_data_word(destoffset, destval);
12365 destval = fetch_data_word(destoffset);
12367 push_word(M.x86.R_IP);
12368 M.x86.R_IP = destval;
12371 destval = fetch_data_word(destoffset);
12372 destval2 = fetch_data_word(destoffset + 2);
12374 push_word(M.x86.R_CS);
12375 M.x86.R_CS = destval2;
12376 push_word(M.x86.R_IP);
12377 M.x86.R_IP = destval;
12380 destval = fetch_data_word(destoffset);
12382 M.x86.R_IP = destval;
12385 destval = fetch_data_word(destoffset);
12386 destval2 = fetch_data_word(destoffset + 2);
12388 M.x86.R_IP = destval;
12389 M.x86.R_CS = destval2;
12392 if (M.x86.mode & SYSMODE_PREFIX_DATA)
12396 destval = fetch_data_long(destoffset);
12398 push_long(destval);
12404 destval = fetch_data_word(destoffset);
12406 push_word(destval);
12415 if (M.x86.mode & SYSMODE_PREFIX_DATA)
12419 destreg = DECODE_RM_LONG_REGISTER(rl);
12420 DECODE_PRINTF(
"\n");
12422 *destreg = inc_long(*destreg);
12428 destreg = DECODE_RM_WORD_REGISTER(rl);
12429 DECODE_PRINTF(
"\n");
12431 *destreg = inc_word(*destreg);
12435 if (M.x86.mode & SYSMODE_PREFIX_DATA)
12439 destreg = DECODE_RM_LONG_REGISTER(rl);
12440 DECODE_PRINTF(
"\n");
12442 *destreg = dec_long(*destreg);
12448 destreg = DECODE_RM_WORD_REGISTER(rl);
12449 DECODE_PRINTF(
"\n");
12451 *destreg = dec_word(*destreg);
12455 destreg = DECODE_RM_WORD_REGISTER(rl);
12456 DECODE_PRINTF(
"\n");
12458 push_word(M.x86.R_IP);
12459 M.x86.R_IP = *destreg;
12462 DECODE_PRINTF(
"OPERATION UNDEFINED 0XFF \n");
12468 destreg = DECODE_RM_WORD_REGISTER(rl);
12469 DECODE_PRINTF(
"\n");
12471 M.x86.R_IP = (u16)(*destreg);
12474 DECODE_PRINTF(
"OPERATION UNDEFINED 0XFF \n");
12479 if (M.x86.mode & SYSMODE_PREFIX_DATA)
12483 destreg = DECODE_RM_LONG_REGISTER(rl);
12484 DECODE_PRINTF(
"\n");
12486 push_long(*destreg);
12492 destreg = DECODE_RM_WORD_REGISTER(rl);
12493 DECODE_PRINTF(
"\n");
12495 push_word(*destreg);
12501 DECODE_CLEAR_SEGOVR();
12508 void (*x86emu_optab[256])(u8) = {
12509 x86emuOp_add_byte_RM_R,
12510 x86emuOp_add_word_RM_R,
12511 x86emuOp_add_byte_R_RM,
12512 x86emuOp_add_word_R_RM,
12513 x86emuOp_add_byte_AL_IMM,
12514 x86emuOp_add_word_AX_IMM,
12518 x86emuOp_or_byte_RM_R,
12519 x86emuOp_or_word_RM_R,
12520 x86emuOp_or_byte_R_RM,
12521 x86emuOp_or_word_R_RM,
12522 x86emuOp_or_byte_AL_IMM,
12523 x86emuOp_or_word_AX_IMM,
12527 x86emuOp_adc_byte_RM_R,
12528 x86emuOp_adc_word_RM_R,
12529 x86emuOp_adc_byte_R_RM,
12530 x86emuOp_adc_word_R_RM,
12531 x86emuOp_adc_byte_AL_IMM,
12532 x86emuOp_adc_word_AX_IMM,
12536 x86emuOp_sbb_byte_RM_R,
12537 x86emuOp_sbb_word_RM_R,
12538 x86emuOp_sbb_byte_R_RM,
12539 x86emuOp_sbb_word_R_RM,
12540 x86emuOp_sbb_byte_AL_IMM,
12541 x86emuOp_sbb_word_AX_IMM,
12545 x86emuOp_and_byte_RM_R,
12546 x86emuOp_and_word_RM_R,
12547 x86emuOp_and_byte_R_RM,
12548 x86emuOp_and_word_R_RM,
12549 x86emuOp_and_byte_AL_IMM,
12550 x86emuOp_and_word_AX_IMM,
12551 x86emuOp_segovr_ES,
12554 x86emuOp_sub_byte_RM_R,
12555 x86emuOp_sub_word_RM_R,
12556 x86emuOp_sub_byte_R_RM,
12557 x86emuOp_sub_word_R_RM,
12558 x86emuOp_sub_byte_AL_IMM,
12559 x86emuOp_sub_word_AX_IMM,
12560 x86emuOp_segovr_CS,
12563 x86emuOp_xor_byte_RM_R,
12564 x86emuOp_xor_word_RM_R,
12565 x86emuOp_xor_byte_R_RM,
12566 x86emuOp_xor_word_R_RM,
12567 x86emuOp_xor_byte_AL_IMM,
12568 x86emuOp_xor_word_AX_IMM,
12569 x86emuOp_segovr_SS,
12572 x86emuOp_cmp_byte_RM_R,
12573 x86emuOp_cmp_word_RM_R,
12574 x86emuOp_cmp_byte_R_RM,
12575 x86emuOp_cmp_word_R_RM,
12576 x86emuOp_cmp_byte_AL_IMM,
12577 x86emuOp_cmp_word_AX_IMM,
12578 x86emuOp_segovr_DS,
12619 x86emuOp_illegal_op,
12620 x86emuOp_illegal_op,
12621 x86emuOp_segovr_FS,
12622 x86emuOp_segovr_GS,
12623 x86emuOp_prefix_data,
12624 x86emuOp_prefix_addr,
12626 x86emuOp_push_word_IMM,
12627 x86emuOp_imul_word_IMM,
12628 x86emuOp_push_byte_IMM,
12629 x86emuOp_imul_byte_IMM,
12632 x86emuOp_outs_byte,
12633 x86emuOp_outs_word,
12635 x86emuOp_jump_near_O,
12636 x86emuOp_jump_near_NO,
12637 x86emuOp_jump_near_B,
12638 x86emuOp_jump_near_NB,
12639 x86emuOp_jump_near_Z,
12640 x86emuOp_jump_near_NZ,
12641 x86emuOp_jump_near_BE,
12642 x86emuOp_jump_near_NBE,
12644 x86emuOp_jump_near_S,
12645 x86emuOp_jump_near_NS,
12646 x86emuOp_jump_near_P,
12647 x86emuOp_jump_near_NP,
12648 x86emuOp_jump_near_L,
12649 x86emuOp_jump_near_NL,
12650 x86emuOp_jump_near_LE,
12651 x86emuOp_jump_near_NLE,
12653 x86emuOp_opc80_byte_RM_IMM,
12654 x86emuOp_opc81_word_RM_IMM,
12655 x86emuOp_opc82_byte_RM_IMM,
12656 x86emuOp_opc83_word_RM_IMM,
12657 x86emuOp_test_byte_RM_R,
12658 x86emuOp_test_word_RM_R,
12659 x86emuOp_xchg_byte_RM_R,
12660 x86emuOp_xchg_word_RM_R,
12662 x86emuOp_mov_byte_RM_R,
12663 x86emuOp_mov_word_RM_R,
12664 x86emuOp_mov_byte_R_RM,
12665 x86emuOp_mov_word_R_RM,
12666 x86emuOp_mov_word_RM_SR,
12667 x86emuOp_lea_word_R_M,
12668 x86emuOp_mov_word_SR_RM,
12672 x86emuOp_xchg_word_AX_CX,
12673 x86emuOp_xchg_word_AX_DX,
12674 x86emuOp_xchg_word_AX_BX,
12675 x86emuOp_xchg_word_AX_SP,
12676 x86emuOp_xchg_word_AX_BP,
12677 x86emuOp_xchg_word_AX_SI,
12678 x86emuOp_xchg_word_AX_DI,
12682 x86emuOp_call_far_IMM,
12684 x86emuOp_pushf_word,
12685 x86emuOp_popf_word,
12689 x86emuOp_mov_AL_M_IMM,
12690 x86emuOp_mov_AX_M_IMM,
12691 x86emuOp_mov_M_AL_IMM,
12692 x86emuOp_mov_M_AX_IMM,
12693 x86emuOp_movs_byte,
12694 x86emuOp_movs_word,
12695 x86emuOp_cmps_byte,
12696 x86emuOp_cmps_word,
12697 x86emuOp_test_AL_IMM,
12698 x86emuOp_test_AX_IMM,
12699 x86emuOp_stos_byte,
12700 x86emuOp_stos_word,
12701 x86emuOp_lods_byte,
12702 x86emuOp_lods_word,
12703 x86emuOp_scas_byte,
12704 x86emuOp_scas_word,
12706 x86emuOp_mov_byte_AL_IMM,
12707 x86emuOp_mov_byte_CL_IMM,
12708 x86emuOp_mov_byte_DL_IMM,
12709 x86emuOp_mov_byte_BL_IMM,
12710 x86emuOp_mov_byte_AH_IMM,
12711 x86emuOp_mov_byte_CH_IMM,
12712 x86emuOp_mov_byte_DH_IMM,
12713 x86emuOp_mov_byte_BH_IMM,
12715 x86emuOp_mov_word_AX_IMM,
12716 x86emuOp_mov_word_CX_IMM,
12717 x86emuOp_mov_word_DX_IMM,
12718 x86emuOp_mov_word_BX_IMM,
12719 x86emuOp_mov_word_SP_IMM,
12720 x86emuOp_mov_word_BP_IMM,
12721 x86emuOp_mov_word_SI_IMM,
12722 x86emuOp_mov_word_DI_IMM,
12724 x86emuOp_opcC0_byte_RM_MEM,
12725 x86emuOp_opcC1_word_RM_MEM,
12726 x86emuOp_ret_near_IMM,
12728 x86emuOp_les_R_IMM,
12729 x86emuOp_lds_R_IMM,
12730 x86emuOp_mov_byte_RM_IMM,
12731 x86emuOp_mov_word_RM_IMM,
12734 x86emuOp_ret_far_IMM,
12741 x86emuOp_opcD0_byte_RM_1,
12742 x86emuOp_opcD1_word_RM_1,
12743 x86emuOp_opcD2_byte_RM_CL,
12744 x86emuOp_opcD3_word_RM_CL,
12747 x86emuOp_illegal_op,
12749 x86emuOp_esc_coprocess_d8,
12750 x86emuOp_esc_coprocess_d9,
12751 x86emuOp_esc_coprocess_da,
12752 x86emuOp_esc_coprocess_db,
12753 x86emuOp_esc_coprocess_dc,
12754 x86emuOp_esc_coprocess_dd,
12755 x86emuOp_esc_coprocess_de,
12756 x86emuOp_esc_coprocess_df,
12762 x86emuOp_in_byte_AL_IMM,
12763 x86emuOp_in_word_AX_IMM,
12764 x86emuOp_out_byte_IMM_AL,
12765 x86emuOp_out_word_IMM_AX,
12767 x86emuOp_call_near_IMM,
12768 x86emuOp_jump_near_IMM,
12769 x86emuOp_jump_far_IMM,
12770 x86emuOp_jump_byte_IMM,
12771 x86emuOp_in_byte_AL_DX,
12772 x86emuOp_in_word_AX_DX,
12773 x86emuOp_out_byte_DX_AL,
12774 x86emuOp_out_word_DX_AX,
12777 x86emuOp_illegal_op,
12782 x86emuOp_opcF6_byte_RM,
12783 x86emuOp_opcF7_word_RM,
12791 x86emuOp_opcFE_byte_RM,
12792 x86emuOp_opcFF_word_RM,