Lines Matching 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()
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()
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()
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()
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()
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()
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()
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()
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()
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()
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()
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()
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()
883 if (emu->x86.mode & SYSMODE_PREFIX_ADDR) { 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()
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()
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()
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()
1003 if ((emu->x86.mode & SYSMODE_PREFIX_ADDR) == 0) in decode_and_fetch_long_disp()
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()
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()
1506 if (emu->x86.mode & SYSMODE_PREFIX_DATA) in x86emuOp_cmp_word_R_RM()
1522 cmp_byte(emu, emu->x86.R_AL, srcval); in x86emuOp_cmp_byte_AL_IMM()
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()
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()
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()
1626 if (emu->x86.mode & SYSMODE_PREFIX_DATA) { in x86emuOp_push_word_IMM()
1649 if (emu->x86.mode & SYSMODE_PREFIX_DATA) { in x86emuOp_push_byte_IMM()
1663 if (emu->x86.mode & SYSMODE_PREFIX_DATA) { in x86emuOp_ins_word()
1677 if (emu->x86.mode & SYSMODE_PREFIX_DATA) { in x86emuOp_outs_word()
1850 if (emu->x86.mode & SYSMODE_PREFIX_DATA) in x86emuOp_opc81_word_RM_IMM()
1954 if (emu->x86.mode & SYSMODE_PREFIX_DATA) in x86emuOp_opc83_word_RM_IMM()
1962 * Handles opcode 0x86
2013 if (emu->x86.mode & SYSMODE_PREFIX_DATA) in x86emuOp_xchg_word_RM_R()
2081 if (emu->x86.mode & SYSMODE_PREFIX_DATA) in x86emuOp_mov_word_RM_R()
2108 if (emu->x86.mode & SYSMODE_PREFIX_DATA) { in x86emuOp_mov_word_R_RM()
2158 if (emu->x86.mode & SYSMODE_PREFIX_ADDR) { in x86emuOp_lea_word_R_M()
2232 if (emu->x86.mode & SYSMODE_PREFIX_DATA) in x86emuOp_pop_RM()
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()
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()
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()
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()
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()
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()
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()
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()
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()
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()
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()
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()
2484 emu->x86.R_FLG &= 0xffffff00; in x86emuOp_sahf()
2486 emu->x86.R_FLG |= emu->x86.R_AH; in x86emuOp_sahf()
2496 emu->x86.R_AH = (uint8_t) (emu->x86.R_FLG & 0xff); in x86emuOp_lahf()
2499 emu->x86.R_AH |= 0x2; in x86emuOp_lahf()
2512 emu->x86.R_AL = fetch_data_byte(emu, offset); in x86emuOp_mov_AL_M_IMM()
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()
2542 store_data_byte(emu, offset, emu->x86.R_AL); in x86emuOp_mov_M_AL_IMM()
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()
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()
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()
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()
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()
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()
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()
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()
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()
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()
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()
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()
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()
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()
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()
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()
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()
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()
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()
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()
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()
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()
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()
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()
3206 if (emu->x86.mode & SYSMODE_PREFIX_DATA) { in x86emuOp_opcC1_word_RM_MEM()
3233 emu->x86.R_IP = pop_word(emu); in x86emuOp_ret_near_IMM()
3234 emu->x86.R_SP += imm; in x86emuOp_ret_near_IMM()
3311 if (emu->x86.mode & SYSMODE_PREFIX_DATA) in x86emuOp_mov_word_RM_IMM()
3330 push_word(emu, emu->x86.R_BP); in x86emuOp_enter()
3331 frame_pointer = emu->x86.R_SP; 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()
3351 emu->x86.R_SP = emu->x86.R_BP; in x86emuOp_leave()
3352 emu->x86.R_BP = pop_word(emu); in x86emuOp_leave()
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()
3377 emu->x86.R_IP = pop_word(emu); in x86emuOp_ret_far()
3378 emu->x86.R_CS = pop_word(emu); in x86emuOp_ret_far()
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()
3449 if (emu->x86.mode & SYSMODE_PREFIX_DATA) { in x86emuOp_opcD1_word_RM_1()
3478 (emu, destval, emu->x86.R_CL); in x86emuOp_opcD2_byte_RM_CL()
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()
3523 emu->x86.R_AX = aam_word(emu, emu->x86.R_AL); in x86emuOp_aam()
3540 emu->x86.R_AX = aad_word(emu, emu->x86.R_AX); in x86emuOp_aad()
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()
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()
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()
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()
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()
3696 emu->x86.R_AL = (*emu->emu_inb) (emu, port); in x86emuOp_in_byte_AL_IMM()
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()
3726 (*emu->emu_outb) (emu, port, emu->x86.R_AL); in x86emuOp_out_byte_IMM_AL()
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()
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()
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()
3793 emu->x86.R_IP = ip; in x86emuOp_jump_far_IMM()
3794 emu->x86.R_CS = cs; in x86emuOp_jump_far_IMM()
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()
3819 emu->x86.R_AL = (*emu->emu_inb) (emu, emu->x86.R_DX); in x86emuOp_in_byte_AL_DX()
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()
3843 (*emu->emu_outb) (emu, emu->x86.R_DX, emu->x86.R_AL); in x86emuOp_out_byte_DX_AL()
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()
4034 if (emu->x86.mode & SYSMODE_PREFIX_DATA) in x86emuOp_opcF7_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()
4242 push_word(emu, emu->x86.R_ES); in x86emu_exec_one_byte()
4245 emu->x86.R_ES = pop_word(emu); in x86emu_exec_one_byte()
4267 push_word(emu, emu->x86.R_CS); in x86emu_exec_one_byte()
4292 push_word(emu, emu->x86.R_SS); in x86emu_exec_one_byte()
4295 emu->x86.R_SS = pop_word(emu); in x86emu_exec_one_byte()
4317 push_word(emu, emu->x86.R_DS); in x86emu_exec_one_byte()
4320 emu->x86.R_DS = pop_word(emu); in x86emu_exec_one_byte()
4342 emu->x86.mode |= SYSMODE_SEGOVR_ES; in x86emu_exec_one_byte()
4345 emu->x86.R_AL = daa_byte(emu, emu->x86.R_AL); in x86emu_exec_one_byte()
4367 emu->x86.mode |= SYSMODE_SEGOVR_CS; in x86emu_exec_one_byte()
4370 emu->x86.R_AL = das_byte(emu, emu->x86.R_AL); in x86emu_exec_one_byte()
4392 emu->x86.mode |= SYSMODE_SEGOVR_SS; in x86emu_exec_one_byte()
4395 emu->x86.R_AX = aaa_word(emu, emu->x86.R_AX); in x86emu_exec_one_byte()
4418 emu->x86.mode |= SYSMODE_SEGOVR_DS; in x86emu_exec_one_byte()
4421 emu->x86.R_AX = aas_word(emu, emu->x86.R_AX); in x86emu_exec_one_byte()
4425 common_inc_word_long(emu, &emu->x86.register_a); in x86emu_exec_one_byte()
4428 common_inc_word_long(emu, &emu->x86.register_c); in x86emu_exec_one_byte()
4431 common_inc_word_long(emu, &emu->x86.register_d); in x86emu_exec_one_byte()
4434 common_inc_word_long(emu, &emu->x86.register_b); in x86emu_exec_one_byte()
4437 common_inc_word_long(emu, &emu->x86.register_sp); in x86emu_exec_one_byte()
4440 common_inc_word_long(emu, &emu->x86.register_bp); in x86emu_exec_one_byte()
4443 common_inc_word_long(emu, &emu->x86.register_si); in x86emu_exec_one_byte()
4446 common_inc_word_long(emu, &emu->x86.register_di); in x86emu_exec_one_byte()
4450 common_dec_word_long(emu, &emu->x86.register_a); in x86emu_exec_one_byte()
4453 common_dec_word_long(emu, &emu->x86.register_c); in x86emu_exec_one_byte()
4456 common_dec_word_long(emu, &emu->x86.register_d); in x86emu_exec_one_byte()
4459 common_dec_word_long(emu, &emu->x86.register_b); in x86emu_exec_one_byte()
4462 common_dec_word_long(emu, &emu->x86.register_sp); in x86emu_exec_one_byte()
4465 common_dec_word_long(emu, &emu->x86.register_bp); in x86emu_exec_one_byte()
4468 common_dec_word_long(emu, &emu->x86.register_si); in x86emu_exec_one_byte()
4471 common_dec_word_long(emu, &emu->x86.register_di); in x86emu_exec_one_byte()
4475 common_push_word_long(emu, &emu->x86.register_a); in x86emu_exec_one_byte()
4478 common_push_word_long(emu, &emu->x86.register_c); in x86emu_exec_one_byte()
4481 common_push_word_long(emu, &emu->x86.register_d); in x86emu_exec_one_byte()
4484 common_push_word_long(emu, &emu->x86.register_b); in x86emu_exec_one_byte()
4487 common_push_word_long(emu, &emu->x86.register_sp); in x86emu_exec_one_byte()
4490 common_push_word_long(emu, &emu->x86.register_bp); in x86emu_exec_one_byte()
4493 common_push_word_long(emu, &emu->x86.register_si); in x86emu_exec_one_byte()
4496 common_push_word_long(emu, &emu->x86.register_di); in x86emu_exec_one_byte()
4500 common_pop_word_long(emu, &emu->x86.register_a); in x86emu_exec_one_byte()
4503 common_pop_word_long(emu, &emu->x86.register_c); in x86emu_exec_one_byte()
4506 common_pop_word_long(emu, &emu->x86.register_d); in x86emu_exec_one_byte()
4509 common_pop_word_long(emu, &emu->x86.register_b); in x86emu_exec_one_byte()
4512 common_pop_word_long(emu, &emu->x86.register_sp); in x86emu_exec_one_byte()
4515 common_pop_word_long(emu, &emu->x86.register_bp); in x86emu_exec_one_byte()
4518 common_pop_word_long(emu, &emu->x86.register_si); in x86emu_exec_one_byte()
4521 common_pop_word_long(emu, &emu->x86.register_di); in x86emu_exec_one_byte()
4533 emu->x86.mode |= SYSMODE_SEGOVR_FS; in x86emu_exec_one_byte()
4536 emu->x86.mode |= SYSMODE_SEGOVR_GS; in x86emu_exec_one_byte()
4539 emu->x86.mode |= SYSMODE_PREFIX_DATA; in x86emu_exec_one_byte()
4542 emu->x86.mode |= SYSMODE_PREFIX_ADDR; in x86emu_exec_one_byte()
4638 case 0x86: in x86emu_exec_one_byte()
4746 test_byte(emu, emu->x86.R_AL, fetch_byte_imm(emu)); in x86emu_exec_one_byte()
4771 emu->x86.R_AL = fetch_byte_imm(emu); in x86emu_exec_one_byte()
4774 emu->x86.R_CL = fetch_byte_imm(emu); in x86emu_exec_one_byte()
4777 emu->x86.R_DL = fetch_byte_imm(emu); in x86emu_exec_one_byte()
4780 emu->x86.R_BL = fetch_byte_imm(emu); in x86emu_exec_one_byte()
4783 emu->x86.R_AH = fetch_byte_imm(emu); in x86emu_exec_one_byte()
4786 emu->x86.R_CH = fetch_byte_imm(emu); in x86emu_exec_one_byte()
4789 emu->x86.R_DH = fetch_byte_imm(emu); in x86emu_exec_one_byte()
4792 emu->x86.R_BH = fetch_byte_imm(emu); in x86emu_exec_one_byte()
4831 emu->x86.R_IP = pop_word(emu); in x86emu_exec_one_byte()
4834 common_load_far_pointer(emu, &emu->x86.R_ES); in x86emu_exec_one_byte()
4837 common_load_far_pointer(emu, &emu->x86.R_DS); in x86emu_exec_one_byte()
4971 emu->x86.mode |= SYSMODE_PREFIX_REPNE; in x86emu_exec_one_byte()
4974 emu->x86.mode |= SYSMODE_PREFIX_REPE; 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()
5109 if (emu->x86.mode & SYSMODE_PREFIX_DATA) in common_bitstring()
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()
5218 emu->x86.R_EAX = emu->cur_cycles & 0xffffffff; in x86emuOp2_rdtsc()
5219 emu->x86.R_EDX = emu->cur_cycles >> 32; in x86emuOp2_rdtsc()
5229 push_word(emu, emu->x86.R_FS); in x86emuOp2_push_FS()
5239 emu->x86.R_FS = pop_word(emu); in x86emuOp2_pop_FS()
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()
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()
5327 push_word(emu, emu->x86.R_GS); in x86emuOp2_push_GS()
5337 emu->x86.R_GS = pop_word(emu); in x86emuOp2_pop_GS()
5417 if (emu->x86.mode & SYSMODE_PREFIX_DATA) in x86emuOp2_imul_R_RM()
5430 common_load_far_pointer(emu, &emu->x86.R_SS); in x86emuOp2_lss_R_IMM()
5450 common_load_far_pointer(emu, &emu->x86.R_FS); in x86emuOp2_lfs_R_IMM()
5460 common_load_far_pointer(emu, &emu->x86.R_GS); in x86emuOp2_lgs_R_IMM()
5490 if (emu->x86.mode & SYSMODE_PREFIX_DATA) in x86emuOp2_movzx_byte_R_RM()
5575 if (emu->x86.mode & SYSMODE_PREFIX_DATA) in x86emuOp2_btX_I()
5638 if (emu->x86.mode & SYSMODE_PREFIX_DATA) in x86emuOp2_movsx_byte_R_RM()
5705 case 0x86: in x86emu_exec_two_byte()
7180 /* was (emu->x86.R_FLG&F_CF)==F_CF)), */ in shl_byte()
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()
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()
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()
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()
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()
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()
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()