#include <stdint.h>#include <stdio.h>#include "emu/emu_cpu.h"#include "emu/emu_cpu_data.h"#include "emu/emu_memory.h"
Defines | |
| #define | INSTR_CALC(bits, a, b, c, operation, cpu) |
| #define | INSTR_SET_FLAG_OF(cpu, operand, bits) |
| #define | INSTR_SET_FLAG_CF(cpu, operand) |
| #define | INSTR_CALC_AND_SET_FLAGS(bits, cpu, a, b, c, operation) |
| #define | TRACK_INIT_ALL_FLAGS(instruction_p) |
Functions | |
| int32_t | instr_adc_10 (struct emu_cpu *c, struct emu_cpu_instruction *i) |
| int32_t | instr_adc_11 (struct emu_cpu *c, struct emu_cpu_instruction *i) |
| int32_t | instr_adc_12 (struct emu_cpu *c, struct emu_cpu_instruction *i) |
| int32_t | instr_adc_13 (struct emu_cpu *c, struct emu_cpu_instruction *i) |
| int32_t | instr_adc_14 (struct emu_cpu *c, struct emu_cpu_instruction *i) |
| int32_t | instr_adc_15 (struct emu_cpu *c, struct emu_cpu_instruction *i) |
| int32_t | instr_group_1_80_adc (struct emu_cpu *c, struct emu_cpu_instruction *i) |
| int32_t | instr_group_1_81_adc (struct emu_cpu *c, struct emu_cpu_instruction *i) |
| int32_t | instr_group_1_83_adc (struct emu_cpu *c, struct emu_cpu_instruction *i) |
| #define INSTR_CALC | ( | bits, | |||
| a, | |||||
| b, | |||||
| c, | |||||
| operation, | |||||
| cpu | ) |
UINTOF(bits) operand_a; \ UINTOF(bits) operand_b; \ bcopy(&(a), &operand_a, bits/8); \ bcopy(&(b), &operand_b, bits/8); \ UINTOF(bits) operation_result = operand_a operation operand_b operation ((cpu->eflags & (1 << f_cf))?1:0); \ bcopy(&operation_result, &(c), bits/8);
Referenced by instr_group_3_f6_div(), instr_group_3_f6_idiv(), instr_group_3_f6_imul(), instr_group_3_f6_mul(), instr_group_3_f7_div(), instr_group_3_f7_idiv(), instr_group_3_f7_imul(), instr_group_3_f7_mul(), instr_imul_0f_af(), instr_imul_69(), and instr_imul_6b().
| #define INSTR_CALC_AND_SET_FLAGS | ( | bits, | |||
| cpu, | |||||
| a, | |||||
| b, | |||||
| c, | |||||
| operation | ) |
INSTR_CALC(bits, a, b, c, operation, cpu) \ INSTR_SET_FLAG_ZF(cpu) \ INSTR_SET_FLAG_PF(cpu) \ INSTR_SET_FLAG_SF(cpu) \ INSTR_SET_FLAG_OF(cpu, operation, bits) \ INSTR_SET_FLAG_CF(cpu, operation)
Referenced by instr_adc_10(), instr_adc_11(), instr_adc_12(), instr_adc_13(), instr_adc_14(), instr_adc_15(), instr_add_00(), instr_add_01(), instr_add_02(), instr_add_03(), instr_add_04(), instr_add_05(), instr_and_20(), instr_and_21(), instr_and_22(), instr_and_23(), instr_and_24(), instr_and_25(), instr_cmp_38(), instr_cmp_39(), instr_cmp_3a(), instr_cmp_3b(), instr_cmp_3c(), instr_cmp_3d(), instr_cmps_a6(), instr_cmps_a7(), instr_dec_4x(), instr_group_1_80_adc(), instr_group_1_80_add(), instr_group_1_80_and(), instr_group_1_80_cmp(), instr_group_1_80_or(), instr_group_1_80_sbb(), instr_group_1_80_sub(), instr_group_1_80_xor(), instr_group_1_81_adc(), instr_group_1_81_add(), instr_group_1_81_and(), instr_group_1_81_cmp(), instr_group_1_81_or(), instr_group_1_81_sbb(), instr_group_1_81_sub(), instr_group_1_81_xor(), instr_group_1_83_adc(), instr_group_1_83_add(), instr_group_1_83_and(), instr_group_1_83_cmp(), instr_group_1_83_or(), instr_group_1_83_sbb(), instr_group_1_83_sub(), instr_group_1_83_xor(), instr_group_2_c0_rcl(), instr_group_2_c0_rcr(), instr_group_2_c0_rol(), instr_group_2_c0_ror(), instr_group_2_c0_sal(), instr_group_2_c0_sar(), instr_group_2_c0_shr(), instr_group_2_c1_rcl(), instr_group_2_c1_rcr(), instr_group_2_c1_rol(), instr_group_2_c1_ror(), instr_group_2_c1_sal(), instr_group_2_c1_sar(), instr_group_2_c1_shr(), instr_group_2_d0_rcl(), instr_group_2_d0_rcr(), instr_group_2_d0_rol(), instr_group_2_d0_ror(), instr_group_2_d0_sal(), instr_group_2_d0_sar(), instr_group_2_d0_shr(), instr_group_2_d1_rcl(), instr_group_2_d1_rcr(), instr_group_2_d1_rol(), instr_group_2_d1_ror(), instr_group_2_d1_sal(), instr_group_2_d1_sar(), instr_group_2_d1_shr(), instr_group_2_d2_rcl(), instr_group_2_d2_rcr(), instr_group_2_d2_rol(), instr_group_2_d2_ror(), instr_group_2_d2_sal(), instr_group_2_d2_sar(), instr_group_2_d2_shr(), instr_group_2_d3_rcl(), instr_group_2_d3_rcr(), instr_group_2_d3_rol(), instr_group_2_d3_ror(), instr_group_2_d3_sal(), instr_group_2_d3_sar(), instr_group_2_d3_shr(), instr_group_3_f6_neg(), instr_group_3_f6_not(), instr_group_3_f6_test(), instr_group_3_f7_neg(), instr_group_3_f7_not(), instr_group_3_f7_test(), instr_group_4_fe_dec(), instr_group_4_fe_inc(), instr_group_5_ff_dec(), instr_group_5_ff_inc(), instr_inc_4x(), instr_or_08(), instr_or_09(), instr_or_0a(), instr_or_0b(), instr_or_0c(), instr_or_0d(), instr_sbb_18(), instr_sbb_19(), instr_sbb_1a(), instr_sbb_1b(), instr_sbb_1c(), instr_sbb_1d(), instr_scas_ae(), instr_scas_af(), instr_sub_28(), instr_sub_29(), instr_sub_2a(), instr_sub_2b(), instr_sub_2c(), instr_sub_2d(), instr_test_84(), instr_test_85(), instr_test_a8(), instr_test_a9(), instr_xor_30(), instr_xor_31(), instr_xor_32(), instr_xor_33(), instr_xor_34(), and instr_xor_35().
| #define INSTR_SET_FLAG_CF | ( | cpu, | |||
| operand | ) |
{ \
uint64_t ux = (uint64_t)operand_a; \
uint64_t uy = (uint64_t)operand_b; \
uint64_t uz = 0; \
uz = ux operand uy operand ((cpu->eflags & (1 << f_cf))?1:0); \
/*printf("cf: ux %lli + uy %lli + cf %i = uz %lli \n", ux, uy, (cpu->eflags & (1 << f_cf))?1:0, uz);*/\
\
if (uz < max_inttype_borders[sizeof(operation_result)][1][0] || uz > max_inttype_borders[sizeof(operation_result)][1][1] \
|| uz != (uint64_t)operation_result ) \
{ \
CPU_FLAG_SET(cpu, f_cf); \
}else \
{ \
CPU_FLAG_UNSET(cpu, f_cf); \
} \
}
| #define INSTR_SET_FLAG_OF | ( | cpu, | |||
| operand, | |||||
| bits | ) |
{ \
int64_t sx = (INTOF(bits))operand_a; \
int64_t sy = (INTOF(bits))operand_b; \
int64_t sz = 0; \
\
sz = sx operand sy operand ((cpu->eflags & (1 << f_cf))?1:0); \
/*printf("of: sx %lli + sy %lli + cf %i = sz %lli \n", sx, sy, (cpu->eflags & (1 << f_cf))?1:0, sz);*/\
\
if (sz < max_inttype_borders[sizeof(operation_result)][0][0] || sz > max_inttype_borders[sizeof(operation_result)][0][1] \
|| sz != (INTOF(bits))operation_result ) \
{ \
CPU_FLAG_SET(cpu, f_of); \
}else \
{ \
CPU_FLAG_UNSET(cpu, f_of); \
} \
}
| #define TRACK_INIT_ALL_FLAGS | ( | instruction_p | ) |
TRACK_INIT_EFLAG(instruction_p, f_zf); \ TRACK_INIT_EFLAG(instruction_p, f_pf); \ TRACK_INIT_EFLAG(instruction_p, f_sf); \ TRACK_INIT_EFLAG(instruction_p, f_of); \ TRACK_INIT_EFLAG(instruction_p, f_cf);
Referenced by instr_adc_10(), instr_adc_11(), instr_adc_12(), instr_adc_13(), instr_adc_14(), instr_adc_15(), instr_add_00(), instr_add_01(), instr_add_02(), instr_add_03(), instr_add_04(), instr_add_05(), instr_and_20(), instr_and_21(), instr_and_22(), instr_and_23(), instr_and_24(), instr_and_25(), instr_group_1_80_adc(), instr_group_1_80_add(), instr_group_1_80_and(), instr_group_1_80_or(), instr_group_1_80_sbb(), instr_group_1_80_sub(), instr_group_1_80_xor(), instr_group_1_81_adc(), instr_group_1_81_add(), instr_group_1_81_and(), instr_group_1_81_or(), instr_group_1_81_sbb(), instr_group_1_81_sub(), instr_group_1_81_xor(), instr_group_1_83_adc(), instr_group_1_83_add(), instr_group_1_83_and(), instr_group_1_83_or(), instr_group_1_83_sbb(), instr_group_1_83_sub(), instr_group_1_83_xor(), instr_or_08(), instr_or_09(), instr_or_0a(), instr_or_0b(), instr_or_0c(), instr_or_0d(), instr_sbb_18(), instr_sbb_19(), instr_sbb_1a(), instr_sbb_1b(), instr_sbb_1c(), instr_sbb_1d(), instr_sub_28(), instr_sub_29(), instr_sub_2a(), instr_sub_2b(), instr_sub_2c(), instr_sub_2d(), instr_xor_30(), instr_xor_31(), instr_xor_32(), instr_xor_33(), instr_xor_34(), and instr_xor_35().
| int32_t instr_adc_10 | ( | struct emu_cpu * | c, | |
| struct emu_cpu_instruction * | i | |||
| ) |
| int32_t instr_adc_11 | ( | struct emu_cpu * | c, | |
| struct emu_cpu_instruction * | i | |||
| ) |
References emu_cpu_instruction::ea, emu_cpu::instr, INSTR_CALC_AND_SET_FLAGS, MEM_DWORD_READ, MEM_DWORD_WRITE, MEM_WORD_READ, MEM_WORD_WRITE, emu_cpu_instruction::mod, emu_cpu_instruction::modrm, emu_cpu_instruction::opc, PREFIX_OPSIZE, emu_cpu_instruction::prefixes, emu_cpu::reg, emu_cpu::reg16, emu_cpu_instruction::rm, and TRACK_INIT_ALL_FLAGS.
| int32_t instr_adc_12 | ( | struct emu_cpu * | c, | |
| struct emu_cpu_instruction * | i | |||
| ) |
| int32_t instr_adc_13 | ( | struct emu_cpu * | c, | |
| struct emu_cpu_instruction * | i | |||
| ) |
References emu_cpu_instruction::ea, emu_cpu::instr, INSTR_CALC_AND_SET_FLAGS, MEM_DWORD_READ, MEM_WORD_READ, emu_cpu_instruction::mod, emu_cpu_instruction::modrm, emu_cpu_instruction::opc, PREFIX_OPSIZE, emu_cpu_instruction::prefixes, emu_cpu::reg, emu_cpu::reg16, emu_cpu_instruction::rm, and TRACK_INIT_ALL_FLAGS.
| int32_t instr_adc_14 | ( | struct emu_cpu * | c, | |
| struct emu_cpu_instruction * | i | |||
| ) |
References al, emu_cpu_instruction::imm8, emu_cpu::instr, INSTR_CALC_AND_SET_FLAGS, emu_cpu::reg8, and TRACK_INIT_ALL_FLAGS.
| int32_t instr_adc_15 | ( | struct emu_cpu * | c, | |
| struct emu_cpu_instruction * | i | |||
| ) |
| int32_t instr_group_1_80_adc | ( | struct emu_cpu * | c, | |
| struct emu_cpu_instruction * | i | |||
| ) |
| int32_t instr_group_1_81_adc | ( | struct emu_cpu * | c, | |
| struct emu_cpu_instruction * | i | |||
| ) |
References emu_cpu_instruction::ea, emu_cpu_instruction::imm, emu_cpu_instruction::imm16, emu_cpu::instr, INSTR_CALC_AND_SET_FLAGS, MEM_DWORD_READ, MEM_DWORD_WRITE, MEM_WORD_READ, MEM_WORD_WRITE, emu_cpu_instruction::mod, emu_cpu_instruction::modrm, PREFIX_OPSIZE, emu_cpu_instruction::prefixes, emu_cpu::reg, emu_cpu::reg16, emu_cpu_instruction::rm, and TRACK_INIT_ALL_FLAGS.
Referenced by instr_group_1_81().
| int32_t instr_group_1_83_adc | ( | struct emu_cpu * | c, | |
| struct emu_cpu_instruction * | i | |||
| ) |
References emu_cpu_instruction::ea, emu_cpu_instruction::imm8, emu_cpu::instr, INSTR_CALC_AND_SET_FLAGS, MEM_DWORD_READ, MEM_DWORD_WRITE, MEM_WORD_READ, MEM_WORD_WRITE, emu_cpu_instruction::mod, emu_cpu_instruction::modrm, PREFIX_OPSIZE, emu_cpu_instruction::prefixes, emu_cpu::reg, emu_cpu::reg16, emu_cpu_instruction::rm, and TRACK_INIT_ALL_FLAGS.
Referenced by instr_group_1_83().
1.6.1