Lines Matching +full:0 +full:x86

6  *  Realmode X86 Emulator Library
182 push_word(emu, (uint16_t) emu->x86.R_FLG); in x86emu_intr_dispatch()
185 push_word(emu, emu->x86.R_CS); in x86emu_intr_dispatch()
186 emu->x86.R_CS = fetch_word(emu, 0, intno * 4 + 2); in x86emu_intr_dispatch()
187 push_word(emu, emu->x86.R_IP); in x86emu_intr_dispatch()
188 emu->x86.R_IP = fetch_word(emu, 0, intno * 4); in x86emu_intr_dispatch()
197 if (emu->x86.intr & INTR_SYNCH) { in x86emu_intr_handle()
198 intno = emu->x86.intno; in x86emu_intr_handle()
199 emu->x86.intr = 0; in x86emu_intr_handle()
215 emu->x86.intno = intrnum; in x86emu_intr_raise()
216 emu->x86.intr |= INTR_SYNCH; in x86emu_intr_raise()
228 emu->x86.intr = 0; in x86emu_exec()
234 if (emu->x86.intr) { in x86emu_exec()
235 if (((emu->x86.intr & INTR_SYNCH) && in x86emu_exec()
236 (emu->x86.intno == 0 || emu->x86.intno == 2)) || in x86emu_exec()
241 if (emu->x86.R_CS == 0 && emu->x86.R_IP == 0) in x86emu_exec()
251 push_word(emu, 0); in x86emu_exec_call()
252 push_word(emu, 0); in x86emu_exec_call()
253 emu->x86.R_CS = seg; in x86emu_exec_call()
254 emu->x86.R_IP = off; in x86emu_exec_call()
262 push_word(emu, emu->x86.R_FLG); in x86emu_exec_intr()
265 push_word(emu, 0); in x86emu_exec_intr()
266 push_word(emu, 0); in x86emu_exec_intr()
267 emu->x86.R_CS = (*emu->emu_rdw)(emu, intr * 4 + 2); in x86emu_exec_intr()
268 emu->x86.R_IP = (*emu->emu_rdw)(emu, intr * 4); in x86emu_exec_intr()
269 emu->x86.intr = 0; in x86emu_exec_intr()
302 emu->cur_mod = (fetched >> 6) & 0x03; in fetch_decode_modrm()
303 emu->cur_rh = (fetched >> 3) & 0x07; in fetch_decode_modrm()
304 emu->cur_rl = (fetched >> 0) & 0x07; in fetch_decode_modrm()
322 fetched = fetch_byte(emu, emu->x86.R_CS, emu->x86.R_IP); in fetch_byte_imm()
323 emu->x86.R_IP++; in fetch_byte_imm()
342 fetched = fetch_word(emu, emu->x86.R_CS, emu->x86.R_IP); in fetch_word_imm()
343 emu->x86.R_IP += 2; in fetch_word_imm()
362 fetched = fetch_long(emu, emu->x86.R_CS, emu->x86.R_IP); in fetch_long_imm()
363 emu->x86.R_IP += 4; in fetch_long_imm()
375 * On the x86 processor, the default segment is not always DS if there is
380 * cpu-state-varible emu->x86.mode. There are several potential states:
399 switch (emu->x86.mode & SYSMODE_SEGMASK) { in get_data_segment()
400 case 0: /* default case: use ds register */ in get_data_segment()
403 return emu->x86.R_DS; in get_data_segment()
405 return emu->x86.R_SS; in get_data_segment()
408 return emu->x86.R_CS; in get_data_segment()
411 return emu->x86.R_ES; in get_data_segment()
414 return emu->x86.R_FS; in get_data_segment()
417 return emu->x86.R_GS; in get_data_segment()
420 return emu->x86.R_SS; in get_data_segment()
635 case 0: in decode_rm_byte_register()
636 return &emu->x86.R_AL; in decode_rm_byte_register()
638 return &emu->x86.R_CL; in decode_rm_byte_register()
640 return &emu->x86.R_DL; in decode_rm_byte_register()
642 return &emu->x86.R_BL; in decode_rm_byte_register()
644 return &emu->x86.R_AH; in decode_rm_byte_register()
646 return &emu->x86.R_CH; in decode_rm_byte_register()
648 return &emu->x86.R_DH; in decode_rm_byte_register()
650 return &emu->x86.R_BH; in decode_rm_byte_register()
683 case 0: in decode_rm_word_register()
684 return &emu->x86.R_AX; in decode_rm_word_register()
686 return &emu->x86.R_CX; in decode_rm_word_register()
688 return &emu->x86.R_DX; in decode_rm_word_register()
690 return &emu->x86.R_BX; in decode_rm_word_register()
692 return &emu->x86.R_SP; in decode_rm_word_register()
694 return &emu->x86.R_BP; in decode_rm_word_register()
696 return &emu->x86.R_SI; in decode_rm_word_register()
698 return &emu->x86.R_DI; in decode_rm_word_register()
731 case 0: in decode_rm_long_register()
732 return &emu->x86.R_EAX; in decode_rm_long_register()
734 return &emu->x86.R_ECX; in decode_rm_long_register()
736 return &emu->x86.R_EDX; in decode_rm_long_register()
738 return &emu->x86.R_EBX; in decode_rm_long_register()
740 return &emu->x86.R_ESP; in decode_rm_long_register()
742 return &emu->x86.R_EBP; in decode_rm_long_register()
744 return &emu->x86.R_ESI; in decode_rm_long_register()
746 return &emu->x86.R_EDI; in decode_rm_long_register()
781 case 0: in decode_rh_seg_register()
782 return &emu->x86.R_ES; in decode_rh_seg_register()
784 return &emu->x86.R_CS; in decode_rh_seg_register()
786 return &emu->x86.R_SS; in decode_rh_seg_register()
788 return &emu->x86.R_DS; in decode_rh_seg_register()
790 return &emu->x86.R_FS; in decode_rh_seg_register()
792 return &emu->x86.R_GS; in decode_rh_seg_register()
804 uint32_t base = 0, i = 0, scale = 1; in decode_sib_address()
806 switch (sib & 0x07) { in decode_sib_address()
807 case 0: in decode_sib_address()
808 base = emu->x86.R_EAX; in decode_sib_address()
811 base = emu->x86.R_ECX; in decode_sib_address()
815 base = emu->x86.R_EDX; in decode_sib_address()
818 base = emu->x86.R_EBX; in decode_sib_address()
821 base = emu->x86.R_ESP; in decode_sib_address()
822 emu->x86.mode |= SYSMODE_SEG_DS_SS; in decode_sib_address()
825 if (mod == 0) { in decode_sib_address()
828 base = emu->x86.R_EBP; in decode_sib_address()
829 emu->x86.mode |= SYSMODE_SEG_DS_SS; in decode_sib_address()
833 base = emu->x86.R_ESI; in decode_sib_address()
836 base = emu->x86.R_EDI; in decode_sib_address()
839 switch ((sib >> 3) & 0x07) { in decode_sib_address()
840 case 0: in decode_sib_address()
841 i = emu->x86.R_EAX; in decode_sib_address()
844 i = emu->x86.R_ECX; in decode_sib_address()
847 i = emu->x86.R_EDX; in decode_sib_address()
850 i = emu->x86.R_EBX; in decode_sib_address()
853 i = 0; in decode_sib_address()
856 i = emu->x86.R_EBP; in decode_sib_address()
859 i = emu->x86.R_ESI; in decode_sib_address()
862 i = emu->x86.R_EDI; in decode_sib_address()
865 scale = 1 << ((sib >> 6) & 0x03); in decode_sib_address()
883 if (emu->x86.mode & SYSMODE_PREFIX_ADDR) { in decode_rl_address()
887 case 0: in decode_rl_address()
888 offset = emu->x86.R_EAX; in decode_rl_address()
891 offset = emu->x86.R_ECX; in decode_rl_address()
894 offset = emu->x86.R_EDX; in decode_rl_address()
897 offset = emu->x86.R_EBX; in decode_rl_address()
901 offset = decode_sib_address(emu, sib, 0); in decode_rl_address()
904 if (emu->cur_mod == 0) { in decode_rl_address()
907 emu->x86.mode |= SYSMODE_SEG_DS_SS; in decode_rl_address()
908 offset = emu->x86.R_EBP; in decode_rl_address()
912 offset = emu->x86.R_ESI; in decode_rl_address()
915 offset = emu->x86.R_EDI; in decode_rl_address()
930 case 0: in decode_rl_address()
931 offset = emu->x86.R_BX + emu->x86.R_SI; in decode_rl_address()
934 offset = emu->x86.R_BX + emu->x86.R_DI; in decode_rl_address()
937 emu->x86.mode |= SYSMODE_SEG_DS_SS; in decode_rl_address()
938 offset = emu->x86.R_BP + emu->x86.R_SI; in decode_rl_address()
941 emu->x86.mode |= SYSMODE_SEG_DS_SS; in decode_rl_address()
942 offset = emu->x86.R_BP + emu->x86.R_DI; in decode_rl_address()
945 offset = emu->x86.R_SI; in decode_rl_address()
948 offset = emu->x86.R_DI; in decode_rl_address()
951 if (emu->cur_mod == 0) { in decode_rl_address()
954 emu->x86.mode |= SYSMODE_SEG_DS_SS; in decode_rl_address()
955 offset = emu->x86.R_BP; in decode_rl_address()
959 offset = emu->x86.R_BX; in decode_rl_address()
989 if ((emu->x86.mode & SYSMODE_PREFIX_ADDR) == 0) in decode_and_fetch_word_disp()
990 emu->cur_offset &= 0xffff; in decode_and_fetch_word_disp()
1003 if ((emu->x86.mode & SYSMODE_PREFIX_ADDR) == 0) in decode_and_fetch_long_disp()
1004 emu->cur_offset &= 0xffff; in decode_and_fetch_long_disp()
1014 return decode_and_fetch_word_disp(emu, 0); in decode_and_fetch_word()
1020 return decode_and_fetch_long_disp(emu, 0); in decode_and_fetch_long()
1092 if (emu->x86.mode & SYSMODE_PREFIX_DATA) in common_inc_word_long()
1101 if (emu->x86.mode & SYSMODE_PREFIX_DATA) in common_dec_word_long()
1209 if (emu->x86.mode & SYSMODE_PREFIX_DATA) in common_binop_word_long_rm_r()
1257 if (emu->x86.mode & SYSMODE_PREFIX_DATA) in common_binop_ns_word_long_rm_r()
1304 if (emu->x86.mode & SYSMODE_PREFIX_DATA) in common_binop_word_long_r_rm()
1317 emu->x86.R_AL = (*binop)(emu, emu->x86.R_AL, srcval); in common_binop_byte_imm()
1325 if (emu->x86.mode & SYSMODE_PREFIX_DATA) { in common_binop_word_long_imm()
1329 emu->x86.R_EAX = (*binop32)(emu, emu->x86.R_EAX, srcval); in common_binop_word_long_imm()
1334 emu->x86.R_AX = (*binop16)(emu, emu->x86.R_AX, srcval); in common_binop_word_long_imm()
1341 if (emu->x86.mode & SYSMODE_PREFIX_DATA) in common_push_word_long()
1350 if (emu->x86.mode & SYSMODE_PREFIX_DATA) in common_pop_word_long()
1379 if (res > 0xffffffff) { in common_imul_long_IMM()
1412 if (res > 0xffff) { in common_imul_word_IMM()
1425 if (emu->x86.mode & SYSMODE_PREFIX_DATA) in common_imul_imm()
1438 target = (uint16_t) (emu->x86.R_IP + (int16_t) offset); in common_jmp_near()
1440 emu->x86.R_IP = target; in common_jmp_near()
1463 * Handles opcode 0x3a
1479 * Handles opcode 0x3b
1506 if (emu->x86.mode & SYSMODE_PREFIX_DATA) in x86emuOp_cmp_word_R_RM()
1514 * Handles opcode 0x3c
1522 cmp_byte(emu, emu->x86.R_AL, srcval); in x86emuOp_cmp_byte_AL_IMM()
1527 * Handles opcode 0x3d
1535 cmp_long(emu, emu->x86.R_EAX, srcval); in x86emuOp32_cmp_word_AX_IMM()
1544 cmp_word(emu, emu->x86.R_AX, srcval); in x86emuOp16_cmp_word_AX_IMM()
1550 if (emu->x86.mode & SYSMODE_PREFIX_DATA) in x86emuOp_cmp_word_AX_IMM()
1558 * Handles opcode 0x60
1563 if (emu->x86.mode & SYSMODE_PREFIX_DATA) { in x86emuOp_push_all()
1564 uint32_t old_sp = emu->x86.R_ESP; in x86emuOp_push_all()
1566 push_long(emu, emu->x86.R_EAX); in x86emuOp_push_all()
1567 push_long(emu, emu->x86.R_ECX); in x86emuOp_push_all()
1568 push_long(emu, emu->x86.R_EDX); in x86emuOp_push_all()
1569 push_long(emu, emu->x86.R_EBX); in x86emuOp_push_all()
1571 push_long(emu, emu->x86.R_EBP); in x86emuOp_push_all()
1572 push_long(emu, emu->x86.R_ESI); in x86emuOp_push_all()
1573 push_long(emu, emu->x86.R_EDI); in x86emuOp_push_all()
1575 uint16_t old_sp = emu->x86.R_SP; in x86emuOp_push_all()
1577 push_word(emu, emu->x86.R_AX); in x86emuOp_push_all()
1578 push_word(emu, emu->x86.R_CX); in x86emuOp_push_all()
1579 push_word(emu, emu->x86.R_DX); in x86emuOp_push_all()
1580 push_word(emu, emu->x86.R_BX); in x86emuOp_push_all()
1582 push_word(emu, emu->x86.R_BP); in x86emuOp_push_all()
1583 push_word(emu, emu->x86.R_SI); in x86emuOp_push_all()
1584 push_word(emu, emu->x86.R_DI); in x86emuOp_push_all()
1590 * Handles opcode 0x61
1595 if (emu->x86.mode & SYSMODE_PREFIX_DATA) { in x86emuOp_pop_all()
1596 emu->x86.R_EDI = pop_long(emu); in x86emuOp_pop_all()
1597 emu->x86.R_ESI = pop_long(emu); in x86emuOp_pop_all()
1598 emu->x86.R_EBP = pop_long(emu); in x86emuOp_pop_all()
1599 emu->x86.R_ESP += 4; /* skip ESP */ in x86emuOp_pop_all()
1600 emu->x86.R_EBX = pop_long(emu); in x86emuOp_pop_all()
1601 emu->x86.R_EDX = pop_long(emu); in x86emuOp_pop_all()
1602 emu->x86.R_ECX = pop_long(emu); in x86emuOp_pop_all()
1603 emu->x86.R_EAX = pop_long(emu); in x86emuOp_pop_all()
1605 emu->x86.R_DI = pop_word(emu); in x86emuOp_pop_all()
1606 emu->x86.R_SI = pop_word(emu); in x86emuOp_pop_all()
1607 emu->x86.R_BP = pop_word(emu); in x86emuOp_pop_all()
1608 emu->x86.R_SP += 2;/* skip SP */ in x86emuOp_pop_all()
1609 emu->x86.R_BX = pop_word(emu); in x86emuOp_pop_all()
1610 emu->x86.R_DX = pop_word(emu); in x86emuOp_pop_all()
1611 emu->x86.R_CX = pop_word(emu); in x86emuOp_pop_all()
1612 emu->x86.R_AX = pop_word(emu); in x86emuOp_pop_all()
1615 /*opcode 0x62 ILLEGAL OP, calls x86emuOp_illegal_op() */
1616 /*opcode 0x63 ILLEGAL OP, calls x86emuOp_illegal_op() */
1621 * Handles opcode 0x68
1626 if (emu->x86.mode & SYSMODE_PREFIX_DATA) { in x86emuOp_push_word_IMM()
1641 * Handles opcode 0x6a
1649 if (emu->x86.mode & SYSMODE_PREFIX_DATA) { in x86emuOp_push_byte_IMM()
1658 * Handles opcode 0x6c and 0x6d
1663 if (emu->x86.mode & SYSMODE_PREFIX_DATA) { in x86emuOp_ins_word()
1672 * Handles opcode 0x6f
1677 if (emu->x86.mode & SYSMODE_PREFIX_DATA) { in x86emuOp_outs_word()
1686 * Handles opcode 0x7c
1693 sf = ACCESS_FLAG(F_SF) != 0; in x86emuOp_jump_near_L()
1694 of = ACCESS_FLAG(F_OF) != 0; in x86emuOp_jump_near_L()
1701 * Handles opcode 0x7d
1708 sf = ACCESS_FLAG(F_SF) != 0; in x86emuOp_jump_near_NL()
1709 of = ACCESS_FLAG(F_OF) != 0; in x86emuOp_jump_near_NL()
1716 * Handles opcode 0x7e
1723 sf = ACCESS_FLAG(F_SF) != 0; in x86emuOp_jump_near_LE()
1724 of = ACCESS_FLAG(F_OF) != 0; in x86emuOp_jump_near_LE()
1731 * Handles opcode 0x7f
1738 sf = ACCESS_FLAG(F_SF) != 0; in x86emuOp_jump_near_NLE()
1739 of = ACCESS_FLAG(F_OF) != 0; in x86emuOp_jump_near_NLE()
1759 * Handles opcode 0x80
1809 * Handles opcode 0x81
1850 if (emu->x86.mode & SYSMODE_PREFIX_DATA) in x86emuOp_opc81_word_RM_IMM()
1872 * Handles opcode 0x82
1923 * Handles opcode 0x83
1954 if (emu->x86.mode & SYSMODE_PREFIX_DATA) in x86emuOp_opc83_word_RM_IMM()
1962 * Handles opcode 0x86
1980 * Handles opcode 0x87
2013 if (emu->x86.mode & SYSMODE_PREFIX_DATA) in x86emuOp_xchg_word_RM_R()
2021 * Handles opcode 0x88
2042 * Handles opcode 0x89
2081 if (emu->x86.mode & SYSMODE_PREFIX_DATA) in x86emuOp_mov_word_RM_R()
2089 * Handles opcode 0x8a
2103 * Handles opcode 0x8b
2108 if (emu->x86.mode & SYSMODE_PREFIX_DATA) { in x86emuOp_mov_word_R_RM()
2125 * Handles opcode 0x8c
2146 * Handles opcode 0x8d
2158 if (emu->x86.mode & SYSMODE_PREFIX_ADDR) { in x86emuOp_lea_word_R_M()
2173 * Handles opcode 0x8e
2193 * Handles opcode 0x8f
2232 if (emu->x86.mode & SYSMODE_PREFIX_DATA) in x86emuOp_pop_RM()
2240 * Handles opcode 0x91
2247 if (emu->x86.mode & SYSMODE_PREFIX_DATA) { in x86emuOp_xchg_word_AX_CX()
2248 tmp = emu->x86.R_EAX; in x86emuOp_xchg_word_AX_CX()
2249 emu->x86.R_EAX = emu->x86.R_ECX; in x86emuOp_xchg_word_AX_CX()
2250 emu->x86.R_ECX = tmp; in x86emuOp_xchg_word_AX_CX()
2252 tmp = emu->x86.R_AX; in x86emuOp_xchg_word_AX_CX()
2253 emu->x86.R_AX = emu->x86.R_CX; in x86emuOp_xchg_word_AX_CX()
2254 emu->x86.R_CX = (uint16_t) tmp; in x86emuOp_xchg_word_AX_CX()
2260 * Handles opcode 0x92
2267 if (emu->x86.mode & SYSMODE_PREFIX_DATA) { in x86emuOp_xchg_word_AX_DX()
2268 tmp = emu->x86.R_EAX; in x86emuOp_xchg_word_AX_DX()
2269 emu->x86.R_EAX = emu->x86.R_EDX; in x86emuOp_xchg_word_AX_DX()
2270 emu->x86.R_EDX = tmp; in x86emuOp_xchg_word_AX_DX()
2272 tmp = emu->x86.R_AX; in x86emuOp_xchg_word_AX_DX()
2273 emu->x86.R_AX = emu->x86.R_DX; in x86emuOp_xchg_word_AX_DX()
2274 emu->x86.R_DX = (uint16_t) tmp; in x86emuOp_xchg_word_AX_DX()
2280 * Handles opcode 0x93
2287 if (emu->x86.mode & SYSMODE_PREFIX_DATA) { in x86emuOp_xchg_word_AX_BX()
2288 tmp = emu->x86.R_EAX; in x86emuOp_xchg_word_AX_BX()
2289 emu->x86.R_EAX = emu->x86.R_EBX; in x86emuOp_xchg_word_AX_BX()
2290 emu->x86.R_EBX = tmp; in x86emuOp_xchg_word_AX_BX()
2292 tmp = emu->x86.R_AX; in x86emuOp_xchg_word_AX_BX()
2293 emu->x86.R_AX = emu->x86.R_BX; in x86emuOp_xchg_word_AX_BX()
2294 emu->x86.R_BX = (uint16_t) tmp; in x86emuOp_xchg_word_AX_BX()
2300 * Handles opcode 0x94
2307 if (emu->x86.mode & SYSMODE_PREFIX_DATA) { in x86emuOp_xchg_word_AX_SP()
2308 tmp = emu->x86.R_EAX; in x86emuOp_xchg_word_AX_SP()
2309 emu->x86.R_EAX = emu->x86.R_ESP; in x86emuOp_xchg_word_AX_SP()
2310 emu->x86.R_ESP = tmp; in x86emuOp_xchg_word_AX_SP()
2312 tmp = emu->x86.R_AX; in x86emuOp_xchg_word_AX_SP()
2313 emu->x86.R_AX = emu->x86.R_SP; in x86emuOp_xchg_word_AX_SP()
2314 emu->x86.R_SP = (uint16_t) tmp; in x86emuOp_xchg_word_AX_SP()
2320 * Handles opcode 0x95
2327 if (emu->x86.mode & SYSMODE_PREFIX_DATA) { in x86emuOp_xchg_word_AX_BP()
2328 tmp = emu->x86.R_EAX; in x86emuOp_xchg_word_AX_BP()
2329 emu->x86.R_EAX = emu->x86.R_EBP; in x86emuOp_xchg_word_AX_BP()
2330 emu->x86.R_EBP = tmp; in x86emuOp_xchg_word_AX_BP()
2332 tmp = emu->x86.R_AX; in x86emuOp_xchg_word_AX_BP()
2333 emu->x86.R_AX = emu->x86.R_BP; in x86emuOp_xchg_word_AX_BP()
2334 emu->x86.R_BP = (uint16_t) tmp; in x86emuOp_xchg_word_AX_BP()
2340 * Handles opcode 0x96
2347 if (emu->x86.mode & SYSMODE_PREFIX_DATA) { in x86emuOp_xchg_word_AX_SI()
2348 tmp = emu->x86.R_EAX; in x86emuOp_xchg_word_AX_SI()
2349 emu->x86.R_EAX = emu->x86.R_ESI; in x86emuOp_xchg_word_AX_SI()
2350 emu->x86.R_ESI = tmp; in x86emuOp_xchg_word_AX_SI()
2352 tmp = emu->x86.R_AX; in x86emuOp_xchg_word_AX_SI()
2353 emu->x86.R_AX = emu->x86.R_SI; in x86emuOp_xchg_word_AX_SI()
2354 emu->x86.R_SI = (uint16_t) tmp; in x86emuOp_xchg_word_AX_SI()
2360 * Handles opcode 0x97
2367 if (emu->x86.mode & SYSMODE_PREFIX_DATA) { in x86emuOp_xchg_word_AX_DI()
2368 tmp = emu->x86.R_EAX; in x86emuOp_xchg_word_AX_DI()
2369 emu->x86.R_EAX = emu->x86.R_EDI; in x86emuOp_xchg_word_AX_DI()
2370 emu->x86.R_EDI = tmp; in x86emuOp_xchg_word_AX_DI()
2372 tmp = emu->x86.R_AX; in x86emuOp_xchg_word_AX_DI()
2373 emu->x86.R_AX = emu->x86.R_DI; in x86emuOp_xchg_word_AX_DI()
2374 emu->x86.R_DI = (uint16_t) tmp; in x86emuOp_xchg_word_AX_DI()
2380 * Handles opcode 0x98
2385 if (emu->x86.mode & SYSMODE_PREFIX_DATA) { in x86emuOp_cbw()
2386 if (emu->x86.R_AX & 0x8000) { in x86emuOp_cbw()
2387 emu->x86.R_EAX |= 0xffff0000; in x86emuOp_cbw()
2389 emu->x86.R_EAX &= 0x0000ffff; in x86emuOp_cbw()
2392 if (emu->x86.R_AL & 0x80) { in x86emuOp_cbw()
2393 emu->x86.R_AH = 0xff; in x86emuOp_cbw()
2395 emu->x86.R_AH = 0x0; in x86emuOp_cbw()
2402 * Handles opcode 0x99
2407 if (emu->x86.mode & SYSMODE_PREFIX_DATA) { in x86emuOp_cwd()
2408 if (emu->x86.R_EAX & 0x80000000) { in x86emuOp_cwd()
2409 emu->x86.R_EDX = 0xffffffff; in x86emuOp_cwd()
2411 emu->x86.R_EDX = 0x0; in x86emuOp_cwd()
2414 if (emu->x86.R_AX & 0x8000) { in x86emuOp_cwd()
2415 emu->x86.R_DX = 0xffff; in x86emuOp_cwd()
2417 emu->x86.R_DX = 0x0; in x86emuOp_cwd()
2424 * Handles opcode 0x9a
2438 push_word(emu, emu->x86.R_CS); in x86emuOp_call_far_IMM()
2439 emu->x86.R_CS = farseg; in x86emuOp_call_far_IMM()
2440 push_word(emu, emu->x86.R_IP); in x86emuOp_call_far_IMM()
2441 emu->x86.R_IP = faroff; in x86emuOp_call_far_IMM()
2446 * Handles opcode 0x9c
2454 flags = (emu->x86.R_EFLG & F_MSK) | F_ALWAYS_ON; in x86emuOp_pushf_word()
2455 if (emu->x86.mode & SYSMODE_PREFIX_DATA) { in x86emuOp_pushf_word()
2464 * Handles opcode 0x9d
2469 if (emu->x86.mode & SYSMODE_PREFIX_DATA) { in x86emuOp_popf_word()
2470 emu->x86.R_EFLG = pop_long(emu); in x86emuOp_popf_word()
2472 emu->x86.R_FLG = pop_word(emu); in x86emuOp_popf_word()
2478 * Handles opcode 0x9e
2484 emu->x86.R_FLG &= 0xffffff00; in x86emuOp_sahf()
2486 emu->x86.R_FLG |= emu->x86.R_AH; in x86emuOp_sahf()
2491 * Handles opcode 0x9f
2496 emu->x86.R_AH = (uint8_t) (emu->x86.R_FLG & 0xff); in x86emuOp_lahf()
2499 emu->x86.R_AH |= 0x2; in x86emuOp_lahf()
2504 * Handles opcode 0xa0
2512 emu->x86.R_AL = fetch_data_byte(emu, offset); in x86emuOp_mov_AL_M_IMM()
2517 * Handles opcode 0xa1
2525 if (emu->x86.mode & SYSMODE_PREFIX_DATA) { in x86emuOp_mov_AX_M_IMM()
2526 emu->x86.R_EAX = fetch_data_long(emu, offset); in x86emuOp_mov_AX_M_IMM()
2528 emu->x86.R_AX = fetch_data_word(emu, offset); in x86emuOp_mov_AX_M_IMM()
2534 * Handles opcode 0xa2
2542 store_data_byte(emu, offset, emu->x86.R_AL); in x86emuOp_mov_M_AL_IMM()
2547 * Handles opcode 0xa3
2555 if (emu->x86.mode & SYSMODE_PREFIX_DATA) { in x86emuOp_mov_M_AX_IMM()
2556 store_data_long(emu, offset, emu->x86.R_EAX); in x86emuOp_mov_M_AX_IMM()
2558 store_data_word(emu, offset, emu->x86.R_AX); in x86emuOp_mov_M_AX_IMM()
2564 * Handles opcode 0xa4
2578 if (emu->x86.mode & (SYSMODE_PREFIX_REPE | SYSMODE_PREFIX_REPNE)) { in x86emuOp_movs_byte()
2581 count = emu->x86.R_CX; in x86emuOp_movs_byte()
2582 emu->x86.R_CX = 0; in x86emuOp_movs_byte()
2583 emu->x86.mode &= ~(SYSMODE_PREFIX_REPE | SYSMODE_PREFIX_REPNE); in x86emuOp_movs_byte()
2586 val = fetch_data_byte(emu, emu->x86.R_SI); in x86emuOp_movs_byte()
2587 store_byte(emu, emu->x86.R_ES, emu->x86.R_DI, val); in x86emuOp_movs_byte()
2588 emu->x86.R_SI += inc; in x86emuOp_movs_byte()
2589 emu->x86.R_DI += inc; in x86emuOp_movs_byte()
2595 * Handles opcode 0xa5
2604 if (emu->x86.mode & SYSMODE_PREFIX_DATA) in x86emuOp_movs_word()
2613 if (emu->x86.mode & (SYSMODE_PREFIX_REPE | SYSMODE_PREFIX_REPNE)) { in x86emuOp_movs_word()
2616 count = emu->x86.R_CX; in x86emuOp_movs_word()
2617 emu->x86.R_CX = 0; in x86emuOp_movs_word()
2618 emu->x86.mode &= ~(SYSMODE_PREFIX_REPE | SYSMODE_PREFIX_REPNE); in x86emuOp_movs_word()
2621 if (emu->x86.mode & SYSMODE_PREFIX_DATA) { in x86emuOp_movs_word()
2622 val = fetch_data_long(emu, emu->x86.R_SI); in x86emuOp_movs_word()
2623 store_long(emu, emu->x86.R_ES, emu->x86.R_DI, val); in x86emuOp_movs_word()
2625 val = fetch_data_word(emu, emu->x86.R_SI); in x86emuOp_movs_word()
2626 store_word(emu, emu->x86.R_ES, emu->x86.R_DI, in x86emuOp_movs_word()
2629 emu->x86.R_SI += inc; in x86emuOp_movs_word()
2630 emu->x86.R_DI += inc; in x86emuOp_movs_word()
2636 * Handles opcode 0xa6
2649 if (emu->x86.mode & SYSMODE_PREFIX_REPE) { in x86emuOp_cmps_byte()
2652 while (emu->x86.R_CX != 0) { in x86emuOp_cmps_byte()
2653 val1 = fetch_data_byte(emu, emu->x86.R_SI); in x86emuOp_cmps_byte()
2654 val2 = fetch_byte(emu, emu->x86.R_ES, emu->x86.R_DI); in x86emuOp_cmps_byte()
2656 emu->x86.R_CX -= 1; in x86emuOp_cmps_byte()
2657 emu->x86.R_SI += inc; in x86emuOp_cmps_byte()
2658 emu->x86.R_DI += inc; in x86emuOp_cmps_byte()
2659 if (ACCESS_FLAG(F_ZF) == 0) in x86emuOp_cmps_byte()
2662 emu->x86.mode &= ~SYSMODE_PREFIX_REPE; in x86emuOp_cmps_byte()
2663 } else if (emu->x86.mode & SYSMODE_PREFIX_REPNE) { in x86emuOp_cmps_byte()
2666 while (emu->x86.R_CX != 0) { in x86emuOp_cmps_byte()
2667 val1 = fetch_data_byte(emu, emu->x86.R_SI); in x86emuOp_cmps_byte()
2668 val2 = fetch_byte(emu, emu->x86.R_ES, emu->x86.R_DI); in x86emuOp_cmps_byte()
2670 emu->x86.R_CX -= 1; in x86emuOp_cmps_byte()
2671 emu->x86.R_SI += inc; in x86emuOp_cmps_byte()
2672 emu->x86.R_DI += inc; in x86emuOp_cmps_byte()
2676 emu->x86.mode &= ~SYSMODE_PREFIX_REPNE; in x86emuOp_cmps_byte()
2678 val1 = fetch_data_byte(emu, emu->x86.R_SI); in x86emuOp_cmps_byte()
2679 val2 = fetch_byte(emu, emu->x86.R_ES, emu->x86.R_DI); in x86emuOp_cmps_byte()
2681 emu->x86.R_SI += inc; in x86emuOp_cmps_byte()
2682 emu->x86.R_DI += inc; in x86emuOp_cmps_byte()
2688 * Handles opcode 0xa7
2696 if (emu->x86.mode & SYSMODE_PREFIX_DATA) { in x86emuOp_cmps_word()
2707 if (emu->x86.mode & SYSMODE_PREFIX_REPE) { in x86emuOp_cmps_word()
2710 while (emu->x86.R_CX != 0) { in x86emuOp_cmps_word()
2711 if (emu->x86.mode & SYSMODE_PREFIX_DATA) { in x86emuOp_cmps_word()
2712 val1 = fetch_data_long(emu, emu->x86.R_SI); in x86emuOp_cmps_word()
2713 val2 = fetch_long(emu, emu->x86.R_ES, in x86emuOp_cmps_word()
2714 emu->x86.R_DI); in x86emuOp_cmps_word()
2717 val1 = fetch_data_word(emu, emu->x86.R_SI); in x86emuOp_cmps_word()
2718 val2 = fetch_word(emu, emu->x86.R_ES, in x86emuOp_cmps_word()
2719 emu->x86.R_DI); in x86emuOp_cmps_word()
2722 emu->x86.R_CX -= 1; in x86emuOp_cmps_word()
2723 emu->x86.R_SI += inc; in x86emuOp_cmps_word()
2724 emu->x86.R_DI += inc; in x86emuOp_cmps_word()
2725 if (ACCESS_FLAG(F_ZF) == 0) in x86emuOp_cmps_word()
2728 emu->x86.mode &= ~SYSMODE_PREFIX_REPE; in x86emuOp_cmps_word()
2729 } else if (emu->x86.mode & SYSMODE_PREFIX_REPNE) { in x86emuOp_cmps_word()
2732 while (emu->x86.R_CX != 0) { in x86emuOp_cmps_word()
2733 if (emu->x86.mode & SYSMODE_PREFIX_DATA) { in x86emuOp_cmps_word()
2734 val1 = fetch_data_long(emu, emu->x86.R_SI); in x86emuOp_cmps_word()
2735 val2 = fetch_long(emu, emu->x86.R_ES, in x86emuOp_cmps_word()
2736 emu->x86.R_DI); in x86emuOp_cmps_word()
2739 val1 = fetch_data_word(emu, emu->x86.R_SI); in x86emuOp_cmps_word()
2740 val2 = fetch_word(emu, emu->x86.R_ES, in x86emuOp_cmps_word()
2741 emu->x86.R_DI); in x86emuOp_cmps_word()
2744 emu->x86.R_CX -= 1; in x86emuOp_cmps_word()
2745 emu->x86.R_SI += inc; in x86emuOp_cmps_word()
2746 emu->x86.R_DI += inc; in x86emuOp_cmps_word()
2750 emu->x86.mode &= ~SYSMODE_PREFIX_REPNE; in x86emuOp_cmps_word()
2752 if (emu->x86.mode & SYSMODE_PREFIX_DATA) { in x86emuOp_cmps_word()
2753 val1 = fetch_data_long(emu, emu->x86.R_SI); in x86emuOp_cmps_word()
2754 val2 = fetch_long(emu, emu->x86.R_ES, emu->x86.R_DI); in x86emuOp_cmps_word()
2757 val1 = fetch_data_word(emu, emu->x86.R_SI); in x86emuOp_cmps_word()
2758 val2 = fetch_word(emu, emu->x86.R_ES, emu->x86.R_DI); in x86emuOp_cmps_word()
2761 emu->x86.R_SI += inc; in x86emuOp_cmps_word()
2762 emu->x86.R_DI += inc; in x86emuOp_cmps_word()
2768 * Handles opcode 0xa9
2773 if (emu->x86.mode & SYSMODE_PREFIX_DATA) { in x86emuOp_test_AX_IMM()
2774 test_long(emu, emu->x86.R_EAX, fetch_long_imm(emu)); in x86emuOp_test_AX_IMM()
2776 test_word(emu, emu->x86.R_AX, fetch_word_imm(emu)); in x86emuOp_test_AX_IMM()
2782 * Handles opcode 0xaa
2793 if (emu->x86.mode & (SYSMODE_PREFIX_REPE | SYSMODE_PREFIX_REPNE)) { in x86emuOp_stos_byte()
2796 while (emu->x86.R_CX != 0) { in x86emuOp_stos_byte()
2797 store_byte(emu, emu->x86.R_ES, emu->x86.R_DI, in x86emuOp_stos_byte()
2798 emu->x86.R_AL); in x86emuOp_stos_byte()
2799 emu->x86.R_CX -= 1; in x86emuOp_stos_byte()
2800 emu->x86.R_DI += inc; in x86emuOp_stos_byte()
2802 emu->x86.mode &= ~(SYSMODE_PREFIX_REPE | SYSMODE_PREFIX_REPNE); in x86emuOp_stos_byte()
2804 store_byte(emu, emu->x86.R_ES, emu->x86.R_DI, emu->x86.R_AL); in x86emuOp_stos_byte()
2805 emu->x86.R_DI += inc; in x86emuOp_stos_byte()
2811 * Handles opcode 0xab
2819 if (emu->x86.mode & SYSMODE_PREFIX_DATA) in x86emuOp_stos_word()
2828 if (emu->x86.mode & (SYSMODE_PREFIX_REPE | SYSMODE_PREFIX_REPNE)) { in x86emuOp_stos_word()
2831 count = emu->x86.R_CX; in x86emuOp_stos_word()
2832 emu->x86.R_CX = 0; in x86emuOp_stos_word()
2833 emu->x86.mode &= ~(SYSMODE_PREFIX_REPE | SYSMODE_PREFIX_REPNE); in x86emuOp_stos_word()
2836 if (emu->x86.mode & SYSMODE_PREFIX_DATA) { in x86emuOp_stos_word()
2837 store_long(emu, emu->x86.R_ES, emu->x86.R_DI, in x86emuOp_stos_word()
2838 emu->x86.R_EAX); in x86emuOp_stos_word()
2840 store_word(emu, emu->x86.R_ES, emu->x86.R_DI, in x86emuOp_stos_word()
2841 emu->x86.R_AX); in x86emuOp_stos_word()
2843 emu->x86.R_DI += inc; in x86emuOp_stos_word()
2849 * Handles opcode 0xac
2860 if (emu->x86.mode & (SYSMODE_PREFIX_REPE | SYSMODE_PREFIX_REPNE)) { in x86emuOp_lods_byte()
2863 while (emu->x86.R_CX != 0) { in x86emuOp_lods_byte()
2864 emu->x86.R_AL = fetch_data_byte(emu, emu->x86.R_SI); in x86emuOp_lods_byte()
2865 emu->x86.R_CX -= 1; in x86emuOp_lods_byte()
2866 emu->x86.R_SI += inc; in x86emuOp_lods_byte()
2868 emu->x86.mode &= ~(SYSMODE_PREFIX_REPE | SYSMODE_PREFIX_REPNE); in x86emuOp_lods_byte()
2870 emu->x86.R_AL = fetch_data_byte(emu, emu->x86.R_SI); in x86emuOp_lods_byte()
2871 emu->x86.R_SI += inc; in x86emuOp_lods_byte()
2877 * Handles opcode 0xad
2885 if (emu->x86.mode & SYSMODE_PREFIX_DATA) in x86emuOp_lods_word()
2894 if (emu->x86.mode & (SYSMODE_PREFIX_REPE | SYSMODE_PREFIX_REPNE)) { in x86emuOp_lods_word()
2897 count = emu->x86.R_CX; in x86emuOp_lods_word()
2898 emu->x86.R_CX = 0; in x86emuOp_lods_word()
2899 emu->x86.mode &= ~(SYSMODE_PREFIX_REPE | SYSMODE_PREFIX_REPNE); in x86emuOp_lods_word()
2902 if (emu->x86.mode & SYSMODE_PREFIX_DATA) { in x86emuOp_lods_word()
2903 emu->x86.R_EAX = fetch_data_long(emu, emu->x86.R_SI); in x86emuOp_lods_word()
2905 emu->x86.R_AX = fetch_data_word(emu, emu->x86.R_SI); in x86emuOp_lods_word()
2907 emu->x86.R_SI += inc; in x86emuOp_lods_word()
2913 * Handles opcode 0xae
2925 if (emu->x86.mode & SYSMODE_PREFIX_REPE) { in x86emuOp_scas_byte()
2928 while (emu->x86.R_CX != 0) { in x86emuOp_scas_byte()
2929 val2 = fetch_byte(emu, emu->x86.R_ES, emu->x86.R_DI); in x86emuOp_scas_byte()
2930 cmp_byte(emu, emu->x86.R_AL, val2); in x86emuOp_scas_byte()
2931 emu->x86.R_CX -= 1; in x86emuOp_scas_byte()
2932 emu->x86.R_DI += inc; in x86emuOp_scas_byte()
2933 if (ACCESS_FLAG(F_ZF) == 0) in x86emuOp_scas_byte()
2936 emu->x86.mode &= ~SYSMODE_PREFIX_REPE; in x86emuOp_scas_byte()
2937 } else if (emu->x86.mode & SYSMODE_PREFIX_REPNE) { in x86emuOp_scas_byte()
2940 while (emu->x86.R_CX != 0) { in x86emuOp_scas_byte()
2941 val2 = fetch_byte(emu, emu->x86.R_ES, emu->x86.R_DI); in x86emuOp_scas_byte()
2942 cmp_byte(emu, emu->x86.R_AL, val2); in x86emuOp_scas_byte()
2943 emu->x86.R_CX -= 1; in x86emuOp_scas_byte()
2944 emu->x86.R_DI += inc; in x86emuOp_scas_byte()
2948 emu->x86.mode &= ~SYSMODE_PREFIX_REPNE; in x86emuOp_scas_byte()
2950 val2 = fetch_byte(emu, emu->x86.R_ES, emu->x86.R_DI); in x86emuOp_scas_byte()
2951 cmp_byte(emu, emu->x86.R_AL, val2); in x86emuOp_scas_byte()
2952 emu->x86.R_DI += inc; in x86emuOp_scas_byte()
2958 * Handles opcode 0xaf
2966 if (emu->x86.mode & SYSMODE_PREFIX_DATA) in x86emuOp_scas_word()
2974 if (emu->x86.mode & SYSMODE_PREFIX_REPE) { in x86emuOp_scas_word()
2977 while (emu->x86.R_CX != 0) { in x86emuOp_scas_word()
2978 if (emu->x86.mode & SYSMODE_PREFIX_DATA) { in x86emuOp_scas_word()
2979 val = fetch_long(emu, emu->x86.R_ES, in x86emuOp_scas_word()
2980 emu->x86.R_DI); in x86emuOp_scas_word()
2981 cmp_long(emu, emu->x86.R_EAX, val); in x86emuOp_scas_word()
2983 val = fetch_word(emu, emu->x86.R_ES, in x86emuOp_scas_word()
2984 emu->x86.R_DI); in x86emuOp_scas_word()
2985 cmp_word(emu, emu->x86.R_AX, (uint16_t) val); in x86emuOp_scas_word()
2987 emu->x86.R_CX -= 1; in x86emuOp_scas_word()
2988 emu->x86.R_DI += inc; in x86emuOp_scas_word()
2989 if (ACCESS_FLAG(F_ZF) == 0) in x86emuOp_scas_word()
2992 emu->x86.mode &= ~SYSMODE_PREFIX_REPE; in x86emuOp_scas_word()
2993 } else if (emu->x86.mode & SYSMODE_PREFIX_REPNE) { in x86emuOp_scas_word()
2996 while (emu->x86.R_CX != 0) { in x86emuOp_scas_word()
2997 if (emu->x86.mode & SYSMODE_PREFIX_DATA) { in x86emuOp_scas_word()
2998 val = fetch_long(emu, emu->x86.R_ES, in x86emuOp_scas_word()
2999 emu->x86.R_DI); in x86emuOp_scas_word()
3000 cmp_long(emu, emu->x86.R_EAX, val); in x86emuOp_scas_word()
3002 val = fetch_word(emu, emu->x86.R_ES, in x86emuOp_scas_word()
3003 emu->x86.R_DI); in x86emuOp_scas_word()
3004 cmp_word(emu, emu->x86.R_AX, (uint16_t) val); in x86emuOp_scas_word()
3006 emu->x86.R_CX -= 1; in x86emuOp_scas_word()
3007 emu->x86.R_DI += inc; in x86emuOp_scas_word()
3011 emu->x86.mode &= ~SYSMODE_PREFIX_REPNE; in x86emuOp_scas_word()
3013 if (emu->x86.mode & SYSMODE_PREFIX_DATA) { in x86emuOp_scas_word()
3014 val = fetch_long(emu, emu->x86.R_ES, emu->x86.R_DI); in x86emuOp_scas_word()
3015 cmp_long(emu, emu->x86.R_EAX, val); in x86emuOp_scas_word()
3017 val = fetch_word(emu, emu->x86.R_ES, emu->x86.R_DI); in x86emuOp_scas_word()
3018 cmp_word(emu, emu->x86.R_AX, (uint16_t) val); in x86emuOp_scas_word()
3020 emu->x86.R_DI += inc; in x86emuOp_scas_word()
3026 * Handles opcode 0xb8
3031 if (emu->x86.mode & SYSMODE_PREFIX_DATA) in x86emuOp_mov_word_AX_IMM()
3032 emu->x86.R_EAX = fetch_long_imm(emu); in x86emuOp_mov_word_AX_IMM()
3034 emu->x86.R_AX = fetch_word_imm(emu); in x86emuOp_mov_word_AX_IMM()
3039 * Handles opcode 0xb9
3044 if (emu->x86.mode & SYSMODE_PREFIX_DATA) in x86emuOp_mov_word_CX_IMM()
3045 emu->x86.R_ECX = fetch_long_imm(emu); in x86emuOp_mov_word_CX_IMM()
3047 emu->x86.R_CX = fetch_word_imm(emu); in x86emuOp_mov_word_CX_IMM()
3052 * Handles opcode 0xba
3057 if (emu->x86.mode & SYSMODE_PREFIX_DATA) in x86emuOp_mov_word_DX_IMM()
3058 emu->x86.R_EDX = fetch_long_imm(emu); in x86emuOp_mov_word_DX_IMM()
3060 emu->x86.R_DX = fetch_word_imm(emu); in x86emuOp_mov_word_DX_IMM()
3065 * Handles opcode 0xbb
3070 if (emu->x86.mode & SYSMODE_PREFIX_DATA) in x86emuOp_mov_word_BX_IMM()
3071 emu->x86.R_EBX = fetch_long_imm(emu); in x86emuOp_mov_word_BX_IMM()
3073 emu->x86.R_BX = fetch_word_imm(emu); in x86emuOp_mov_word_BX_IMM()
3078 * Handles opcode 0xbc
3083 if (emu->x86.mode & SYSMODE_PREFIX_DATA) in x86emuOp_mov_word_SP_IMM()
3084 emu->x86.R_ESP = fetch_long_imm(emu); in x86emuOp_mov_word_SP_IMM()
3086 emu->x86.R_SP = fetch_word_imm(emu); in x86emuOp_mov_word_SP_IMM()
3091 * Handles opcode 0xbd
3096 if (emu->x86.mode & SYSMODE_PREFIX_DATA) in x86emuOp_mov_word_BP_IMM()
3097 emu->x86.R_EBP = fetch_long_imm(emu); in x86emuOp_mov_word_BP_IMM()
3099 emu->x86.R_BP = fetch_word_imm(emu); in x86emuOp_mov_word_BP_IMM()
3104 * Handles opcode 0xbe
3109 if (emu->x86.mode & SYSMODE_PREFIX_DATA) in x86emuOp_mov_word_SI_IMM()
3110 emu->x86.R_ESI = fetch_long_imm(emu); in x86emuOp_mov_word_SI_IMM()
3112 emu->x86.R_SI = fetch_word_imm(emu); in x86emuOp_mov_word_SI_IMM()
3117 * Handles opcode 0xbf
3122 if (emu->x86.mode & SYSMODE_PREFIX_DATA) in x86emuOp_mov_word_DI_IMM()
3123 emu->x86.R_EDI = fetch_long_imm(emu); in x86emuOp_mov_word_DI_IMM()
3125 emu->x86.R_DI = fetch_word_imm(emu); in x86emuOp_mov_word_DI_IMM()
3144 * Handles opcode 0xc0
3193 * Handles opcode 0xc1
3206 if (emu->x86.mode & SYSMODE_PREFIX_DATA) { in x86emuOp_opcC1_word_RM_MEM()
3225 * Handles opcode 0xc2
3233 emu->x86.R_IP = pop_word(emu); in x86emuOp_ret_near_IMM()
3234 emu->x86.R_SP += imm; in x86emuOp_ret_near_IMM()
3239 * Handles opcode 0xc6
3249 if (emu->cur_rh != 0) in x86emuOp_mov_byte_RM_IMM()
3264 * Handles opcode 0xc7
3273 if (emu->cur_rh != 0) in x86emuOp32_mov_word_RM_IMM()
3294 if (emu->cur_rh != 0) in x86emuOp16_mov_word_RM_IMM()
3311 if (emu->x86.mode & SYSMODE_PREFIX_DATA) in x86emuOp_mov_word_RM_IMM()
3319 * Handles opcode 0xc8
3330 push_word(emu, emu->x86.R_BP); in x86emuOp_enter()
3331 frame_pointer = emu->x86.R_SP; in x86emuOp_enter()
3332 if (nesting > 0) { in x86emuOp_enter()
3334 emu->x86.R_BP -= 2; in x86emuOp_enter()
3335 push_word(emu, fetch_word(emu, emu->x86.R_SS, in x86emuOp_enter()
3336 emu->x86.R_BP)); in x86emuOp_enter()
3340 emu->x86.R_BP = frame_pointer; in x86emuOp_enter()
3341 emu->x86.R_SP = (uint16_t) (emu->x86.R_SP - local); in x86emuOp_enter()
3346 * Handles opcode 0xc9
3351 emu->x86.R_SP = emu->x86.R_BP; in x86emuOp_leave()
3352 emu->x86.R_BP = pop_word(emu); in x86emuOp_leave()
3357 * Handles opcode 0xca
3365 emu->x86.R_IP = pop_word(emu); in x86emuOp_ret_far_IMM()
3366 emu->x86.R_CS = pop_word(emu); in x86emuOp_ret_far_IMM()
3367 emu->x86.R_SP += imm; in x86emuOp_ret_far_IMM()
3372 * Handles opcode 0xcb
3377 emu->x86.R_IP = pop_word(emu); in x86emuOp_ret_far()
3378 emu->x86.R_CS = pop_word(emu); in x86emuOp_ret_far()
3383 * Handles opcode 0xcc
3393 * Handles opcode 0xcd
3406 * Handles opcode 0xce
3417 * Handles opcode 0xcf
3422 emu->x86.R_IP = pop_word(emu); in x86emuOp_iret()
3423 emu->x86.R_CS = pop_word(emu); in x86emuOp_iret()
3424 emu->x86.R_FLG = pop_word(emu); in x86emuOp_iret()
3429 * Handles opcode 0xd0
3444 * Handles opcode 0xd1
3449 if (emu->x86.mode & SYSMODE_PREFIX_DATA) { in x86emuOp_opcD1_word_RM_1()
3468 * Handles opcode 0xd2
3478 (emu, destval, emu->x86.R_CL); in x86emuOp_opcD2_byte_RM_CL()
3484 * Handles opcode 0xd3
3489 if (emu->x86.mode & SYSMODE_PREFIX_DATA) { in x86emuOp_opcD3_word_RM_CL()
3495 (emu, destval, emu->x86.R_CL); in x86emuOp_opcD3_word_RM_CL()
3503 (emu, destval, emu->x86.R_CL); in x86emuOp_opcD3_word_RM_CL()
3510 * Handles opcode 0xd4
3523 emu->x86.R_AX = aam_word(emu, emu->x86.R_AL); in x86emuOp_aam()
3528 * Handles opcode 0xd5
3540 emu->x86.R_AX = aad_word(emu, emu->x86.R_AX); in x86emuOp_aad()
3542 /* opcode 0xd6 ILLEGAL OPCODE */
3547 * Handles opcode 0xd7
3554 addr = (uint16_t) (emu->x86.R_BX + (uint8_t) emu->x86.R_AL); in x86emuOp_xlat()
3555 emu->x86.R_AL = fetch_data_byte(emu, addr); in x86emuOp_xlat()
3558 /* opcode=0xd8 */
3563 /* opcode=0xd9 */
3571 /* opcode=0xda */
3579 /* opcode=0xdb */
3587 /* opcode=0xdc */
3595 /* opcode=0xdd */
3603 /* opcode=0xde */
3611 /* opcode=0xdf */
3623 * Handles opcode 0xe0
3631 ip += (int16_t) emu->x86.R_IP; in x86emuOp_loopne()
3632 emu->x86.R_CX -= 1; in x86emuOp_loopne()
3633 if (emu->x86.R_CX != 0 && !ACCESS_FLAG(F_ZF)) /* CX != 0 and !ZF */ in x86emuOp_loopne()
3634 emu->x86.R_IP = ip; in x86emuOp_loopne()
3639 * Handles opcode 0xe1
3647 ip += (int16_t) emu->x86.R_IP; in x86emuOp_loope()
3648 emu->x86.R_CX -= 1; in x86emuOp_loope()
3649 if (emu->x86.R_CX != 0 && ACCESS_FLAG(F_ZF)) /* CX != 0 and ZF */ in x86emuOp_loope()
3650 emu->x86.R_IP = ip; in x86emuOp_loope()
3655 * Handles opcode 0xe2
3663 ip += (int16_t) emu->x86.R_IP; in x86emuOp_loop()
3664 emu->x86.R_CX -= 1; in x86emuOp_loop()
3665 if (emu->x86.R_CX != 0) in x86emuOp_loop()
3666 emu->x86.R_IP = ip; in x86emuOp_loop()
3671 * Handles opcode 0xe3
3681 target = (uint16_t) (emu->x86.R_IP + offset); in x86emuOp_jcxz()
3682 if (emu->x86.R_CX == 0) in x86emuOp_jcxz()
3683 emu->x86.R_IP = target; in x86emuOp_jcxz()
3688 * Handles opcode 0xe4
3696 emu->x86.R_AL = (*emu->emu_inb) (emu, port); in x86emuOp_in_byte_AL_IMM()
3701 * Handles opcode 0xe5
3709 if (emu->x86.mode & SYSMODE_PREFIX_DATA) { in x86emuOp_in_word_AX_IMM()
3710 emu->x86.R_EAX = (*emu->emu_inl) (emu, port); in x86emuOp_in_word_AX_IMM()
3712 emu->x86.R_AX = (*emu->emu_inw) (emu, port); in x86emuOp_in_word_AX_IMM()
3718 * Handles opcode 0xe6
3726 (*emu->emu_outb) (emu, port, emu->x86.R_AL); in x86emuOp_out_byte_IMM_AL()
3731 * Handles opcode 0xe7
3739 if (emu->x86.mode & SYSMODE_PREFIX_DATA) { in x86emuOp_out_word_IMM_AX()
3740 (*emu->emu_outl) (emu, port, emu->x86.R_EAX); in x86emuOp_out_word_IMM_AX()
3742 (*emu->emu_outw) (emu, port, emu->x86.R_AX); in x86emuOp_out_word_IMM_AX()
3748 * Handles opcode 0xe8
3753 if (emu->x86.mode & SYSMODE_PREFIX_DATA) { in x86emuOp_call_near_IMM()
3756 ip += (int32_t) emu->x86.R_EIP; in x86emuOp_call_near_IMM()
3757 push_long(emu, emu->x86.R_EIP); in x86emuOp_call_near_IMM()
3758 emu->x86.R_EIP = ip; in x86emuOp_call_near_IMM()
3762 ip += (int16_t) emu->x86.R_IP; /* CHECK SIGN */ in x86emuOp_call_near_IMM()
3763 push_word(emu, emu->x86.R_IP); in x86emuOp_call_near_IMM()
3764 emu->x86.R_IP = ip; in x86emuOp_call_near_IMM()
3770 * Handles opcode 0xe9
3778 ip += (int16_t) emu->x86.R_IP; in x86emuOp_jump_near_IMM()
3779 emu->x86.R_IP = (uint16_t) ip; in x86emuOp_jump_near_IMM()
3784 * Handles opcode 0xea
3793 emu->x86.R_IP = ip; in x86emuOp_jump_far_IMM()
3794 emu->x86.R_CS = cs; in x86emuOp_jump_far_IMM()
3799 * Handles opcode 0xeb
3808 target = (uint16_t) (emu->x86.R_IP + offset); in x86emuOp_jump_byte_IMM()
3809 emu->x86.R_IP = target; in x86emuOp_jump_byte_IMM()
3814 * Handles opcode 0xec
3819 emu->x86.R_AL = (*emu->emu_inb) (emu, emu->x86.R_DX); in x86emuOp_in_byte_AL_DX()
3824 * Handles opcode 0xed
3829 if (emu->x86.mode & SYSMODE_PREFIX_DATA) { in x86emuOp_in_word_AX_DX()
3830 emu->x86.R_EAX = (*emu->emu_inl) (emu, emu->x86.R_DX); in x86emuOp_in_word_AX_DX()
3832 emu->x86.R_AX = (*emu->emu_inw) (emu, emu->x86.R_DX); in x86emuOp_in_word_AX_DX()
3838 * Handles opcode 0xee
3843 (*emu->emu_outb) (emu, emu->x86.R_DX, emu->x86.R_AL); in x86emuOp_out_byte_DX_AL()
3848 * Handles opcode 0xef
3853 if (emu->x86.mode & SYSMODE_PREFIX_DATA) { in x86emuOp_out_word_DX_AX()
3854 (*emu->emu_outl) (emu, emu->x86.R_DX, emu->x86.R_EAX); in x86emuOp_out_word_DX_AX()
3856 (*emu->emu_outw) (emu, emu->x86.R_DX, emu->x86.R_AX); in x86emuOp_out_word_DX_AX()
3862 * Handles opcode 0xf0
3868 /*opcode 0xf1 ILLEGAL OPERATION */
3873 * Handles opcode 0xf5
3886 * Handles opcode 0xf6
3899 if (emu->cur_rh == 0) { in x86emuOp_opcF6_byte_RM()
3931 * Handles opcode 0xf7
3944 if (emu->cur_rh == 0) { in x86emuOp32_opcF7_word_RM()
3993 if (emu->cur_rh == 0) { in x86emuOp16_opcF7_word_RM()
4034 if (emu->x86.mode & SYSMODE_PREFIX_DATA) in x86emuOp_opcF7_word_RM()
4042 * Handles opcode 0xfe
4056 case 0: /* inc word ptr ... */ in x86emuOp_opcFE_byte_RM()
4070 case 0: in x86emuOp_opcFE_byte_RM()
4082 * Handles opcode 0xff
4087 uint32_t destoffset = 0; in x86emuOp32_opcFF_word_RM()
4094 case 0: /* inc word ptr ... */ in x86emuOp32_opcFF_word_RM()
4109 case 0: in x86emuOp32_opcFF_word_RM()
4125 uint32_t destoffset = 0; in x86emuOp16_opcFF_word_RM()
4133 case 0: in x86emuOp16_opcFF_word_RM()
4148 case 0: in x86emuOp16_opcFF_word_RM()
4164 uint32_t destoffset = 0; in x86emuOp_opcFF_word_RM()
4172 if (emu->cur_rh == 0 || emu->cur_rh == 1 || emu->cur_rh == 6) { in x86emuOp_opcFF_word_RM()
4173 if (emu->x86.mode & SYSMODE_PREFIX_DATA) in x86emuOp_opcFF_word_RM()
4186 push_word(emu, emu->x86.R_CS); in x86emuOp_opcFF_word_RM()
4187 emu->x86.R_CS = destval2; in x86emuOp_opcFF_word_RM()
4188 push_word(emu, emu->x86.R_IP); in x86emuOp_opcFF_word_RM()
4189 emu->x86.R_IP = destval; in x86emuOp_opcFF_word_RM()
4193 emu->x86.R_IP = destval; in x86emuOp_opcFF_word_RM()
4194 emu->x86.R_CS = destval2; in x86emuOp_opcFF_word_RM()
4203 push_word(emu, emu->x86.R_IP); in x86emuOp_opcFF_word_RM()
4204 emu->x86.R_IP = destval; in x86emuOp_opcFF_word_RM()
4207 emu->x86.R_IP = destval; in x86emuOp_opcFF_word_RM()
4223 case 0x00: in x86emu_exec_one_byte()
4226 case 0x01: in x86emu_exec_one_byte()
4229 case 0x02: in x86emu_exec_one_byte()
4232 case 0x03: in x86emu_exec_one_byte()
4235 case 0x04: in x86emu_exec_one_byte()
4238 case 0x05: in x86emu_exec_one_byte()
4241 case 0x06: in x86emu_exec_one_byte()
4242 push_word(emu, emu->x86.R_ES); in x86emu_exec_one_byte()
4244 case 0x07: in x86emu_exec_one_byte()
4245 emu->x86.R_ES = pop_word(emu); in x86emu_exec_one_byte()
4248 case 0x08: in x86emu_exec_one_byte()
4251 case 0x09: in x86emu_exec_one_byte()
4254 case 0x0a: in x86emu_exec_one_byte()
4257 case 0x0b: in x86emu_exec_one_byte()
4260 case 0x0c: in x86emu_exec_one_byte()
4263 case 0x0d: in x86emu_exec_one_byte()
4266 case 0x0e: in x86emu_exec_one_byte()
4267 push_word(emu, emu->x86.R_CS); in x86emu_exec_one_byte()
4269 case 0x0f: in x86emu_exec_one_byte()
4273 case 0x10: in x86emu_exec_one_byte()
4276 case 0x11: in x86emu_exec_one_byte()
4279 case 0x12: in x86emu_exec_one_byte()
4282 case 0x13: in x86emu_exec_one_byte()
4285 case 0x14: in x86emu_exec_one_byte()
4288 case 0x15: in x86emu_exec_one_byte()
4291 case 0x16: in x86emu_exec_one_byte()
4292 push_word(emu, emu->x86.R_SS); in x86emu_exec_one_byte()
4294 case 0x17: in x86emu_exec_one_byte()
4295 emu->x86.R_SS = pop_word(emu); in x86emu_exec_one_byte()
4298 case 0x18: in x86emu_exec_one_byte()
4301 case 0x19: in x86emu_exec_one_byte()
4304 case 0x1a: in x86emu_exec_one_byte()
4307 case 0x1b: in x86emu_exec_one_byte()
4310 case 0x1c: in x86emu_exec_one_byte()
4313 case 0x1d: in x86emu_exec_one_byte()
4316 case 0x1e: in x86emu_exec_one_byte()
4317 push_word(emu, emu->x86.R_DS); in x86emu_exec_one_byte()
4319 case 0x1f: in x86emu_exec_one_byte()
4320 emu->x86.R_DS = pop_word(emu); in x86emu_exec_one_byte()
4323 case 0x20: in x86emu_exec_one_byte()
4326 case 0x21: in x86emu_exec_one_byte()
4329 case 0x22: in x86emu_exec_one_byte()
4332 case 0x23: in x86emu_exec_one_byte()
4335 case 0x24: in x86emu_exec_one_byte()
4338 case 0x25: in x86emu_exec_one_byte()
4341 case 0x26: in x86emu_exec_one_byte()
4342 emu->x86.mode |= SYSMODE_SEGOVR_ES; in x86emu_exec_one_byte()
4344 case 0x27: in x86emu_exec_one_byte()
4345 emu->x86.R_AL = daa_byte(emu, emu->x86.R_AL); in x86emu_exec_one_byte()
4348 case 0x28: in x86emu_exec_one_byte()
4351 case 0x29: in x86emu_exec_one_byte()
4354 case 0x2a: in x86emu_exec_one_byte()
4357 case 0x2b: in x86emu_exec_one_byte()
4360 case 0x2c: in x86emu_exec_one_byte()
4363 case 0x2d: in x86emu_exec_one_byte()
4366 case 0x2e: in x86emu_exec_one_byte()
4367 emu->x86.mode |= SYSMODE_SEGOVR_CS; in x86emu_exec_one_byte()
4369 case 0x2f: in x86emu_exec_one_byte()
4370 emu->x86.R_AL = das_byte(emu, emu->x86.R_AL); in x86emu_exec_one_byte()
4373 case 0x30: in x86emu_exec_one_byte()
4376 case 0x31: in x86emu_exec_one_byte()
4379 case 0x32: in x86emu_exec_one_byte()
4382 case 0x33: in x86emu_exec_one_byte()
4385 case 0x34: in x86emu_exec_one_byte()
4388 case 0x35: in x86emu_exec_one_byte()
4391 case 0x36: in x86emu_exec_one_byte()
4392 emu->x86.mode |= SYSMODE_SEGOVR_SS; in x86emu_exec_one_byte()
4394 case 0x37: in x86emu_exec_one_byte()
4395 emu->x86.R_AX = aaa_word(emu, emu->x86.R_AX); in x86emu_exec_one_byte()
4398 case 0x38: in x86emu_exec_one_byte()
4401 case 0x39: in x86emu_exec_one_byte()
4405 case 0x3a: in x86emu_exec_one_byte()
4408 case 0x3b: in x86emu_exec_one_byte()
4411 case 0x3c: in x86emu_exec_one_byte()
4414 case 0x3d: in x86emu_exec_one_byte()
4417 case 0x3e: in x86emu_exec_one_byte()
4418 emu->x86.mode |= SYSMODE_SEGOVR_DS; in x86emu_exec_one_byte()
4420 case 0x3f: in x86emu_exec_one_byte()
4421 emu->x86.R_AX = aas_word(emu, emu->x86.R_AX); in x86emu_exec_one_byte()
4424 case 0x40: in x86emu_exec_one_byte()
4425 common_inc_word_long(emu, &emu->x86.register_a); in x86emu_exec_one_byte()
4427 case 0x41: in x86emu_exec_one_byte()
4428 common_inc_word_long(emu, &emu->x86.register_c); in x86emu_exec_one_byte()
4430 case 0x42: in x86emu_exec_one_byte()
4431 common_inc_word_long(emu, &emu->x86.register_d); in x86emu_exec_one_byte()
4433 case 0x43: in x86emu_exec_one_byte()
4434 common_inc_word_long(emu, &emu->x86.register_b); in x86emu_exec_one_byte()
4436 case 0x44: in x86emu_exec_one_byte()
4437 common_inc_word_long(emu, &emu->x86.register_sp); in x86emu_exec_one_byte()
4439 case 0x45: in x86emu_exec_one_byte()
4440 common_inc_word_long(emu, &emu->x86.register_bp); in x86emu_exec_one_byte()
4442 case 0x46: in x86emu_exec_one_byte()
4443 common_inc_word_long(emu, &emu->x86.register_si); in x86emu_exec_one_byte()
4445 case 0x47: in x86emu_exec_one_byte()
4446 common_inc_word_long(emu, &emu->x86.register_di); in x86emu_exec_one_byte()
4449 case 0x48: in x86emu_exec_one_byte()
4450 common_dec_word_long(emu, &emu->x86.register_a); in x86emu_exec_one_byte()
4452 case 0x49: in x86emu_exec_one_byte()
4453 common_dec_word_long(emu, &emu->x86.register_c); in x86emu_exec_one_byte()
4455 case 0x4a: in x86emu_exec_one_byte()
4456 common_dec_word_long(emu, &emu->x86.register_d); in x86emu_exec_one_byte()
4458 case 0x4b: in x86emu_exec_one_byte()
4459 common_dec_word_long(emu, &emu->x86.register_b); in x86emu_exec_one_byte()
4461 case 0x4c: in x86emu_exec_one_byte()
4462 common_dec_word_long(emu, &emu->x86.register_sp); in x86emu_exec_one_byte()
4464 case 0x4d: in x86emu_exec_one_byte()
4465 common_dec_word_long(emu, &emu->x86.register_bp); in x86emu_exec_one_byte()
4467 case 0x4e: in x86emu_exec_one_byte()
4468 common_dec_word_long(emu, &emu->x86.register_si); in x86emu_exec_one_byte()
4470 case 0x4f: in x86emu_exec_one_byte()
4471 common_dec_word_long(emu, &emu->x86.register_di); in x86emu_exec_one_byte()
4474 case 0x50: in x86emu_exec_one_byte()
4475 common_push_word_long(emu, &emu->x86.register_a); in x86emu_exec_one_byte()
4477 case 0x51: in x86emu_exec_one_byte()
4478 common_push_word_long(emu, &emu->x86.register_c); in x86emu_exec_one_byte()
4480 case 0x52: in x86emu_exec_one_byte()
4481 common_push_word_long(emu, &emu->x86.register_d); in x86emu_exec_one_byte()
4483 case 0x53: in x86emu_exec_one_byte()
4484 common_push_word_long(emu, &emu->x86.register_b); in x86emu_exec_one_byte()
4486 case 0x54: in x86emu_exec_one_byte()
4487 common_push_word_long(emu, &emu->x86.register_sp); in x86emu_exec_one_byte()
4489 case 0x55: in x86emu_exec_one_byte()
4490 common_push_word_long(emu, &emu->x86.register_bp); in x86emu_exec_one_byte()
4492 case 0x56: in x86emu_exec_one_byte()
4493 common_push_word_long(emu, &emu->x86.register_si); in x86emu_exec_one_byte()
4495 case 0x57: in x86emu_exec_one_byte()
4496 common_push_word_long(emu, &emu->x86.register_di); in x86emu_exec_one_byte()
4499 case 0x58: in x86emu_exec_one_byte()
4500 common_pop_word_long(emu, &emu->x86.register_a); in x86emu_exec_one_byte()
4502 case 0x59: in x86emu_exec_one_byte()
4503 common_pop_word_long(emu, &emu->x86.register_c); in x86emu_exec_one_byte()
4505 case 0x5a: in x86emu_exec_one_byte()
4506 common_pop_word_long(emu, &emu->x86.register_d); in x86emu_exec_one_byte()
4508 case 0x5b: in x86emu_exec_one_byte()
4509 common_pop_word_long(emu, &emu->x86.register_b); in x86emu_exec_one_byte()
4511 case 0x5c: in x86emu_exec_one_byte()
4512 common_pop_word_long(emu, &emu->x86.register_sp); in x86emu_exec_one_byte()
4514 case 0x5d: in x86emu_exec_one_byte()
4515 common_pop_word_long(emu, &emu->x86.register_bp); in x86emu_exec_one_byte()
4517 case 0x5e: in x86emu_exec_one_byte()
4518 common_pop_word_long(emu, &emu->x86.register_si); in x86emu_exec_one_byte()
4520 case 0x5f: in x86emu_exec_one_byte()
4521 common_pop_word_long(emu, &emu->x86.register_di); in x86emu_exec_one_byte()
4524 case 0x60: in x86emu_exec_one_byte()
4527 case 0x61: in x86emu_exec_one_byte()
4530 /* 0x62 bound */ in x86emu_exec_one_byte()
4531 /* 0x63 arpl */ in x86emu_exec_one_byte()
4532 case 0x64: in x86emu_exec_one_byte()
4533 emu->x86.mode |= SYSMODE_SEGOVR_FS; in x86emu_exec_one_byte()
4535 case 0x65: in x86emu_exec_one_byte()
4536 emu->x86.mode |= SYSMODE_SEGOVR_GS; in x86emu_exec_one_byte()
4538 case 0x66: in x86emu_exec_one_byte()
4539 emu->x86.mode |= SYSMODE_PREFIX_DATA; in x86emu_exec_one_byte()
4541 case 0x67: in x86emu_exec_one_byte()
4542 emu->x86.mode |= SYSMODE_PREFIX_ADDR; in x86emu_exec_one_byte()
4545 case 0x68: in x86emu_exec_one_byte()
4548 case 0x69: in x86emu_exec_one_byte()
4549 common_imul_imm(emu, 0); in x86emu_exec_one_byte()
4551 case 0x6a: in x86emu_exec_one_byte()
4554 case 0x6b: in x86emu_exec_one_byte()
4557 case 0x6c: in x86emu_exec_one_byte()
4560 case 0x6d: in x86emu_exec_one_byte()
4563 case 0x6e: in x86emu_exec_one_byte()
4566 case 0x6f: in x86emu_exec_one_byte()
4570 case 0x70: in x86emu_exec_one_byte()
4573 case 0x71: in x86emu_exec_one_byte()
4576 case 0x72: in x86emu_exec_one_byte()
4579 case 0x73: in x86emu_exec_one_byte()
4582 case 0x74: in x86emu_exec_one_byte()
4585 case 0x75: in x86emu_exec_one_byte()
4588 case 0x76: in x86emu_exec_one_byte()
4591 case 0x77: in x86emu_exec_one_byte()
4595 case 0x78: in x86emu_exec_one_byte()
4598 case 0x79: in x86emu_exec_one_byte()
4601 case 0x7a: in x86emu_exec_one_byte()
4604 case 0x7b: in x86emu_exec_one_byte()
4607 case 0x7c: in x86emu_exec_one_byte()
4610 case 0x7d: in x86emu_exec_one_byte()
4613 case 0x7e: in x86emu_exec_one_byte()
4616 case 0x7f: in x86emu_exec_one_byte()
4620 case 0x80: in x86emu_exec_one_byte()
4623 case 0x81: in x86emu_exec_one_byte()
4626 case 0x82: in x86emu_exec_one_byte()
4629 case 0x83: in x86emu_exec_one_byte()
4632 case 0x84: in x86emu_exec_one_byte()
4635 case 0x85: in x86emu_exec_one_byte()
4638 case 0x86: in x86emu_exec_one_byte()
4641 case 0x87: in x86emu_exec_one_byte()
4645 case 0x88: in x86emu_exec_one_byte()
4648 case 0x89: in x86emu_exec_one_byte()
4651 case 0x8a: in x86emu_exec_one_byte()
4654 case 0x8b: in x86emu_exec_one_byte()
4657 case 0x8c: in x86emu_exec_one_byte()
4660 case 0x8d: in x86emu_exec_one_byte()
4663 case 0x8e: in x86emu_exec_one_byte()
4666 case 0x8f: in x86emu_exec_one_byte()
4670 case 0x90: in x86emu_exec_one_byte()
4673 case 0x91: in x86emu_exec_one_byte()
4676 case 0x92: in x86emu_exec_one_byte()
4679 case 0x93: in x86emu_exec_one_byte()
4682 case 0x94: in x86emu_exec_one_byte()
4685 case 0x95: in x86emu_exec_one_byte()
4688 case 0x96: in x86emu_exec_one_byte()
4691 case 0x97: in x86emu_exec_one_byte()
4695 case 0x98: in x86emu_exec_one_byte()
4698 case 0x99: in x86emu_exec_one_byte()
4701 case 0x9a: in x86emu_exec_one_byte()
4704 case 0x9b: in x86emu_exec_one_byte()
4707 case 0x9c: in x86emu_exec_one_byte()
4710 case 0x9d: in x86emu_exec_one_byte()
4713 case 0x9e: in x86emu_exec_one_byte()
4716 case 0x9f: in x86emu_exec_one_byte()
4720 case 0xa0: in x86emu_exec_one_byte()
4723 case 0xa1: in x86emu_exec_one_byte()
4726 case 0xa2: in x86emu_exec_one_byte()
4729 case 0xa3: in x86emu_exec_one_byte()
4732 case 0xa4: in x86emu_exec_one_byte()
4735 case 0xa5: in x86emu_exec_one_byte()
4738 case 0xa6: in x86emu_exec_one_byte()
4741 case 0xa7: in x86emu_exec_one_byte()
4745 case 0xa8: in x86emu_exec_one_byte()
4746 test_byte(emu, emu->x86.R_AL, fetch_byte_imm(emu)); in x86emu_exec_one_byte()
4748 case 0xa9: in x86emu_exec_one_byte()
4751 case 0xaa: in x86emu_exec_one_byte()
4754 case 0xab: in x86emu_exec_one_byte()
4757 case 0xac: in x86emu_exec_one_byte()
4760 case 0xad: in x86emu_exec_one_byte()
4763 case 0xae: in x86emu_exec_one_byte()
4766 case 0xaf: in x86emu_exec_one_byte()
4770 case 0xb0: in x86emu_exec_one_byte()
4771 emu->x86.R_AL = fetch_byte_imm(emu); in x86emu_exec_one_byte()
4773 case 0xb1: in x86emu_exec_one_byte()
4774 emu->x86.R_CL = fetch_byte_imm(emu); in x86emu_exec_one_byte()
4776 case 0xb2: in x86emu_exec_one_byte()
4777 emu->x86.R_DL = fetch_byte_imm(emu); in x86emu_exec_one_byte()
4779 case 0xb3: in x86emu_exec_one_byte()
4780 emu->x86.R_BL = fetch_byte_imm(emu); in x86emu_exec_one_byte()
4782 case 0xb4: in x86emu_exec_one_byte()
4783 emu->x86.R_AH = fetch_byte_imm(emu); in x86emu_exec_one_byte()
4785 case 0xb5: in x86emu_exec_one_byte()
4786 emu->x86.R_CH = fetch_byte_imm(emu); in x86emu_exec_one_byte()
4788 case 0xb6: in x86emu_exec_one_byte()
4789 emu->x86.R_DH = fetch_byte_imm(emu); in x86emu_exec_one_byte()
4791 case 0xb7: in x86emu_exec_one_byte()
4792 emu->x86.R_BH = fetch_byte_imm(emu); in x86emu_exec_one_byte()
4795 case 0xb8: in x86emu_exec_one_byte()
4798 case 0xb9: in x86emu_exec_one_byte()
4801 case 0xba: in x86emu_exec_one_byte()
4804 case 0xbb: in x86emu_exec_one_byte()
4807 case 0xbc: in x86emu_exec_one_byte()
4811 case 0xbd: in x86emu_exec_one_byte()
4814 case 0xbe: in x86emu_exec_one_byte()
4817 case 0xbf: in x86emu_exec_one_byte()
4821 case 0xc0: in x86emu_exec_one_byte()
4824 case 0xc1: in x86emu_exec_one_byte()
4827 case 0xc2: in x86emu_exec_one_byte()
4830 case 0xc3: in x86emu_exec_one_byte()
4831 emu->x86.R_IP = pop_word(emu); in x86emu_exec_one_byte()
4833 case 0xc4: in x86emu_exec_one_byte()
4834 common_load_far_pointer(emu, &emu->x86.R_ES); in x86emu_exec_one_byte()
4836 case 0xc5: in x86emu_exec_one_byte()
4837 common_load_far_pointer(emu, &emu->x86.R_DS); in x86emu_exec_one_byte()
4839 case 0xc6: in x86emu_exec_one_byte()
4842 case 0xc7: in x86emu_exec_one_byte()
4845 case 0xc8: in x86emu_exec_one_byte()
4848 case 0xc9: in x86emu_exec_one_byte()
4851 case 0xca: in x86emu_exec_one_byte()
4854 case 0xcb: in x86emu_exec_one_byte()
4857 case 0xcc: in x86emu_exec_one_byte()
4860 case 0xcd: in x86emu_exec_one_byte()
4863 case 0xce: in x86emu_exec_one_byte()
4866 case 0xcf: in x86emu_exec_one_byte()
4870 case 0xd0: in x86emu_exec_one_byte()
4873 case 0xd1: in x86emu_exec_one_byte()
4876 case 0xd2: in x86emu_exec_one_byte()
4879 case 0xd3: in x86emu_exec_one_byte()
4882 case 0xd4: in x86emu_exec_one_byte()
4885 case 0xd5: in x86emu_exec_one_byte()
4888 /* 0xd6 Undocumented SETALC instruction */ in x86emu_exec_one_byte()
4889 case 0xd7: in x86emu_exec_one_byte()
4892 case 0xd8: in x86emu_exec_one_byte()
4895 case 0xd9: in x86emu_exec_one_byte()
4898 case 0xda: in x86emu_exec_one_byte()
4901 case 0xdb: in x86emu_exec_one_byte()
4904 case 0xdc: in x86emu_exec_one_byte()
4907 case 0xdd: in x86emu_exec_one_byte()
4910 case 0xde: in x86emu_exec_one_byte()
4913 case 0xdf: in x86emu_exec_one_byte()
4917 case 0xe0: in x86emu_exec_one_byte()
4920 case 0xe1: in x86emu_exec_one_byte()
4923 case 0xe2: in x86emu_exec_one_byte()
4926 case 0xe3: in x86emu_exec_one_byte()
4929 case 0xe4: in x86emu_exec_one_byte()
4932 case 0xe5: in x86emu_exec_one_byte()
4935 case 0xe6: in x86emu_exec_one_byte()
4938 case 0xe7: in x86emu_exec_one_byte()
4942 case 0xe8: in x86emu_exec_one_byte()
4945 case 0xe9: in x86emu_exec_one_byte()
4948 case 0xea: in x86emu_exec_one_byte()
4951 case 0xeb: in x86emu_exec_one_byte()
4954 case 0xec: in x86emu_exec_one_byte()
4957 case 0xed: in x86emu_exec_one_byte()
4960 case 0xee: in x86emu_exec_one_byte()
4963 case 0xef: in x86emu_exec_one_byte()
4967 case 0xf0: in x86emu_exec_one_byte()
4970 case 0xf2: in x86emu_exec_one_byte()
4971 emu->x86.mode |= SYSMODE_PREFIX_REPNE; in x86emu_exec_one_byte()
4973 case 0xf3: in x86emu_exec_one_byte()
4974 emu->x86.mode |= SYSMODE_PREFIX_REPE; in x86emu_exec_one_byte()
4976 case 0xf4: in x86emu_exec_one_byte()
4979 case 0xf5: in x86emu_exec_one_byte()
4982 case 0xf6: in x86emu_exec_one_byte()
4985 case 0xf7: in x86emu_exec_one_byte()
4989 case 0xf8: in x86emu_exec_one_byte()
4992 case 0xf9: in x86emu_exec_one_byte()
4995 case 0xfa: in x86emu_exec_one_byte()
4998 case 0xfb: in x86emu_exec_one_byte()
5001 case 0xfc: in x86emu_exec_one_byte()
5004 case 0xfd: in x86emu_exec_one_byte()
5007 case 0xfe: in x86emu_exec_one_byte()
5010 case 0xff: in x86emu_exec_one_byte()
5017 if (op1 != 0x26 && op1 != 0x2e && op1 != 0x36 && op1 != 0x3e && in x86emu_exec_one_byte()
5018 (op1 | 3) != 0x67) in x86emu_exec_one_byte()
5019 emu->x86.mode &= ~SYSMODE_CLRMASK; in x86emu_exec_one_byte()
5028 target += (int16_t) emu->x86.R_IP; in common_jmp_long()
5030 emu->x86.R_IP = (uint16_t) target; in common_jmp_long()
5040 destval = cond ? 0x01 : 0x00; in common_set_byte()
5059 bit = *shiftreg & 0x1F; in common_bitstring32()
5060 mask = 0x1 << bit; in common_bitstring32()
5064 case 0: in common_bitstring32()
5087 bit = *shiftreg & 0xF; in common_bitstring16()
5088 mask = 0x1 << bit; in common_bitstring16()
5092 case 0: in common_bitstring16()
5109 if (emu->x86.mode & SYSMODE_PREFIX_DATA) in common_bitstring()
5123 CONDITIONAL_SET_FLAG(srcval == 0, F_ZF); in common_bitsearch32()
5124 for (*dstreg = 0; *dstreg < 32; *dstreg += diff) { in common_bitsearch32()
5138 CONDITIONAL_SET_FLAG(srcval == 0, F_ZF); in common_bitsearch16()
5139 for (*dstreg = 0; *dstreg < 16; *dstreg += diff) { in common_bitsearch16()
5148 if (emu->x86.mode & SYSMODE_PREFIX_DATA) in common_bitsearch()
5164 shift = emu->x86.R_CL; in common_shift32()
5185 shift = emu->x86.R_CL; in common_shift16()
5199 if (emu->x86.mode & SYSMODE_PREFIX_DATA) in common_shift()
5213 * Handles opcode 0x0f,0x31
5218 emu->x86.R_EAX = emu->cur_cycles & 0xffffffff; in x86emuOp2_rdtsc()
5219 emu->x86.R_EDX = emu->cur_cycles >> 32; in x86emuOp2_rdtsc()
5224 * Handles opcode 0x0f,0xa0
5229 push_word(emu, emu->x86.R_FS); in x86emuOp2_push_FS()
5234 * Handles opcode 0x0f,0xa1
5239 emu->x86.R_FS = pop_word(emu); in x86emuOp2_pop_FS()
5244 * Handles opcode 0x0f,0xa1
5261 hw_cpuid(&emu->x86.R_EAX, &emu->x86.R_EBX, &emu->x86.R_ECX, in x86emuOp2_cpuid()
5262 &emu->x86.R_EDX); in x86emuOp2_cpuid()
5264 switch (emu->x86.R_EAX) { in x86emuOp2_cpuid()
5265 case 0: in x86emuOp2_cpuid()
5266 emu->x86.R_EAX = 1; in x86emuOp2_cpuid()
5269 emu->x86.R_EBX = 0x756e6547; in x86emuOp2_cpuid()
5270 emu->x86.R_EDX = 0x49656e69; in x86emuOp2_cpuid()
5271 emu->x86.R_ECX = 0x6c65746e; in x86emuOp2_cpuid()
5276 emu->x86.R_EAX = 0x00000480; in x86emuOp2_cpuid()
5277 emu->x86.R_EBX = emu->x86.R_ECX = 0; in x86emuOp2_cpuid()
5278 emu->x86.R_EDX = 0x00000002; in x86emuOp2_cpuid()
5280 emu->x86.R_EDX &= 0x00000012; in x86emuOp2_cpuid()
5284 emu->x86.R_EAX = emu->x86.R_EBX = emu->x86.R_ECX = in x86emuOp2_cpuid()
5285 emu->x86.R_EDX = 0; in x86emuOp2_cpuid()
5292 * Handles opcode 0x0f,0xa3
5297 common_bitstring(emu, 0); in x86emuOp2_bt_R()
5302 * Handles opcode 0x0f,0xa4
5307 common_shift(emu, 1, 0); in x86emuOp2_shld_IMM()
5312 * Handles opcode 0x0f,0xa5
5322 * Handles opcode 0x0f,0xa8
5327 push_word(emu, emu->x86.R_GS); in x86emuOp2_push_GS()
5332 * Handles opcode 0x0f,0xa9
5337 emu->x86.R_GS = pop_word(emu); in x86emuOp2_pop_GS()
5342 * Handles opcode 0x0f,0xab
5352 * Handles opcode 0x0f,0xac
5357 common_shift(emu, 0, 0); in x86emuOp2_shrd_IMM()
5362 * Handles opcode 0x0f,0xad
5367 common_shift(emu, 0, 1); in x86emuOp2_shrd_CL()
5372 * Handles opcode 0x0f,0xaf
5384 if (res > 0xffffffff) { in x86emuOp2_32_imul_R_RM()
5404 if (res > 0xFFFF) { in x86emuOp2_16_imul_R_RM()
5417 if (emu->x86.mode & SYSMODE_PREFIX_DATA) in x86emuOp2_imul_R_RM()
5425 * Handles opcode 0x0f,0xb2
5430 common_load_far_pointer(emu, &emu->x86.R_SS); in x86emuOp2_lss_R_IMM()
5435 * Handles opcode 0x0f,0xb3
5445 * Handles opcode 0x0f,0xb4
5450 common_load_far_pointer(emu, &emu->x86.R_FS); in x86emuOp2_lfs_R_IMM()
5455 * Handles opcode 0x0f,0xb5
5460 common_load_far_pointer(emu, &emu->x86.R_GS); in x86emuOp2_lgs_R_IMM()
5465 * Handles opcode 0x0f,0xb6
5490 if (emu->x86.mode & SYSMODE_PREFIX_DATA) in x86emuOp2_movzx_byte_R_RM()
5498 * Handles opcode 0x0f,0xb7
5512 * Handles opcode 0x0f,0xba
5526 bit = shift & 0x1F; in x86emuOp2_32_btX_I()
5527 mask = (0x1 << bit); in x86emuOp2_32_btX_I()
5556 bit = shift & 0xF; in x86emuOp2_16_btX_I()
5557 mask = (0x1 << bit); in x86emuOp2_16_btX_I()
5575 if (emu->x86.mode & SYSMODE_PREFIX_DATA) in x86emuOp2_btX_I()
5583 * Handles opcode 0x0f,0xbb
5593 * Handles opcode 0x0f,0xbc
5603 * Handles opcode 0x0f,0xbd
5613 * Handles opcode 0x0f,0xbe
5638 if (emu->x86.mode & SYSMODE_PREFIX_DATA) in x86emuOp2_movsx_byte_R_RM()
5646 * Handles opcode 0x0f,0xbf
5666 /* 0x00 Group F (ring 0 PM) */ in x86emu_exec_two_byte()
5667 /* 0x01 Group G (ring 0 PM) */ in x86emu_exec_two_byte()
5668 /* 0x02 lar (ring 0 PM) */ in x86emu_exec_two_byte()
5669 /* 0x03 lsl (ring 0 PM) */ in x86emu_exec_two_byte()
5670 /* 0x05 loadall (undocumented) */ in x86emu_exec_two_byte()
5671 /* 0x06 clts (ring 0 PM) */ in x86emu_exec_two_byte()
5672 /* 0x07 loadall (undocumented) */ in x86emu_exec_two_byte()
5673 /* 0x08 invd (ring 0 PM) */ in x86emu_exec_two_byte()
5674 /* 0x09 wbinvd (ring 0 PM) */ in x86emu_exec_two_byte()
5676 /* 0x20 mov reg32(op2); break;creg (ring 0 PM) */ in x86emu_exec_two_byte()
5677 /* 0x21 mov reg32(op2); break;dreg (ring 0 PM) */ in x86emu_exec_two_byte()
5678 /* 0x22 mov creg(op2); break;reg32 (ring 0 PM) */ in x86emu_exec_two_byte()
5679 /* 0x23 mov dreg(op2); break;reg32 (ring 0 PM) */ in x86emu_exec_two_byte()
5680 /* 0x24 mov reg32(op2); break;treg (ring 0 PM) */ in x86emu_exec_two_byte()
5681 /* 0x26 mov treg(op2); break;reg32 (ring 0 PM) */ in x86emu_exec_two_byte()
5683 case 0x31: in x86emu_exec_two_byte()
5687 case 0x80: in x86emu_exec_two_byte()
5690 case 0x81: in x86emu_exec_two_byte()
5693 case 0x82: in x86emu_exec_two_byte()
5696 case 0x83: in x86emu_exec_two_byte()
5699 case 0x84: in x86emu_exec_two_byte()
5702 case 0x85: in x86emu_exec_two_byte()
5705 case 0x86: in x86emu_exec_two_byte()
5708 case 0x87: in x86emu_exec_two_byte()
5711 case 0x88: in x86emu_exec_two_byte()
5714 case 0x89: in x86emu_exec_two_byte()
5717 case 0x8a: in x86emu_exec_two_byte()
5720 case 0x8b: in x86emu_exec_two_byte()
5723 case 0x8c: in x86emu_exec_two_byte()
5727 case 0x8d: in x86emu_exec_two_byte()
5731 case 0x8e: in x86emu_exec_two_byte()
5735 case 0x8f: in x86emu_exec_two_byte()
5741 case 0x90: in x86emu_exec_two_byte()
5744 case 0x91: in x86emu_exec_two_byte()
5747 case 0x92: in x86emu_exec_two_byte()
5750 case 0x93: in x86emu_exec_two_byte()
5753 case 0x94: in x86emu_exec_two_byte()
5756 case 0x95: in x86emu_exec_two_byte()
5759 case 0x96: in x86emu_exec_two_byte()
5762 case 0x97: in x86emu_exec_two_byte()
5765 case 0x98: in x86emu_exec_two_byte()
5768 case 0x99: in x86emu_exec_two_byte()
5771 case 0x9a: in x86emu_exec_two_byte()
5774 case 0x9b: in x86emu_exec_two_byte()
5777 case 0x9c: in x86emu_exec_two_byte()
5781 case 0x9d: in x86emu_exec_two_byte()
5785 case 0x9e: in x86emu_exec_two_byte()
5790 case 0x9f: in x86emu_exec_two_byte()
5796 case 0xa0: in x86emu_exec_two_byte()
5799 case 0xa1: in x86emu_exec_two_byte()
5802 case 0xa2: in x86emu_exec_two_byte()
5805 case 0xa3: in x86emu_exec_two_byte()
5808 case 0xa4: in x86emu_exec_two_byte()
5811 case 0xa5: in x86emu_exec_two_byte()
5814 case 0xa8: in x86emu_exec_two_byte()
5817 case 0xa9: in x86emu_exec_two_byte()
5820 case 0xab: in x86emu_exec_two_byte()
5823 case 0xac: in x86emu_exec_two_byte()
5826 case 0xad: in x86emu_exec_two_byte()
5829 case 0xaf: in x86emu_exec_two_byte()
5833 /* 0xb0 TODO: cmpxchg */ in x86emu_exec_two_byte()
5834 /* 0xb1 TODO: cmpxchg */ in x86emu_exec_two_byte()
5835 case 0xb2: in x86emu_exec_two_byte()
5838 case 0xb3: in x86emu_exec_two_byte()
5841 case 0xb4: in x86emu_exec_two_byte()
5844 case 0xb5: in x86emu_exec_two_byte()
5847 case 0xb6: in x86emu_exec_two_byte()
5850 case 0xb7: in x86emu_exec_two_byte()
5853 case 0xba: in x86emu_exec_two_byte()
5856 case 0xbb: in x86emu_exec_two_byte()
5859 case 0xbc: in x86emu_exec_two_byte()
5862 case 0xbd: in x86emu_exec_two_byte()
5865 case 0xbe: in x86emu_exec_two_byte()
5868 case 0xbf: in x86emu_exec_two_byte()
5872 /* 0xc0 TODO: xadd */ in x86emu_exec_two_byte()
5873 /* 0xc1 TODO: xadd */ in x86emu_exec_two_byte()
5874 /* 0xc8 TODO: bswap */ in x86emu_exec_two_byte()
5875 /* 0xc9 TODO: bswap */ in x86emu_exec_two_byte()
5876 /* 0xca TODO: bswap */ in x86emu_exec_two_byte()
5877 /* 0xcb TODO: bswap */ in x86emu_exec_two_byte()
5878 /* 0xcc TODO: bswap */ in x86emu_exec_two_byte()
5879 /* 0xcd TODO: bswap */ in x86emu_exec_two_byte()
5880 /* 0xce TODO: bswap */ in x86emu_exec_two_byte()
5881 /* 0xcf TODO: bswap */ in x86emu_exec_two_byte()
5904 * 0 0 0 0 0
5905 * 0 0 1 1 0
5906 * 0 1 0 1 0
5907 * 0 1 1 0 1
5908 * 1 0 0 1 0
5909 * 1 0 1 0 1
5910 * 1 1 0 0 1
5918 * 0 | 0 1 1 1
5919 * 1 | 0 0 1 0
5931 * 0 0 0 0 0
5932 * 0 0 1 1 1
5933 * 0 1 0 1 1
5934 * 0 1 1 0 1
5935 * 1 0 0 1 0
5936 * 1 0 1 0 0
5937 * 1 1 0 0 0
5945 * 0 | 0 1 0 0
5946 * 1 | 1 1 1 0
5958 0x96696996,
5959 0x69969669,
5960 0x69969669,
5961 0x96696996,
5962 0x69969669,
5963 0x96696996,
5964 0x96696996,
5965 0x69969669,
5967 #define PARITY(x) (((x86emu_parity_tab[(x) / 32] >> ((x) % 32)) & 1) == 0)
5968 #define XOR2(x) (((x) ^ ((x)>>1)) & 0x1)
5979 if ((d & 0xf) > 0x9 || ACCESS_FLAG(F_AF)) { in aaa_word()
5980 d += 0x6; in aaa_word()
5981 d += 0x100; in aaa_word()
5988 res = (uint16_t) (d & 0xFF0F); in aaa_word()
5990 CONDITIONAL_SET_FLAG(res == 0, F_ZF); in aaa_word()
5991 CONDITIONAL_SET_FLAG(PARITY(res & 0xff), F_PF); in aaa_word()
6003 if ((d & 0xf) > 0x9 || ACCESS_FLAG(F_AF)) { in aas_word()
6004 d -= 0x6; in aas_word()
6005 d -= 0x100; in aas_word()
6012 res = (uint16_t) (d & 0xFF0F); in aas_word()
6014 CONDITIONAL_SET_FLAG(res == 0, F_ZF); in aas_word()
6015 CONDITIONAL_SET_FLAG(PARITY(res & 0xff), F_PF); in aas_word()
6029 hb = (uint8_t) ((d >> 8) & 0xff); in aad_word()
6030 lb = (uint8_t) ((d & 0xff)); in aad_word()
6031 l = (uint16_t) ((lb + 10 * hb) & 0xFF); in aad_word()
6036 CONDITIONAL_SET_FLAG(l & 0x80, F_SF); in aad_word()
6037 CONDITIONAL_SET_FLAG(l == 0, F_ZF); in aad_word()
6038 CONDITIONAL_SET_FLAG(PARITY(l & 0xff), F_PF); in aad_word()
6058 CONDITIONAL_SET_FLAG(l & 0x80, F_SF); in aam_word()
6059 CONDITIONAL_SET_FLAG(l == 0, F_ZF); in aam_word()
6060 CONDITIONAL_SET_FLAG(PARITY(l & 0xff), F_PF); in aam_word()
6079 CONDITIONAL_SET_FLAG(res & 0x100, F_CF); in adc_byte()
6080 CONDITIONAL_SET_FLAG((res & 0xff) == 0, F_ZF); in adc_byte()
6081 CONDITIONAL_SET_FLAG(res & 0x80, F_SF); in adc_byte()
6082 CONDITIONAL_SET_FLAG(PARITY(res & 0xff), F_PF); in adc_byte()
6087 CONDITIONAL_SET_FLAG(cc & 0x8, F_AF); in adc_byte()
6106 CONDITIONAL_SET_FLAG(res & 0x10000, F_CF); in adc_word()
6107 CONDITIONAL_SET_FLAG((res & 0xffff) == 0, F_ZF); in adc_word()
6108 CONDITIONAL_SET_FLAG(res & 0x8000, F_SF); in adc_word()
6109 CONDITIONAL_SET_FLAG(PARITY(res & 0xff), F_PF); in adc_word()
6114 CONDITIONAL_SET_FLAG(cc & 0x8, F_AF); in adc_word()
6131 lo = 1 + (d & 0xFFFF) + (s & 0xFFFF); in adc_long()
6134 lo = (d & 0xFFFF) + (s & 0xFFFF); in adc_long()
6139 CONDITIONAL_SET_FLAG(hi & 0x10000, F_CF); in adc_long()
6140 CONDITIONAL_SET_FLAG((res & 0xffffffff) == 0, F_ZF); in adc_long()
6141 CONDITIONAL_SET_FLAG(res & 0x80000000, F_SF); in adc_long()
6142 CONDITIONAL_SET_FLAG(PARITY(res & 0xff), F_PF); in adc_long()
6147 CONDITIONAL_SET_FLAG(cc & 0x8, F_AF); in adc_long()
6162 CONDITIONAL_SET_FLAG(res & 0x100, F_CF); in add_byte()
6163 CONDITIONAL_SET_FLAG((res & 0xff) == 0, F_ZF); in add_byte()
6164 CONDITIONAL_SET_FLAG(res & 0x80, F_SF); in add_byte()
6165 CONDITIONAL_SET_FLAG(PARITY(res & 0xff), F_PF); in add_byte()
6170 CONDITIONAL_SET_FLAG(cc & 0x8, F_AF); in add_byte()
6185 CONDITIONAL_SET_FLAG(res & 0x10000, F_CF); in add_word()
6186 CONDITIONAL_SET_FLAG((res & 0xffff) == 0, F_ZF); in add_word()
6187 CONDITIONAL_SET_FLAG(res & 0x8000, F_SF); in add_word()
6188 CONDITIONAL_SET_FLAG(PARITY(res & 0xff), F_PF); in add_word()
6193 CONDITIONAL_SET_FLAG(cc & 0x8, F_AF); in add_word()
6209 lo = (d & 0xFFFF) + (s & 0xFFFF); in add_long()
6213 CONDITIONAL_SET_FLAG(hi & 0x10000, F_CF); in add_long()
6214 CONDITIONAL_SET_FLAG((res & 0xffffffff) == 0, F_ZF); in add_long()
6215 CONDITIONAL_SET_FLAG(res & 0x80000000, F_SF); in add_long()
6216 CONDITIONAL_SET_FLAG(PARITY(res & 0xff), F_PF); in add_long()
6221 CONDITIONAL_SET_FLAG(cc & 0x8, F_AF); in add_long()
6241 CONDITIONAL_SET_FLAG(res & 0x80, F_SF); in and_byte()
6242 CONDITIONAL_SET_FLAG(res == 0, F_ZF); in and_byte()
6262 CONDITIONAL_SET_FLAG(res & 0x8000, F_SF); in and_word()
6263 CONDITIONAL_SET_FLAG(res == 0, F_ZF); in and_word()
6264 CONDITIONAL_SET_FLAG(PARITY(res & 0xff), F_PF); in and_word()
6283 CONDITIONAL_SET_FLAG(res & 0x80000000, F_SF); in and_long()
6284 CONDITIONAL_SET_FLAG(res == 0, F_ZF); in and_long()
6285 CONDITIONAL_SET_FLAG(PARITY(res & 0xff), F_PF); in and_long()
6301 CONDITIONAL_SET_FLAG(res & 0x80, F_SF); in cmp_byte()
6302 CONDITIONAL_SET_FLAG((res & 0xff) == 0, F_ZF); in cmp_byte()
6303 CONDITIONAL_SET_FLAG(PARITY(res & 0xff), F_PF); in cmp_byte()
6307 CONDITIONAL_SET_FLAG(bc & 0x80, F_CF); in cmp_byte()
6309 CONDITIONAL_SET_FLAG(bc & 0x8, F_AF); in cmp_byte()
6330 CONDITIONAL_SET_FLAG(res & 0x8000, F_SF); in cmp_word()
6331 CONDITIONAL_SET_FLAG((res & 0xffff) == 0, F_ZF); in cmp_word()
6332 CONDITIONAL_SET_FLAG(PARITY(res & 0xff), F_PF); in cmp_word()
6336 CONDITIONAL_SET_FLAG(bc & 0x8000, F_CF); in cmp_word()
6338 CONDITIONAL_SET_FLAG(bc & 0x8, F_AF); in cmp_word()
6359 CONDITIONAL_SET_FLAG(res & 0x80000000, F_SF); in cmp_long()
6360 CONDITIONAL_SET_FLAG((res & 0xffffffff) == 0, F_ZF); in cmp_long()
6361 CONDITIONAL_SET_FLAG(PARITY(res & 0xff), F_PF); in cmp_long()
6365 CONDITIONAL_SET_FLAG(bc & 0x80000000, F_CF); in cmp_long()
6367 CONDITIONAL_SET_FLAG(bc & 0x8, F_AF); in cmp_long()
6385 if ((d & 0xf) > 9 || ACCESS_FLAG(F_AF)) { in daa_byte()
6389 if (res > 0x9F || ACCESS_FLAG(F_CF)) { in daa_byte()
6390 res += 0x60; in daa_byte()
6393 CONDITIONAL_SET_FLAG(res & 0x80, F_SF); in daa_byte()
6394 CONDITIONAL_SET_FLAG((res & 0xFF) == 0, F_ZF); in daa_byte()
6395 CONDITIONAL_SET_FLAG(PARITY(res & 0xff), F_PF); in daa_byte()
6406 if ((d & 0xf) > 9 || ACCESS_FLAG(F_AF)) { in das_byte()
6410 if (d > 0x9F || ACCESS_FLAG(F_CF)) { in das_byte()
6411 d -= 0x60; in das_byte()
6414 CONDITIONAL_SET_FLAG(d & 0x80, F_SF); in das_byte()
6415 CONDITIONAL_SET_FLAG(d == 0, F_ZF); in das_byte()
6416 CONDITIONAL_SET_FLAG(PARITY(d & 0xff), F_PF); in das_byte()
6431 CONDITIONAL_SET_FLAG(res & 0x80, F_SF); in dec_byte()
6432 CONDITIONAL_SET_FLAG((res & 0xff) == 0, F_ZF); in dec_byte()
6433 CONDITIONAL_SET_FLAG(PARITY(res & 0xff), F_PF); in dec_byte()
6440 CONDITIONAL_SET_FLAG(bc & 0x8, F_AF); in dec_byte()
6455 CONDITIONAL_SET_FLAG(res & 0x8000, F_SF); in dec_word()
6456 CONDITIONAL_SET_FLAG((res & 0xffff) == 0, F_ZF); in dec_word()
6457 CONDITIONAL_SET_FLAG(PARITY(res & 0xff), F_PF); in dec_word()
6464 CONDITIONAL_SET_FLAG(bc & 0x8, F_AF); in dec_word()
6480 CONDITIONAL_SET_FLAG(res & 0x80000000, F_SF); in dec_long()
6481 CONDITIONAL_SET_FLAG((res & 0xffffffff) == 0, F_ZF); in dec_long()
6482 CONDITIONAL_SET_FLAG(PARITY(res & 0xff), F_PF); in dec_long()
6488 CONDITIONAL_SET_FLAG(bc & 0x8, F_AF); in dec_long()
6503 CONDITIONAL_SET_FLAG((res & 0xff) == 0, F_ZF); in inc_byte()
6504 CONDITIONAL_SET_FLAG(res & 0x80, F_SF); in inc_byte()
6505 CONDITIONAL_SET_FLAG(PARITY(res & 0xff), F_PF); in inc_byte()
6510 CONDITIONAL_SET_FLAG(cc & 0x8, F_AF); in inc_byte()
6525 CONDITIONAL_SET_FLAG((res & 0xffff) == 0, F_ZF); in inc_word()
6526 CONDITIONAL_SET_FLAG(res & 0x8000, F_SF); in inc_word()
6527 CONDITIONAL_SET_FLAG(PARITY(res & 0xff), F_PF); in inc_word()
6532 CONDITIONAL_SET_FLAG(cc & 0x8, F_AF); in inc_word()
6547 CONDITIONAL_SET_FLAG((res & 0xffffffff) == 0, F_ZF); in inc_long()
6548 CONDITIONAL_SET_FLAG(res & 0x80000000, F_SF); in inc_long()
6549 CONDITIONAL_SET_FLAG(PARITY(res & 0xff), F_PF); in inc_long()
6554 CONDITIONAL_SET_FLAG(cc & 0x8, F_AF); in inc_long()
6571 CONDITIONAL_SET_FLAG(res & 0x80, F_SF); in or_byte()
6572 CONDITIONAL_SET_FLAG(res == 0, F_ZF); in or_byte()
6591 CONDITIONAL_SET_FLAG(res & 0x8000, F_SF); in or_word()
6592 CONDITIONAL_SET_FLAG(res == 0, F_ZF); in or_word()
6593 CONDITIONAL_SET_FLAG(PARITY(res & 0xff), F_PF); in or_word()
6612 CONDITIONAL_SET_FLAG(res & 0x80000000, F_SF); in or_long()
6613 CONDITIONAL_SET_FLAG(res == 0, F_ZF); in or_long()
6614 CONDITIONAL_SET_FLAG(PARITY(res & 0xff), F_PF); in or_long()
6628 CONDITIONAL_SET_FLAG(s != 0, F_CF); in neg_byte()
6630 CONDITIONAL_SET_FLAG((res & 0xff) == 0, F_ZF); in neg_byte()
6631 CONDITIONAL_SET_FLAG(res & 0x80, F_SF); in neg_byte()
6633 /* calculate the borrow chain --- modified such that d=0. in neg_byte()
6634 * substitutiing d=0 into bc= res&(~d|s)|(~d&s); (the one used for in neg_byte()
6635 * sub) and simplifying, since ~d=0xff..., ~d|s == 0xffff..., and in neg_byte()
6636 * res&0xfff... == res. Similarly ~d&s == s. So the simplified in neg_byte()
6640 CONDITIONAL_SET_FLAG(bc & 0x8, F_AF); in neg_byte()
6654 CONDITIONAL_SET_FLAG(s != 0, F_CF); in neg_word()
6656 CONDITIONAL_SET_FLAG((res & 0xffff) == 0, F_ZF); in neg_word()
6657 CONDITIONAL_SET_FLAG(res & 0x8000, F_SF); in neg_word()
6658 CONDITIONAL_SET_FLAG(PARITY(res & 0xff), F_PF); in neg_word()
6660 /* calculate the borrow chain --- modified such that d=0. in neg_word()
6661 * substitutiing d=0 into bc= res&(~d|s)|(~d&s); (the one used for in neg_word()
6662 * sub) and simplifying, since ~d=0xff..., ~d|s == 0xffff..., and in neg_word()
6663 * res&0xfff... == res. Similarly ~d&s == s. So the simplified in neg_word()
6667 CONDITIONAL_SET_FLAG(bc & 0x8, F_AF); in neg_word()
6681 CONDITIONAL_SET_FLAG(s != 0, F_CF); in neg_long()
6683 CONDITIONAL_SET_FLAG((res & 0xffffffff) == 0, F_ZF); in neg_long()
6684 CONDITIONAL_SET_FLAG(res & 0x80000000, F_SF); in neg_long()
6685 CONDITIONAL_SET_FLAG(PARITY(res & 0xff), F_PF); in neg_long()
6687 /* calculate the borrow chain --- modified such that d=0. in neg_long()
6688 * substitutiing d=0 into bc= res&(~d|s)|(~d&s); (the one used for in neg_long()
6689 * sub) and simplifying, since ~d=0xff..., ~d|s == 0xffff..., and in neg_long()
6690 * res&0xfff... == res. Similarly ~d&s == s. So the simplified in neg_long()
6694 CONDITIONAL_SET_FLAG(bc & 0x8, F_AF); in neg_long()
6707 /* s is the rotate distance. It varies from 0 - 8. */ in rcl_byte()
6725 * IF n > 0 1) CF <- b_(8-n) 2) B_(7) .. B_(n) <- b_(8-(n+1)) .. b_0 in rcl_byte()
6729 if ((cnt = s % 9) != 0) { in rcl_byte()
6732 cf = (d >> (8 - cnt)) & 0x1; in rcl_byte()
6739 res = (d << cnt) & 0xff; in rcl_byte()
6762 CONDITIONAL_SET_FLAG(cnt == 1 && XOR2(cf + ((res >> 6) & 0x2)), in rcl_byte()
6779 if ((cnt = s % 17) != 0) { in rcl_word()
6780 cf = (d >> (16 - cnt)) & 0x1; in rcl_word()
6781 res = (d << cnt) & 0xffff; in rcl_word()
6788 CONDITIONAL_SET_FLAG(cnt == 1 && XOR2(cf + ((res >> 14) & 0x2)), in rcl_word()
6804 if ((cnt = s % 33) != 0) { in rcl_long()
6805 cf = (d >> (32 - cnt)) & 0x1; in rcl_long()
6806 res = (d << cnt) & 0xffffffff; in rcl_long()
6813 CONDITIONAL_SET_FLAG(cnt == 1 && XOR2(cf + ((res >> 30) & 0x2)), in rcl_long()
6827 uint32_t mask, cf, ocf = 0; in rcr_byte()
6830 /* s is the rotate distance. It varies from 0 - 8. d is the byte in rcr_byte()
6843 * IF n > 0 in rcr_byte()
6845 * 2) B_(8-(n+1)) .. B_(0) <- b_(7) .. b_(n) in rcr_byte()
6846 * 3) B_(8-n) <- cf 4) B_(7) .. B_(8-(n-1)) <- b_(n-2) .. b_(0) in rcr_byte()
6849 if ((cnt = s % 9) != 0) { in rcr_byte()
6853 cf = d & 0x1; in rcr_byte()
6855 * either 0 if flag not set non-zero if flag is set. in rcr_byte()
6856 * doing access_flag(..) != 0 casts that into either in rcr_byte()
6857 * 0..1 in any representation of the flags register in rcr_byte()
6859 ocf = ACCESS_FLAG(F_CF) != 0; in rcr_byte()
6861 cf = (d >> (cnt - 1)) & 0x1; in rcr_byte()
6863 /* B_(8-(n+1)) .. B_(0) <- b_(7) .. b_n */ in rcr_byte()
6874 /* B_(7) .. B_(8-(n-1)) <- b_(n-2) .. b_(0) */ in rcr_byte()
6890 CONDITIONAL_SET_FLAG(XOR2(ocf + ((d >> 6) & 0x2)), in rcr_byte()
6905 uint32_t mask, cf, ocf = 0; in rcr_word()
6909 if ((cnt = s % 17) != 0) { in rcr_word()
6911 cf = d & 0x1; in rcr_word()
6912 ocf = ACCESS_FLAG(F_CF) != 0; in rcr_word()
6914 cf = (d >> (cnt - 1)) & 0x1; in rcr_word()
6923 CONDITIONAL_SET_FLAG(XOR2(ocf + ((d >> 14) & 0x2)), in rcr_word()
6938 uint32_t mask, cf, ocf = 0; in rcr_long()
6942 if ((cnt = s % 33) != 0) { in rcr_long()
6944 cf = d & 0x1; in rcr_long()
6945 ocf = ACCESS_FLAG(F_CF) != 0; in rcr_long()
6947 cf = (d >> (cnt - 1)) & 0x1; in rcr_long()
6957 CONDITIONAL_SET_FLAG(XOR2(ocf + ((d >> 30) & 0x2)), in rcr_long()
6974 /* s is the rotate distance. It varies from 0 - 8. d is the byte in rol_byte()
6984 * IF n > 0 1) B_(7) .. B_(n) <- b_(8-(n+1)) .. b_(0) 2) B_(n-1) .. in rol_byte()
6985 * B_(0) <- b_(7) .. b_(8-n) */ in rol_byte()
6987 if ((cnt = s % 8) != 0) { in rol_byte()
6988 /* B_(7) .. B_(n) <- b_(8-(n+1)) .. b_(0) */ in rol_byte()
6991 /* B_(n-1) .. B_(0) <- b_(7) .. b_(8-n) */ in rol_byte()
6998 XOR2((res & 0x1) + ((res >> 6) & 0x2)), in rol_byte()
7001 if (s != 0) { in rol_byte()
7004 CONDITIONAL_SET_FLAG(res & 0x1, F_CF); in rol_byte()
7019 if ((cnt = s % 16) != 0) { in rol_word()
7024 XOR2((res & 0x1) + ((res >> 14) & 0x2)), in rol_word()
7027 if (s != 0) { in rol_word()
7030 CONDITIONAL_SET_FLAG(res & 0x1, F_CF); in rol_word()
7045 if ((cnt = s % 32) != 0) { in rol_long()
7050 XOR2((res & 0x1) + ((res >> 30) & 0x2)), in rol_long()
7053 if (s != 0) { in rol_long()
7056 CONDITIONAL_SET_FLAG(res & 0x1, F_CF); in rol_long()
7071 /* s is the rotate distance. It varies from 0 - 8. d is the byte in ror_byte()
7080 * IF n > 0 1) B_(8-(n+1)) .. B_(0) <- b_(7) .. b_(n) 2) B_(7) .. in ror_byte()
7081 * B_(8-n) <- b_(n-1) .. b_(0) */ in ror_byte()
7083 if ((cnt = s % 8) != 0) { /* not a typo, do nada if cnt==0 */ in ror_byte()
7084 /* B_(7) .. B_(8-n) <- b_(n-1) .. b_(0) */ in ror_byte()
7087 /* B_(8-(n+1)) .. B_(0) <- b_(7) .. b_(n) */ in ror_byte()
7095 if (s != 0) { in ror_byte()
7098 CONDITIONAL_SET_FLAG(res & 0x80, F_CF); in ror_byte()
7113 if ((cnt = s % 16) != 0) { in ror_word()
7119 if (s != 0) { in ror_word()
7122 CONDITIONAL_SET_FLAG(res & 0x8000, F_CF); in ror_word()
7137 if ((cnt = s % 32) != 0) { in ror_long()
7143 if (s != 0) { in ror_long()
7146 CONDITIONAL_SET_FLAG(res & 0x80000000, F_CF); in ror_long()
7164 if (cnt > 0) { in shl_byte()
7168 CONDITIONAL_SET_FLAG((res & 0xff) == 0, F_ZF); in shl_byte()
7169 CONDITIONAL_SET_FLAG(res & 0x80, F_SF); in shl_byte()
7170 CONDITIONAL_SET_FLAG(PARITY(res & 0xff), F_PF); in shl_byte()
7178 (((res & 0x80) == 0x80) ^ in shl_byte()
7179 (ACCESS_FLAG(F_CF) != 0)), in shl_byte()
7180 /* was (emu->x86.R_FLG&F_CF)==F_CF)), */ in shl_byte()
7186 res = 0; in shl_byte()
7187 CONDITIONAL_SET_FLAG((d << (s - 1)) & 0x80, F_CF); in shl_byte()
7207 if (cnt > 0) { in shl_word()
7211 CONDITIONAL_SET_FLAG((res & 0xffff) == 0, F_ZF); in shl_word()
7212 CONDITIONAL_SET_FLAG(res & 0x8000, F_SF); in shl_word()
7213 CONDITIONAL_SET_FLAG(PARITY(res & 0xff), F_PF); in shl_word()
7220 (((res & 0x8000) == 0x8000) ^ in shl_word()
7221 (ACCESS_FLAG(F_CF) != 0)), in shl_word()
7227 res = 0; in shl_word()
7228 CONDITIONAL_SET_FLAG((d << (s - 1)) & 0x8000, F_CF); in shl_word()
7248 if (cnt > 0) { in shl_long()
7252 CONDITIONAL_SET_FLAG((res & 0xffffffff) == 0, F_ZF); in shl_long()
7253 CONDITIONAL_SET_FLAG(res & 0x80000000, F_SF); in shl_long()
7254 CONDITIONAL_SET_FLAG(PARITY(res & 0xff), F_PF); in shl_long()
7259 CONDITIONAL_SET_FLAG((((res & 0x80000000) == 0x80000000) in shl_long()
7260 ^ (ACCESS_FLAG(F_CF) != 0)), F_OF); in shl_long()
7265 res = 0; in shl_long()
7266 CONDITIONAL_SET_FLAG((d << (s - 1)) & 0x80000000, F_CF); in shl_long()
7286 if (cnt > 0) { in shr_byte()
7290 CONDITIONAL_SET_FLAG((res & 0xff) == 0, F_ZF); in shr_byte()
7291 CONDITIONAL_SET_FLAG(res & 0x80, F_SF); in shr_byte()
7292 CONDITIONAL_SET_FLAG(PARITY(res & 0xff), F_PF); in shr_byte()
7303 res = 0; in shr_byte()
7304 CONDITIONAL_SET_FLAG((d >> (s - 1)) & 0x1, F_CF); in shr_byte()
7324 if (cnt > 0) { in shr_word()
7328 CONDITIONAL_SET_FLAG((res & 0xffff) == 0, F_ZF); in shr_word()
7329 CONDITIONAL_SET_FLAG(res & 0x8000, F_SF); in shr_word()
7330 CONDITIONAL_SET_FLAG(PARITY(res & 0xff), F_PF); in shr_word()
7341 res = 0; in shr_word()
7362 if (cnt > 0) { in shr_long()
7366 CONDITIONAL_SET_FLAG((res & 0xffffffff) == 0, F_ZF); in shr_long()
7367 CONDITIONAL_SET_FLAG(res & 0x80000000, F_SF); in shr_long()
7368 CONDITIONAL_SET_FLAG(PARITY(res & 0xff), F_PF); in shr_long()
7378 res = 0; in shr_long()
7398 sf = d & 0x80; in sar_byte()
7400 if (cnt > 0 && cnt < 8) { in sar_byte()
7408 CONDITIONAL_SET_FLAG((res & 0xff) == 0, F_ZF); in sar_byte()
7409 CONDITIONAL_SET_FLAG(PARITY(res & 0xff), F_PF); in sar_byte()
7410 CONDITIONAL_SET_FLAG(res & 0x80, F_SF); in sar_byte()
7413 res = 0xff; in sar_byte()
7419 res = 0; in sar_byte()
7438 sf = d & 0x8000; in sar_word()
7441 if (cnt > 0 && cnt < 16) { in sar_word()
7449 CONDITIONAL_SET_FLAG((res & 0xffff) == 0, F_ZF); in sar_word()
7450 CONDITIONAL_SET_FLAG(res & 0x8000, F_SF); in sar_word()
7451 CONDITIONAL_SET_FLAG(PARITY(res & 0xff), F_PF); in sar_word()
7454 res = 0xffff; in sar_word()
7460 res = 0; in sar_word()
7479 sf = d & 0x80000000; in sar_long()
7482 if (cnt > 0 && cnt < 32) { in sar_long()
7490 CONDITIONAL_SET_FLAG((res & 0xffffffff) == 0, F_ZF); in sar_long()
7491 CONDITIONAL_SET_FLAG(res & 0x80000000, F_SF); in sar_long()
7492 CONDITIONAL_SET_FLAG(PARITY(res & 0xff), F_PF); in sar_long()
7495 res = 0xffffffff; in sar_long()
7501 res = 0; in sar_long()
7522 if (cnt > 0) { in shld_word()
7526 CONDITIONAL_SET_FLAG((res & 0xffff) == 0, F_ZF); in shld_word()
7527 CONDITIONAL_SET_FLAG(res & 0x8000, F_SF); in shld_word()
7528 CONDITIONAL_SET_FLAG(PARITY(res & 0xff), F_PF); in shld_word()
7533 CONDITIONAL_SET_FLAG((((res & 0x8000) == 0x8000) ^ in shld_word()
7534 (ACCESS_FLAG(F_CF) != 0)), F_OF); in shld_word()
7539 res = 0; in shld_word()
7540 CONDITIONAL_SET_FLAG((d << (s - 1)) & 0x8000, F_CF); in shld_word()
7560 if (cnt > 0) { in shld_long()
7564 CONDITIONAL_SET_FLAG((res & 0xffffffff) == 0, F_ZF); in shld_long()
7565 CONDITIONAL_SET_FLAG(res & 0x80000000, F_SF); in shld_long()
7566 CONDITIONAL_SET_FLAG(PARITY(res & 0xff), F_PF); in shld_long()
7571 CONDITIONAL_SET_FLAG((((res & 0x80000000) == 0x80000000) in shld_long()
7572 ^ (ACCESS_FLAG(F_CF) != 0)), F_OF); in shld_long()
7577 res = 0; in shld_long()
7578 CONDITIONAL_SET_FLAG((d << (s - 1)) & 0x80000000, F_CF); in shld_long()
7598 if (cnt > 0) { in shrd_word()
7602 CONDITIONAL_SET_FLAG((res & 0xffff) == 0, F_ZF); in shrd_word()
7603 CONDITIONAL_SET_FLAG(res & 0x8000, F_SF); in shrd_word()
7604 CONDITIONAL_SET_FLAG(PARITY(res & 0xff), F_PF); in shrd_word()
7615 res = 0; in shrd_word()
7636 if (cnt > 0) { in shrd_long()
7640 CONDITIONAL_SET_FLAG((res & 0xffffffff) == 0, F_ZF); in shrd_long()
7641 CONDITIONAL_SET_FLAG(res & 0x80000000, F_SF); in shrd_long()
7642 CONDITIONAL_SET_FLAG(PARITY(res & 0xff), F_PF); in shrd_long()
7652 res = 0; in shrd_long()
7676 CONDITIONAL_SET_FLAG(res & 0x80, F_SF); in sbb_byte()
7677 CONDITIONAL_SET_FLAG((res & 0xff) == 0, F_ZF); in sbb_byte()
7678 CONDITIONAL_SET_FLAG(PARITY(res & 0xff), F_PF); in sbb_byte()
7682 CONDITIONAL_SET_FLAG(bc & 0x80, F_CF); in sbb_byte()
7684 CONDITIONAL_SET_FLAG(bc & 0x8, F_AF); in sbb_byte()
7702 CONDITIONAL_SET_FLAG(res & 0x8000, F_SF); in sbb_word()
7703 CONDITIONAL_SET_FLAG((res & 0xffff) == 0, F_ZF); in sbb_word()
7704 CONDITIONAL_SET_FLAG(PARITY(res & 0xff), F_PF); in sbb_word()
7708 CONDITIONAL_SET_FLAG(bc & 0x8000, F_CF); in sbb_word()
7710 CONDITIONAL_SET_FLAG(bc & 0x8, F_AF); in sbb_word()
7728 CONDITIONAL_SET_FLAG(res & 0x80000000, F_SF); in sbb_long()
7729 CONDITIONAL_SET_FLAG((res & 0xffffffff) == 0, F_ZF); in sbb_long()
7730 CONDITIONAL_SET_FLAG(PARITY(res & 0xff), F_PF); in sbb_long()
7734 CONDITIONAL_SET_FLAG(bc & 0x80000000, F_CF); in sbb_long()
7736 CONDITIONAL_SET_FLAG(bc & 0x8, F_AF); in sbb_long()
7751 CONDITIONAL_SET_FLAG(res & 0x80, F_SF); in sub_byte()
7752 CONDITIONAL_SET_FLAG((res & 0xff) == 0, F_ZF); in sub_byte()
7753 CONDITIONAL_SET_FLAG(PARITY(res & 0xff), F_PF); in sub_byte()
7757 CONDITIONAL_SET_FLAG(bc & 0x80, F_CF); in sub_byte()
7759 CONDITIONAL_SET_FLAG(bc & 0x8, F_AF); in sub_byte()
7774 CONDITIONAL_SET_FLAG(res & 0x8000, F_SF); in sub_word()
7775 CONDITIONAL_SET_FLAG((res & 0xffff) == 0, F_ZF); in sub_word()
7776 CONDITIONAL_SET_FLAG(PARITY(res & 0xff), F_PF); in sub_word()
7780 CONDITIONAL_SET_FLAG(bc & 0x8000, F_CF); in sub_word()
7782 CONDITIONAL_SET_FLAG(bc & 0x8, F_AF); in sub_word()
7797 CONDITIONAL_SET_FLAG(res & 0x80000000, F_SF); in sub_long()
7798 CONDITIONAL_SET_FLAG((res & 0xffffffff) == 0, F_ZF); in sub_long()
7799 CONDITIONAL_SET_FLAG(PARITY(res & 0xff), F_PF); in sub_long()
7803 CONDITIONAL_SET_FLAG(bc & 0x80000000, F_CF); in sub_long()
7805 CONDITIONAL_SET_FLAG(bc & 0x8, F_AF); in sub_long()
7821 CONDITIONAL_SET_FLAG(res & 0x80, F_SF); in test_byte()
7822 CONDITIONAL_SET_FLAG(res == 0, F_ZF); in test_byte()
7823 CONDITIONAL_SET_FLAG(PARITY(res & 0xff), F_PF); in test_byte()
7840 CONDITIONAL_SET_FLAG(res & 0x8000, F_SF); in test_word()
7841 CONDITIONAL_SET_FLAG(res == 0, F_ZF); in test_word()
7842 CONDITIONAL_SET_FLAG(PARITY(res & 0xff), F_PF); in test_word()
7859 CONDITIONAL_SET_FLAG(res & 0x80000000, F_SF); in test_long()
7860 CONDITIONAL_SET_FLAG(res == 0, F_ZF); in test_long()
7861 CONDITIONAL_SET_FLAG(PARITY(res & 0xff), F_PF); in test_long()
7877 CONDITIONAL_SET_FLAG(res & 0x80, F_SF); in xor_byte()
7878 CONDITIONAL_SET_FLAG(res == 0, F_ZF); in xor_byte()
7896 CONDITIONAL_SET_FLAG(res & 0x8000, F_SF); in xor_word()
7897 CONDITIONAL_SET_FLAG(res == 0, F_ZF); in xor_word()
7898 CONDITIONAL_SET_FLAG(PARITY(res & 0xff), F_PF); in xor_word()
7915 CONDITIONAL_SET_FLAG(res & 0x80000000, F_SF); in xor_long()
7916 CONDITIONAL_SET_FLAG(res == 0, F_ZF); in xor_long()
7917 CONDITIONAL_SET_FLAG(PARITY(res & 0xff), F_PF); in xor_long()
7930 int16_t res = (int16_t) ((int8_t) emu->x86.R_AL * (int8_t) s); in imul_byte()
7932 emu->x86.R_AX = res; in imul_byte()
7933 if (((emu->x86.R_AL & 0x80) == 0 && emu->x86.R_AH == 0x00) || in imul_byte()
7934 ((emu->x86.R_AL & 0x80) != 0 && emu->x86.R_AH == 0xFF)) { in imul_byte()
7950 int32_t res = (int16_t) emu->x86.R_AX * (int16_t) s; in imul_word()
7952 emu->x86.R_AX = (uint16_t) res; in imul_word()
7953 emu->x86.R_DX = (uint16_t) (res >> 16); in imul_word()
7954 if (((emu->x86.R_AX & 0x8000) == 0 && emu->x86.R_DX == 0x00) || in imul_word()
7955 ((emu->x86.R_AX & 0x8000) != 0 && emu->x86.R_DX == 0xFF)) { in imul_word()
7973 res = (int64_t)(int32_t)emu->x86.R_EAX * (int32_t)s; in imul_long()
7974 emu->x86.R_EAX = (uint32_t)res; in imul_long()
7975 emu->x86.R_EDX = ((uint64_t)res) >> 32; in imul_long()
7976 if (((emu->x86.R_EAX & 0x80000000) == 0 && emu->x86.R_EDX == 0x00) || in imul_long()
7977 ((emu->x86.R_EAX & 0x80000000) != 0 && emu->x86.R_EDX == 0xFF)) { in imul_long()
7993 uint16_t res = (uint16_t) (emu->x86.R_AL * s); in mul_byte()
7995 emu->x86.R_AX = res; in mul_byte()
7996 if (emu->x86.R_AH == 0) { in mul_byte()
8012 uint32_t res = emu->x86.R_AX * s; in mul_word()
8014 emu->x86.R_AX = (uint16_t) res; in mul_word()
8015 emu->x86.R_DX = (uint16_t) (res >> 16); in mul_word()
8016 if (emu->x86.R_DX == 0) { in mul_word()
8032 uint64_t res = (uint64_t) emu->x86.R_EAX * s; in mul_long()
8034 emu->x86.R_EAX = (uint32_t) res; in mul_long()
8035 emu->x86.R_EDX = (uint32_t) (res >> 32); in mul_long()
8037 if (emu->x86.R_EDX == 0) { in mul_long()
8055 dvd = (int16_t) emu->x86.R_AX; in idiv_byte()
8056 if (s == 0) { in idiv_byte()
8062 if (div > 0x7f || div < -0x7f) { in idiv_byte()
8066 emu->x86.R_AL = (int8_t) div; in idiv_byte()
8067 emu->x86.R_AH = (int8_t) mod; in idiv_byte()
8079 dvd = (((int32_t) emu->x86.R_DX) << 16) | emu->x86.R_AX; in idiv_word()
8080 if (s == 0) { in idiv_word()
8086 if (div > 0x7fff || div < -0x7fff) { in idiv_word()
8092 CONDITIONAL_SET_FLAG(div == 0, F_ZF); in idiv_word()
8093 CONDITIONAL_SET_FLAG(PARITY(mod & 0xff), F_PF); in idiv_word()
8095 emu->x86.R_AX = (uint16_t) div; in idiv_word()
8096 emu->x86.R_DX = (uint16_t) mod; in idiv_word()
8108 dvd = (((int64_t) emu->x86.R_EDX) << 32) | emu->x86.R_EAX; in idiv_long()
8109 if (s == 0) { in idiv_long()
8115 if (div > 0x7fffffff || div < -0x7fffffff) { in idiv_long()
8123 CONDITIONAL_SET_FLAG(PARITY(mod & 0xff), F_PF); in idiv_long()
8125 emu->x86.R_EAX = (uint32_t) div; in idiv_long()
8126 emu->x86.R_EDX = (uint32_t) mod; in idiv_long()
8138 dvd = emu->x86.R_AX; in div_byte()
8139 if (s == 0) { in div_byte()
8145 if (div > 0xff) { in div_byte()
8149 emu->x86.R_AL = (uint8_t) div; in div_byte()
8150 emu->x86.R_AH = (uint8_t) mod; in div_byte()
8162 dvd = (((uint32_t) emu->x86.R_DX) << 16) | emu->x86.R_AX; in div_word()
8163 if (s == 0) { in div_word()
8169 if (div > 0xffff) { in div_word()
8175 CONDITIONAL_SET_FLAG(div == 0, F_ZF); in div_word()
8176 CONDITIONAL_SET_FLAG(PARITY(mod & 0xff), F_PF); in div_word()
8178 emu->x86.R_AX = (uint16_t) div; in div_word()
8179 emu->x86.R_DX = (uint16_t) mod; in div_word()
8191 dvd = (((uint64_t) emu->x86.R_EDX) << 32) | emu->x86.R_EAX; in div_long()
8192 if (s == 0) { in div_long()
8198 if (div > 0xffffffff) { in div_long()
8206 CONDITIONAL_SET_FLAG(PARITY(mod & 0xff), F_PF); in div_long()
8208 emu->x86.R_EAX = (uint32_t) div; in div_long()
8209 emu->x86.R_EDX = (uint32_t) mod; in div_long()
8224 if (emu->x86.mode & (SYSMODE_PREFIX_REPE | SYSMODE_PREFIX_REPNE)) { in ins()
8227 uint32_t count = ((emu->x86.mode & SYSMODE_PREFIX_DATA) ? in ins()
8228 emu->x86.R_ECX : emu->x86.R_CX); in ins()
8232 store_byte(emu, emu->x86.R_ES, emu->x86.R_DI, in ins()
8233 (*emu->emu_inb) (emu, emu->x86.R_DX)); in ins()
8234 emu->x86.R_DI += inc; in ins()
8240 store_word(emu, emu->x86.R_ES, emu->x86.R_DI, in ins()
8241 (*emu->emu_inw) (emu, emu->x86.R_DX)); in ins()
8242 emu->x86.R_DI += inc; in ins()
8247 store_long(emu, emu->x86.R_ES, emu->x86.R_DI, in ins()
8248 (*emu->emu_inl) (emu, emu->x86.R_DX)); in ins()
8249 emu->x86.R_DI += inc; in ins()
8253 emu->x86.R_CX = 0; in ins()
8254 if (emu->x86.mode & SYSMODE_PREFIX_DATA) { in ins()
8255 emu->x86.R_ECX = 0; in ins()
8257 emu->x86.mode &= ~(SYSMODE_PREFIX_REPE | SYSMODE_PREFIX_REPNE); in ins()
8261 store_byte(emu, emu->x86.R_ES, emu->x86.R_DI, in ins()
8262 (*emu->emu_inb) (emu, emu->x86.R_DX)); in ins()
8265 store_word(emu, emu->x86.R_ES, emu->x86.R_DI, in ins()
8266 (*emu->emu_inw) (emu, emu->x86.R_DX)); in ins()
8269 store_long(emu, emu->x86.R_ES, emu->x86.R_DI, in ins()
8270 (*emu->emu_inl) (emu, emu->x86.R_DX)); in ins()
8273 emu->x86.R_DI += inc; in ins()
8289 if (emu->x86.mode & (SYSMODE_PREFIX_REPE | SYSMODE_PREFIX_REPNE)) { in outs()
8292 uint32_t count = ((emu->x86.mode & SYSMODE_PREFIX_DATA) ? in outs()
8293 emu->x86.R_ECX : emu->x86.R_CX); in outs()
8297 (*emu->emu_outb) (emu, emu->x86.R_DX, in outs()
8298 fetch_byte(emu, emu->x86.R_ES, in outs()
8299 emu->x86.R_SI)); in outs()
8300 emu->x86.R_SI += inc; in outs()
8306 (*emu->emu_outw) (emu, emu->x86.R_DX, in outs()
8307 fetch_word(emu, emu->x86.R_ES, in outs()
8308 emu->x86.R_SI)); in outs()
8309 emu->x86.R_SI += inc; in outs()
8314 (*emu->emu_outl) (emu, emu->x86.R_DX, in outs()
8315 fetch_long(emu, emu->x86.R_ES, in outs()
8316 emu->x86.R_SI)); in outs()
8317 emu->x86.R_SI += inc; in outs()
8321 emu->x86.R_CX = 0; in outs()
8322 if (emu->x86.mode & SYSMODE_PREFIX_DATA) { in outs()
8323 emu->x86.R_ECX = 0; in outs()
8325 emu->x86.mode &= ~(SYSMODE_PREFIX_REPE | SYSMODE_PREFIX_REPNE); in outs()
8329 (*emu->emu_outb) (emu, emu->x86.R_DX, in outs()
8330 fetch_byte(emu, emu->x86.R_ES, emu->x86.R_SI)); in outs()
8333 (*emu->emu_outw) (emu, emu->x86.R_DX, in outs()
8334 fetch_word(emu, emu->x86.R_ES, emu->x86.R_SI)); in outs()
8337 (*emu->emu_outl) (emu, emu->x86.R_DX, in outs()
8338 fetch_long(emu, emu->x86.R_ES, emu->x86.R_SI)); in outs()
8341 emu->x86.R_SI += inc; in outs()
8354 emu->x86.R_SP -= 2; in push_word()
8355 store_word(emu, emu->x86.R_SS, emu->x86.R_SP, w); in push_word()
8367 emu->x86.R_SP -= 4; in push_long()
8368 store_long(emu, emu->x86.R_SS, emu->x86.R_SP, w); in push_long()
8382 res = fetch_word(emu, emu->x86.R_SS, emu->x86.R_SP); in pop_word()
8383 emu->x86.R_SP += 2; in pop_word()
8398 res = fetch_long(emu, emu->x86.R_SS, emu->x86.R_SP); in pop_long()
8399 emu->x86.R_SP += 4; in pop_long()