Added recompiled versions of ADC and SBC.
This commit is contained in:
parent
222071b742
commit
d4d6a26283
5 changed files with 823 additions and 97 deletions
|
|
@ -8,6 +8,263 @@
|
|||
#include "codegen_ops.h"
|
||||
#include "codegen_ops_arith.h"
|
||||
|
||||
static inline void get_cf(ir_data_t *ir, int dest_reg)
|
||||
{
|
||||
uop_CALL_FUNC_RESULT(ir, dest_reg, CF_SET);
|
||||
}
|
||||
|
||||
uint32_t ropADC_AL_imm(codeblock_t *block, ir_data_t *ir, uint8_t opcode, uint32_t fetchdat, uint32_t op_32, uint32_t op_pc)
|
||||
{
|
||||
uint8_t imm_data = fastreadb(cs + op_pc);
|
||||
|
||||
get_cf(ir, IREG_temp0);
|
||||
uop_MOVZX(ir, IREG_flags_op1, IREG_AL);
|
||||
uop_ADD_IMM(ir, IREG_AL, IREG_AL, imm_data);
|
||||
uop_MOV_IMM(ir, IREG_flags_op2, imm_data);
|
||||
uop_ADD(ir, IREG_AL, IREG_AL, IREG_temp0_B);
|
||||
uop_MOV_IMM(ir, IREG_flags_op, FLAGS_ADC8);
|
||||
uop_MOVZX(ir, IREG_flags_res, IREG_AL);
|
||||
|
||||
codegen_flags_changed = 1;
|
||||
return op_pc + 1;
|
||||
}
|
||||
uint32_t ropADC_AX_imm(codeblock_t *block, ir_data_t *ir, uint8_t opcode, uint32_t fetchdat, uint32_t op_32, uint32_t op_pc)
|
||||
{
|
||||
uint16_t imm_data = fastreadw(cs + op_pc);
|
||||
|
||||
get_cf(ir, IREG_temp0);
|
||||
uop_MOVZX(ir, IREG_flags_op1, IREG_AX);
|
||||
uop_ADD_IMM(ir, IREG_AX, IREG_AX, imm_data);
|
||||
uop_MOV_IMM(ir, IREG_flags_op2, imm_data);
|
||||
uop_ADD(ir, IREG_AX, IREG_AX, IREG_temp0_W);
|
||||
uop_MOV_IMM(ir, IREG_flags_op, FLAGS_ADC16);
|
||||
uop_MOVZX(ir, IREG_flags_res, IREG_AX);
|
||||
|
||||
codegen_flags_changed = 1;
|
||||
return op_pc + 2;
|
||||
}
|
||||
uint32_t ropADC_EAX_imm(codeblock_t *block, ir_data_t *ir, uint8_t opcode, uint32_t fetchdat, uint32_t op_32, uint32_t op_pc)
|
||||
{
|
||||
fetchdat = fastreadl(cs + op_pc);
|
||||
|
||||
get_cf(ir, IREG_temp0);
|
||||
uop_MOV(ir, IREG_flags_op1, IREG_EAX);
|
||||
uop_ADD_IMM(ir, IREG_EAX, IREG_EAX, fetchdat);
|
||||
uop_MOV_IMM(ir, IREG_flags_op2, fetchdat);
|
||||
uop_ADD(ir, IREG_EAX, IREG_EAX, IREG_temp0);
|
||||
uop_MOV_IMM(ir, IREG_flags_op, FLAGS_ADC32);
|
||||
uop_MOV(ir, IREG_flags_res, IREG_EAX);
|
||||
|
||||
codegen_flags_changed = 1;
|
||||
return op_pc + 4;
|
||||
}
|
||||
uint32_t ropADC_b_rm(codeblock_t *block, ir_data_t *ir, uint8_t opcode, uint32_t fetchdat, uint32_t op_32, uint32_t op_pc)
|
||||
{
|
||||
int dest_reg = (fetchdat >> 3) & 7;
|
||||
//return 0;
|
||||
get_cf(ir, IREG_temp1);
|
||||
if ((fetchdat & 0xc0) == 0xc0)
|
||||
{
|
||||
int src_reg = fetchdat & 7;
|
||||
|
||||
uop_MOVZX(ir, IREG_flags_op1, IREG_8(dest_reg));
|
||||
uop_MOVZX(ir, IREG_flags_op2, IREG_8(src_reg));
|
||||
uop_ADD(ir, IREG_8(dest_reg), IREG_8(dest_reg), IREG_8(src_reg));
|
||||
}
|
||||
else
|
||||
{
|
||||
x86seg *target_seg;
|
||||
|
||||
uop_MOV_IMM(ir, IREG_oldpc, cpu_state.oldpc);
|
||||
target_seg = codegen_generate_ea(ir, op_ea_seg, fetchdat, op_ssegs, &op_pc, op_32, 0);
|
||||
codegen_check_seg_read(block, ir, target_seg);
|
||||
uop_MEM_LOAD_REG(ir, IREG_temp0_B, ireg_seg_base(target_seg), IREG_eaaddr);
|
||||
uop_MOVZX(ir, IREG_flags_op1, IREG_8(dest_reg));
|
||||
uop_MOVZX(ir, IREG_flags_op2, IREG_temp0_B);
|
||||
uop_ADD(ir, IREG_8(dest_reg), IREG_8(dest_reg), IREG_temp0_B);
|
||||
}
|
||||
|
||||
uop_ADD(ir, IREG_8(dest_reg), IREG_8(dest_reg), IREG_temp1_B);
|
||||
uop_MOV_IMM(ir, IREG_flags_op, FLAGS_ADC8);
|
||||
uop_MOVZX(ir, IREG_flags_res, IREG_8(dest_reg));
|
||||
|
||||
codegen_flags_changed = 1;
|
||||
return op_pc + 1;
|
||||
}
|
||||
uint32_t ropADC_b_rmw(codeblock_t *block, ir_data_t *ir, uint8_t opcode, uint32_t fetchdat, uint32_t op_32, uint32_t op_pc)
|
||||
{
|
||||
int src_reg = (fetchdat >> 3) & 7;
|
||||
|
||||
get_cf(ir, IREG_temp1);
|
||||
if ((fetchdat & 0xc0) == 0xc0)
|
||||
{
|
||||
int dest_reg = fetchdat & 7;
|
||||
|
||||
uop_MOVZX(ir, IREG_flags_op1, IREG_8(dest_reg));
|
||||
uop_MOVZX(ir, IREG_flags_op2, IREG_8(src_reg));
|
||||
uop_ADD(ir, IREG_8(dest_reg), IREG_8(dest_reg), IREG_8(src_reg));
|
||||
uop_ADD(ir, IREG_8(dest_reg), IREG_8(dest_reg), IREG_temp1_B);
|
||||
uop_MOVZX(ir, IREG_flags_res, IREG_8(dest_reg));
|
||||
}
|
||||
else
|
||||
{
|
||||
x86seg *target_seg;
|
||||
|
||||
uop_MOV_IMM(ir, IREG_oldpc, cpu_state.oldpc);
|
||||
target_seg = codegen_generate_ea(ir, op_ea_seg, fetchdat, op_ssegs, &op_pc, op_32, 0);
|
||||
codegen_check_seg_write(block, ir, target_seg);
|
||||
|
||||
uop_MEM_LOAD_REG(ir, IREG_temp0_B, ireg_seg_base(target_seg), IREG_eaaddr);
|
||||
uop_ADD(ir, IREG_temp2_B, IREG_temp0_B, IREG_8(src_reg));
|
||||
uop_ADD(ir, IREG_temp2_B, IREG_temp2_B, IREG_temp1_B);
|
||||
uop_MEM_STORE_REG(ir, ireg_seg_base(target_seg), IREG_eaaddr, IREG_temp2_B);
|
||||
uop_MOVZX(ir, IREG_flags_op1, IREG_temp0_B);
|
||||
uop_MOVZX(ir, IREG_flags_op2, IREG_8(src_reg));
|
||||
uop_MOVZX(ir, IREG_flags_res, IREG_temp2_B);
|
||||
}
|
||||
uop_MOV_IMM(ir, IREG_flags_op, FLAGS_ADC8);
|
||||
|
||||
codegen_flags_changed = 1;
|
||||
return op_pc + 1;
|
||||
}
|
||||
uint32_t ropADC_w_rm(codeblock_t *block, ir_data_t *ir, uint8_t opcode, uint32_t fetchdat, uint32_t op_32, uint32_t op_pc)
|
||||
{
|
||||
int dest_reg = (fetchdat >> 3) & 7;
|
||||
|
||||
get_cf(ir, IREG_temp1);
|
||||
if ((fetchdat & 0xc0) == 0xc0)
|
||||
{
|
||||
int src_reg = fetchdat & 7;
|
||||
|
||||
uop_MOVZX(ir, IREG_flags_op1, IREG_16(dest_reg));
|
||||
uop_MOVZX(ir, IREG_flags_op2, IREG_16(src_reg));
|
||||
uop_ADD(ir, IREG_16(dest_reg), IREG_16(dest_reg), IREG_16(src_reg));
|
||||
}
|
||||
else
|
||||
{
|
||||
x86seg *target_seg;
|
||||
|
||||
uop_MOV_IMM(ir, IREG_oldpc, cpu_state.oldpc);
|
||||
target_seg = codegen_generate_ea(ir, op_ea_seg, fetchdat, op_ssegs, &op_pc, op_32, 0);
|
||||
codegen_check_seg_read(block, ir, target_seg);
|
||||
uop_MEM_LOAD_REG(ir, IREG_temp0_W, ireg_seg_base(target_seg), IREG_eaaddr);
|
||||
uop_MOVZX(ir, IREG_flags_op1, IREG_16(dest_reg));
|
||||
uop_MOVZX(ir, IREG_flags_op2, IREG_temp0_W);
|
||||
uop_ADD(ir, IREG_16(dest_reg), IREG_16(dest_reg), IREG_temp0_W);
|
||||
}
|
||||
|
||||
uop_ADD(ir, IREG_16(dest_reg), IREG_16(dest_reg), IREG_temp1_W);
|
||||
uop_MOV_IMM(ir, IREG_flags_op, FLAGS_ADC16);
|
||||
uop_MOVZX(ir, IREG_flags_res, IREG_16(dest_reg));
|
||||
|
||||
codegen_flags_changed = 1;
|
||||
return op_pc + 1;
|
||||
}
|
||||
uint32_t ropADC_w_rmw(codeblock_t *block, ir_data_t *ir, uint8_t opcode, uint32_t fetchdat, uint32_t op_32, uint32_t op_pc)
|
||||
{
|
||||
int src_reg = (fetchdat >> 3) & 7;
|
||||
|
||||
get_cf(ir, IREG_temp1);
|
||||
if ((fetchdat & 0xc0) == 0xc0)
|
||||
{
|
||||
int dest_reg = fetchdat & 7;
|
||||
|
||||
uop_MOVZX(ir, IREG_flags_op1, IREG_16(dest_reg));
|
||||
uop_MOVZX(ir, IREG_flags_op2, IREG_16(src_reg));
|
||||
uop_ADD(ir, IREG_16(dest_reg), IREG_16(dest_reg), IREG_16(src_reg));
|
||||
uop_ADD(ir, IREG_16(dest_reg), IREG_16(dest_reg), IREG_temp1_W);
|
||||
uop_MOVZX(ir, IREG_flags_res, IREG_16(dest_reg));
|
||||
}
|
||||
else
|
||||
{
|
||||
x86seg *target_seg;
|
||||
|
||||
uop_MOV_IMM(ir, IREG_oldpc, cpu_state.oldpc);
|
||||
target_seg = codegen_generate_ea(ir, op_ea_seg, fetchdat, op_ssegs, &op_pc, op_32, 0);
|
||||
codegen_check_seg_write(block, ir, target_seg);
|
||||
|
||||
uop_MEM_LOAD_REG(ir, IREG_temp0_W, ireg_seg_base(target_seg), IREG_eaaddr);
|
||||
uop_ADD(ir, IREG_temp2_W, IREG_temp0_W, IREG_16(src_reg));
|
||||
uop_ADD(ir, IREG_temp2_W, IREG_temp2_W, IREG_temp1_W);
|
||||
uop_MEM_STORE_REG(ir, ireg_seg_base(target_seg), IREG_eaaddr, IREG_temp2_W);
|
||||
uop_MOVZX(ir, IREG_flags_op1, IREG_temp0_W);
|
||||
uop_MOVZX(ir, IREG_flags_op2, IREG_16(src_reg));
|
||||
uop_MOVZX(ir, IREG_flags_res, IREG_temp2_W);
|
||||
}
|
||||
uop_MOV_IMM(ir, IREG_flags_op, FLAGS_ADC16);
|
||||
|
||||
codegen_flags_changed = 1;
|
||||
return op_pc + 1;
|
||||
}
|
||||
uint32_t ropADC_l_rm(codeblock_t *block, ir_data_t *ir, uint8_t opcode, uint32_t fetchdat, uint32_t op_32, uint32_t op_pc)
|
||||
{
|
||||
int dest_reg = (fetchdat >> 3) & 7;
|
||||
|
||||
get_cf(ir, IREG_temp1);
|
||||
if ((fetchdat & 0xc0) == 0xc0)
|
||||
{
|
||||
int src_reg = fetchdat & 7;
|
||||
|
||||
uop_MOV(ir, IREG_flags_op1, IREG_32(dest_reg));
|
||||
uop_MOV(ir, IREG_flags_op2, IREG_32(src_reg));
|
||||
uop_ADD(ir, IREG_32(dest_reg), IREG_32(dest_reg), IREG_32(src_reg));
|
||||
}
|
||||
else
|
||||
{
|
||||
x86seg *target_seg;
|
||||
|
||||
uop_MOV_IMM(ir, IREG_oldpc, cpu_state.oldpc);
|
||||
target_seg = codegen_generate_ea(ir, op_ea_seg, fetchdat, op_ssegs, &op_pc, op_32, 0);
|
||||
codegen_check_seg_read(block, ir, target_seg);
|
||||
uop_MEM_LOAD_REG(ir, IREG_flags_op2, ireg_seg_base(target_seg), IREG_eaaddr);
|
||||
uop_MOV(ir, IREG_flags_op1, IREG_32(dest_reg));
|
||||
uop_ADD(ir, IREG_32(dest_reg), IREG_32(dest_reg), IREG_flags_op2);
|
||||
}
|
||||
|
||||
uop_ADD(ir, IREG_32(dest_reg), IREG_32(dest_reg), IREG_temp1);
|
||||
uop_MOV_IMM(ir, IREG_flags_op, FLAGS_ADC32);
|
||||
uop_MOV(ir, IREG_flags_res, IREG_32(dest_reg));
|
||||
|
||||
codegen_flags_changed = 1;
|
||||
return op_pc + 1;
|
||||
}
|
||||
uint32_t ropADC_l_rmw(codeblock_t *block, ir_data_t *ir, uint8_t opcode, uint32_t fetchdat, uint32_t op_32, uint32_t op_pc)
|
||||
{
|
||||
int src_reg = (fetchdat >> 3) & 7;
|
||||
|
||||
get_cf(ir, IREG_temp1);
|
||||
if ((fetchdat & 0xc0) == 0xc0)
|
||||
{
|
||||
int dest_reg = fetchdat & 7;
|
||||
|
||||
uop_MOV(ir, IREG_flags_op1, IREG_32(dest_reg));
|
||||
uop_MOV(ir, IREG_flags_op2, IREG_32(src_reg));
|
||||
uop_ADD(ir, IREG_32(dest_reg), IREG_32(dest_reg), IREG_32(src_reg));
|
||||
uop_ADD(ir, IREG_32(dest_reg), IREG_32(dest_reg), IREG_temp1);
|
||||
uop_MOV(ir, IREG_flags_res, IREG_32(dest_reg));
|
||||
}
|
||||
else
|
||||
{
|
||||
x86seg *target_seg;
|
||||
|
||||
uop_MOV_IMM(ir, IREG_oldpc, cpu_state.oldpc);
|
||||
target_seg = codegen_generate_ea(ir, op_ea_seg, fetchdat, op_ssegs, &op_pc, op_32, 0);
|
||||
codegen_check_seg_write(block, ir, target_seg);
|
||||
|
||||
uop_MEM_LOAD_REG(ir, IREG_temp0, ireg_seg_base(target_seg), IREG_eaaddr);
|
||||
uop_ADD(ir, IREG_temp2, IREG_temp0, IREG_32(src_reg));
|
||||
uop_ADD(ir, IREG_temp2, IREG_temp2, IREG_temp1);
|
||||
uop_MEM_STORE_REG(ir, ireg_seg_base(target_seg), IREG_eaaddr, IREG_temp2);
|
||||
uop_MOV(ir, IREG_flags_op1, IREG_temp0);
|
||||
uop_MOV(ir, IREG_flags_op2, IREG_32(src_reg));
|
||||
uop_MOV(ir, IREG_flags_res, IREG_temp2);
|
||||
}
|
||||
uop_MOV_IMM(ir, IREG_flags_op, FLAGS_ADC32);
|
||||
|
||||
codegen_flags_changed = 1;
|
||||
return op_pc + 1;
|
||||
}
|
||||
|
||||
uint32_t ropADD_AL_imm(codeblock_t *block, ir_data_t *ir, uint8_t opcode, uint32_t fetchdat, uint32_t op_32, uint32_t op_pc)
|
||||
{
|
||||
uint8_t imm_data = fastreadb(cs + op_pc);
|
||||
|
|
@ -462,6 +719,260 @@ uint32_t ropCMP_l_rmw(codeblock_t *block, ir_data_t *ir, uint8_t opcode, uint32_
|
|||
return op_pc + 1;
|
||||
}
|
||||
|
||||
uint32_t ropSBB_AL_imm(codeblock_t *block, ir_data_t *ir, uint8_t opcode, uint32_t fetchdat, uint32_t op_32, uint32_t op_pc)
|
||||
{
|
||||
uint8_t imm_data = fastreadb(cs + op_pc);
|
||||
|
||||
get_cf(ir, IREG_temp0);
|
||||
uop_MOVZX(ir, IREG_flags_op1, IREG_AL);
|
||||
uop_SUB_IMM(ir, IREG_AL, IREG_AL, imm_data);
|
||||
uop_MOV_IMM(ir, IREG_flags_op2, imm_data);
|
||||
uop_SUB(ir, IREG_AL, IREG_AL, IREG_temp0_B);
|
||||
uop_MOV_IMM(ir, IREG_flags_op, FLAGS_SBC8);
|
||||
uop_MOVZX(ir, IREG_flags_res, IREG_AL);
|
||||
|
||||
codegen_flags_changed = 1;
|
||||
return op_pc + 1;
|
||||
}
|
||||
uint32_t ropSBB_AX_imm(codeblock_t *block, ir_data_t *ir, uint8_t opcode, uint32_t fetchdat, uint32_t op_32, uint32_t op_pc)
|
||||
{
|
||||
uint16_t imm_data = fastreadw(cs + op_pc);
|
||||
|
||||
get_cf(ir, IREG_temp0);
|
||||
uop_MOVZX(ir, IREG_flags_op1, IREG_AX);
|
||||
uop_SUB_IMM(ir, IREG_AX, IREG_AX, imm_data);
|
||||
uop_MOV_IMM(ir, IREG_flags_op2, imm_data);
|
||||
uop_SUB(ir, IREG_AX, IREG_AX, IREG_temp0_W);
|
||||
uop_MOV_IMM(ir, IREG_flags_op, FLAGS_SBC16);
|
||||
uop_MOVZX(ir, IREG_flags_res, IREG_AX);
|
||||
|
||||
codegen_flags_changed = 1;
|
||||
return op_pc + 2;
|
||||
}
|
||||
uint32_t ropSBB_EAX_imm(codeblock_t *block, ir_data_t *ir, uint8_t opcode, uint32_t fetchdat, uint32_t op_32, uint32_t op_pc)
|
||||
{
|
||||
fetchdat = fastreadl(cs + op_pc);
|
||||
|
||||
get_cf(ir, IREG_temp0);
|
||||
uop_MOV(ir, IREG_flags_op1, IREG_EAX);
|
||||
uop_SUB_IMM(ir, IREG_EAX, IREG_EAX, fetchdat);
|
||||
uop_MOV_IMM(ir, IREG_flags_op2, fetchdat);
|
||||
uop_SUB(ir, IREG_EAX, IREG_EAX, IREG_temp0);
|
||||
uop_MOV_IMM(ir, IREG_flags_op, FLAGS_SBC32);
|
||||
uop_MOV(ir, IREG_flags_res, IREG_EAX);
|
||||
|
||||
codegen_flags_changed = 1;
|
||||
return op_pc + 4;
|
||||
}
|
||||
uint32_t ropSBB_b_rm(codeblock_t *block, ir_data_t *ir, uint8_t opcode, uint32_t fetchdat, uint32_t op_32, uint32_t op_pc)
|
||||
{
|
||||
int dest_reg = (fetchdat >> 3) & 7;
|
||||
|
||||
get_cf(ir, IREG_temp1);
|
||||
if ((fetchdat & 0xc0) == 0xc0)
|
||||
{
|
||||
int src_reg = fetchdat & 7;
|
||||
|
||||
uop_MOVZX(ir, IREG_flags_op1, IREG_8(dest_reg));
|
||||
uop_MOVZX(ir, IREG_flags_op2, IREG_8(src_reg));
|
||||
uop_SUB(ir, IREG_8(dest_reg), IREG_8(dest_reg), IREG_8(src_reg));
|
||||
}
|
||||
else
|
||||
{
|
||||
x86seg *target_seg;
|
||||
|
||||
uop_MOV_IMM(ir, IREG_oldpc, cpu_state.oldpc);
|
||||
target_seg = codegen_generate_ea(ir, op_ea_seg, fetchdat, op_ssegs, &op_pc, op_32, 0);
|
||||
codegen_check_seg_read(block, ir, target_seg);
|
||||
uop_MEM_LOAD_REG(ir, IREG_temp0_B, ireg_seg_base(target_seg), IREG_eaaddr);
|
||||
uop_MOVZX(ir, IREG_flags_op1, IREG_8(dest_reg));
|
||||
uop_MOVZX(ir, IREG_flags_op2, IREG_temp0_B);
|
||||
uop_SUB(ir, IREG_8(dest_reg), IREG_8(dest_reg), IREG_temp0_B);
|
||||
}
|
||||
|
||||
uop_SUB(ir, IREG_8(dest_reg), IREG_8(dest_reg), IREG_temp1_B);
|
||||
uop_MOV_IMM(ir, IREG_flags_op, FLAGS_SBC8);
|
||||
uop_MOVZX(ir, IREG_flags_res, IREG_8(dest_reg));
|
||||
|
||||
codegen_flags_changed = 1;
|
||||
return op_pc + 1;
|
||||
}
|
||||
uint32_t ropSBB_b_rmw(codeblock_t *block, ir_data_t *ir, uint8_t opcode, uint32_t fetchdat, uint32_t op_32, uint32_t op_pc)
|
||||
{
|
||||
int src_reg = (fetchdat >> 3) & 7;
|
||||
|
||||
get_cf(ir, IREG_temp1);
|
||||
if ((fetchdat & 0xc0) == 0xc0)
|
||||
{
|
||||
int dest_reg = fetchdat & 7;
|
||||
|
||||
uop_MOVZX(ir, IREG_flags_op1, IREG_8(dest_reg));
|
||||
uop_MOVZX(ir, IREG_flags_op2, IREG_8(src_reg));
|
||||
uop_SUB(ir, IREG_8(dest_reg), IREG_8(dest_reg), IREG_8(src_reg));
|
||||
uop_SUB(ir, IREG_8(dest_reg), IREG_8(dest_reg), IREG_temp1_B);
|
||||
uop_MOVZX(ir, IREG_flags_res, IREG_8(dest_reg));
|
||||
}
|
||||
else
|
||||
{
|
||||
x86seg *target_seg;
|
||||
|
||||
uop_MOV_IMM(ir, IREG_oldpc, cpu_state.oldpc);
|
||||
target_seg = codegen_generate_ea(ir, op_ea_seg, fetchdat, op_ssegs, &op_pc, op_32, 0);
|
||||
codegen_check_seg_write(block, ir, target_seg);
|
||||
|
||||
uop_MEM_LOAD_REG(ir, IREG_temp0_B, ireg_seg_base(target_seg), IREG_eaaddr);
|
||||
uop_SUB(ir, IREG_temp2_B, IREG_temp0_B, IREG_8(src_reg));
|
||||
uop_SUB(ir, IREG_temp2_B, IREG_temp2_B, IREG_temp1_B);
|
||||
uop_MEM_STORE_REG(ir, ireg_seg_base(target_seg), IREG_eaaddr, IREG_temp2_B);
|
||||
uop_MOVZX(ir, IREG_flags_op1, IREG_temp0_B);
|
||||
uop_MOVZX(ir, IREG_flags_op2, IREG_8(src_reg));
|
||||
uop_MOVZX(ir, IREG_flags_res, IREG_temp2_B);
|
||||
}
|
||||
uop_MOV_IMM(ir, IREG_flags_op, FLAGS_SBC8);
|
||||
|
||||
codegen_flags_changed = 1;
|
||||
return op_pc + 1;
|
||||
}
|
||||
uint32_t ropSBB_w_rm(codeblock_t *block, ir_data_t *ir, uint8_t opcode, uint32_t fetchdat, uint32_t op_32, uint32_t op_pc)
|
||||
{
|
||||
int dest_reg = (fetchdat >> 3) & 7;
|
||||
|
||||
get_cf(ir, IREG_temp1);
|
||||
if ((fetchdat & 0xc0) == 0xc0)
|
||||
{
|
||||
int src_reg = fetchdat & 7;
|
||||
|
||||
uop_MOVZX(ir, IREG_flags_op1, IREG_16(dest_reg));
|
||||
uop_MOVZX(ir, IREG_flags_op2, IREG_16(src_reg));
|
||||
uop_SUB(ir, IREG_16(dest_reg), IREG_16(dest_reg), IREG_16(src_reg));
|
||||
}
|
||||
else
|
||||
{
|
||||
x86seg *target_seg;
|
||||
|
||||
uop_MOV_IMM(ir, IREG_oldpc, cpu_state.oldpc);
|
||||
target_seg = codegen_generate_ea(ir, op_ea_seg, fetchdat, op_ssegs, &op_pc, op_32, 0);
|
||||
codegen_check_seg_read(block, ir, target_seg);
|
||||
uop_MEM_LOAD_REG(ir, IREG_temp0_W, ireg_seg_base(target_seg), IREG_eaaddr);
|
||||
uop_MOVZX(ir, IREG_flags_op1, IREG_16(dest_reg));
|
||||
uop_MOVZX(ir, IREG_flags_op2, IREG_temp0_W);
|
||||
uop_SUB(ir, IREG_16(dest_reg), IREG_16(dest_reg), IREG_temp0_W);
|
||||
}
|
||||
|
||||
uop_SUB(ir, IREG_16(dest_reg), IREG_16(dest_reg), IREG_temp1_W);
|
||||
uop_MOV_IMM(ir, IREG_flags_op, FLAGS_SBC16);
|
||||
uop_MOVZX(ir, IREG_flags_res, IREG_16(dest_reg));
|
||||
|
||||
codegen_flags_changed = 1;
|
||||
return op_pc + 1;
|
||||
}
|
||||
uint32_t ropSBB_w_rmw(codeblock_t *block, ir_data_t *ir, uint8_t opcode, uint32_t fetchdat, uint32_t op_32, uint32_t op_pc)
|
||||
{
|
||||
int src_reg = (fetchdat >> 3) & 7;
|
||||
|
||||
get_cf(ir, IREG_temp1);
|
||||
if ((fetchdat & 0xc0) == 0xc0)
|
||||
{
|
||||
int dest_reg = fetchdat & 7;
|
||||
|
||||
uop_MOVZX(ir, IREG_flags_op1, IREG_16(dest_reg));
|
||||
uop_MOVZX(ir, IREG_flags_op2, IREG_16(src_reg));
|
||||
uop_SUB(ir, IREG_16(dest_reg), IREG_16(dest_reg), IREG_16(src_reg));
|
||||
uop_SUB(ir, IREG_16(dest_reg), IREG_16(dest_reg), IREG_temp1_W);
|
||||
uop_MOVZX(ir, IREG_flags_res, IREG_16(dest_reg));
|
||||
}
|
||||
else
|
||||
{
|
||||
x86seg *target_seg;
|
||||
|
||||
uop_MOV_IMM(ir, IREG_oldpc, cpu_state.oldpc);
|
||||
target_seg = codegen_generate_ea(ir, op_ea_seg, fetchdat, op_ssegs, &op_pc, op_32, 0);
|
||||
codegen_check_seg_write(block, ir, target_seg);
|
||||
|
||||
uop_MEM_LOAD_REG(ir, IREG_temp0_W, ireg_seg_base(target_seg), IREG_eaaddr);
|
||||
uop_SUB(ir, IREG_temp2_W, IREG_temp0_W, IREG_16(src_reg));
|
||||
uop_SUB(ir, IREG_temp2_W, IREG_temp2_W, IREG_temp1_W);
|
||||
uop_MEM_STORE_REG(ir, ireg_seg_base(target_seg), IREG_eaaddr, IREG_temp2_W);
|
||||
uop_MOVZX(ir, IREG_flags_op1, IREG_temp0_W);
|
||||
uop_MOVZX(ir, IREG_flags_op2, IREG_16(src_reg));
|
||||
uop_MOVZX(ir, IREG_flags_res, IREG_temp2_W);
|
||||
}
|
||||
|
||||
uop_MOV_IMM(ir, IREG_flags_op, FLAGS_SBC16);
|
||||
|
||||
codegen_flags_changed = 1;
|
||||
return op_pc + 1;
|
||||
}
|
||||
uint32_t ropSBB_l_rm(codeblock_t *block, ir_data_t *ir, uint8_t opcode, uint32_t fetchdat, uint32_t op_32, uint32_t op_pc)
|
||||
{
|
||||
int dest_reg = (fetchdat >> 3) & 7;
|
||||
|
||||
get_cf(ir, IREG_temp1);
|
||||
if ((fetchdat & 0xc0) == 0xc0)
|
||||
{
|
||||
int src_reg = fetchdat & 7;
|
||||
|
||||
uop_MOV(ir, IREG_flags_op1, IREG_32(dest_reg));
|
||||
uop_MOV(ir, IREG_flags_op2, IREG_32(src_reg));
|
||||
uop_SUB(ir, IREG_32(dest_reg), IREG_32(dest_reg), IREG_32(src_reg));
|
||||
}
|
||||
else
|
||||
{
|
||||
x86seg *target_seg;
|
||||
|
||||
uop_MOV_IMM(ir, IREG_oldpc, cpu_state.oldpc);
|
||||
target_seg = codegen_generate_ea(ir, op_ea_seg, fetchdat, op_ssegs, &op_pc, op_32, 0);
|
||||
codegen_check_seg_read(block, ir, target_seg);
|
||||
uop_MEM_LOAD_REG(ir, IREG_flags_op2, ireg_seg_base(target_seg), IREG_eaaddr);
|
||||
uop_MOV(ir, IREG_flags_op1, IREG_32(dest_reg));
|
||||
uop_SUB(ir, IREG_32(dest_reg), IREG_32(dest_reg), IREG_flags_op2);
|
||||
}
|
||||
|
||||
uop_SUB(ir, IREG_32(dest_reg), IREG_32(dest_reg), IREG_temp1);
|
||||
uop_MOV_IMM(ir, IREG_flags_op, FLAGS_SBC32);
|
||||
uop_MOV(ir, IREG_flags_res, IREG_32(dest_reg));
|
||||
|
||||
codegen_flags_changed = 1;
|
||||
return op_pc + 1;
|
||||
}
|
||||
uint32_t ropSBB_l_rmw(codeblock_t *block, ir_data_t *ir, uint8_t opcode, uint32_t fetchdat, uint32_t op_32, uint32_t op_pc)
|
||||
{
|
||||
int src_reg = (fetchdat >> 3) & 7;
|
||||
|
||||
get_cf(ir, IREG_temp1);
|
||||
if ((fetchdat & 0xc0) == 0xc0)
|
||||
{
|
||||
int dest_reg = fetchdat & 7;
|
||||
|
||||
uop_MOV(ir, IREG_flags_op1, IREG_32(dest_reg));
|
||||
uop_MOV(ir, IREG_flags_op2, IREG_32(src_reg));
|
||||
uop_SUB(ir, IREG_32(dest_reg), IREG_32(dest_reg), IREG_32(src_reg));
|
||||
uop_SUB(ir, IREG_32(dest_reg), IREG_32(dest_reg), IREG_temp1);
|
||||
uop_MOV(ir, IREG_flags_res, IREG_32(dest_reg));
|
||||
}
|
||||
else
|
||||
{
|
||||
x86seg *target_seg;
|
||||
|
||||
uop_MOV_IMM(ir, IREG_oldpc, cpu_state.oldpc);
|
||||
target_seg = codegen_generate_ea(ir, op_ea_seg, fetchdat, op_ssegs, &op_pc, op_32, 0);
|
||||
codegen_check_seg_write(block, ir, target_seg);
|
||||
|
||||
uop_MEM_LOAD_REG(ir, IREG_temp0, ireg_seg_base(target_seg), IREG_eaaddr);
|
||||
uop_SUB(ir, IREG_temp2, IREG_temp0, IREG_32(src_reg));
|
||||
uop_SUB(ir, IREG_temp2, IREG_temp2, IREG_temp1);
|
||||
uop_MEM_STORE_REG(ir, ireg_seg_base(target_seg), IREG_eaaddr, IREG_temp2);
|
||||
uop_MOV(ir, IREG_flags_op1, IREG_temp0);
|
||||
uop_MOV(ir, IREG_flags_op2, IREG_32(src_reg));
|
||||
uop_MOV(ir, IREG_flags_res, IREG_temp2);
|
||||
}
|
||||
|
||||
uop_MOV_IMM(ir, IREG_flags_op, FLAGS_SBC32);
|
||||
|
||||
codegen_flags_changed = 1;
|
||||
return op_pc + 1;
|
||||
}
|
||||
|
||||
uint32_t ropSUB_AL_imm(codeblock_t *block, ir_data_t *ir, uint8_t opcode, uint32_t fetchdat, uint32_t op_32, uint32_t op_pc)
|
||||
{
|
||||
uint8_t imm_data = fastreadb(cs + op_pc);
|
||||
|
|
@ -697,9 +1208,6 @@ uint32_t ropSUB_l_rmw(codeblock_t *block, ir_data_t *ir, uint8_t opcode, uint32_
|
|||
|
||||
uint32_t rop80(codeblock_t *block, ir_data_t *ir, uint8_t opcode, uint32_t fetchdat, uint32_t op_32, uint32_t op_pc)
|
||||
{
|
||||
if ((fetchdat & 0x30) == 0x10) /*ADC/SBB*/
|
||||
return 0;
|
||||
|
||||
if ((fetchdat & 0xc0) == 0xc0)
|
||||
{
|
||||
int dest_reg = fetchdat & 7;
|
||||
|
|
@ -721,6 +1229,26 @@ uint32_t rop80(codeblock_t *block, ir_data_t *ir, uint8_t opcode, uint32_t fetch
|
|||
uop_MOVZX(ir, IREG_flags_res, IREG_8(dest_reg));
|
||||
break;
|
||||
|
||||
case 0x10: /*ADC*/
|
||||
get_cf(ir, IREG_temp1);
|
||||
uop_MOVZX(ir, IREG_flags_op1, IREG_8(dest_reg));
|
||||
uop_ADD_IMM(ir, IREG_8(dest_reg), IREG_8(dest_reg), imm);
|
||||
uop_MOV_IMM(ir, IREG_flags_op2, imm);
|
||||
uop_ADD(ir, IREG_8(dest_reg), IREG_8(dest_reg), IREG_temp1_B);
|
||||
uop_MOV_IMM(ir, IREG_flags_op, FLAGS_ADC8);
|
||||
uop_MOVZX(ir, IREG_flags_res, IREG_8(dest_reg));
|
||||
break;
|
||||
|
||||
case 0x18: /*SBB*/
|
||||
get_cf(ir, IREG_temp1);
|
||||
uop_MOVZX(ir, IREG_flags_op1, IREG_8(dest_reg));
|
||||
uop_SUB_IMM(ir, IREG_8(dest_reg), IREG_8(dest_reg), imm);
|
||||
uop_MOV_IMM(ir, IREG_flags_op2, imm);
|
||||
uop_SUB(ir, IREG_8(dest_reg), IREG_8(dest_reg), IREG_temp1_B);
|
||||
uop_MOV_IMM(ir, IREG_flags_op, FLAGS_SBC8);
|
||||
uop_MOVZX(ir, IREG_flags_res, IREG_8(dest_reg));
|
||||
break;
|
||||
|
||||
case 0x20: /*AND*/
|
||||
uop_AND_IMM(ir, IREG_8(dest_reg), IREG_8(dest_reg), imm);
|
||||
uop_MOV_IMM(ir, IREG_flags_op, FLAGS_ZN8);
|
||||
|
|
@ -785,6 +1313,28 @@ uint32_t rop80(codeblock_t *block, ir_data_t *ir, uint8_t opcode, uint32_t fetch
|
|||
uop_MOV_IMM(ir, IREG_flags_op, FLAGS_ZN8);
|
||||
break;
|
||||
|
||||
case 0x10: /*ADC*/
|
||||
get_cf(ir, IREG_temp2);
|
||||
uop_ADD_IMM(ir, IREG_temp1_B, IREG_temp0_B, imm);
|
||||
uop_ADD(ir, IREG_temp1_B, IREG_temp1_B, IREG_temp2_B);
|
||||
uop_MEM_STORE_REG(ir, ireg_seg_base(target_seg), IREG_eaaddr, IREG_temp1_B);
|
||||
uop_MOVZX(ir, IREG_flags_op1, IREG_temp0_B);
|
||||
uop_MOV_IMM(ir, IREG_flags_op2, imm);
|
||||
uop_MOV_IMM(ir, IREG_flags_op, FLAGS_ADC8);
|
||||
uop_MOVZX(ir, IREG_flags_res, IREG_temp1_B);
|
||||
break;
|
||||
|
||||
case 0x18: /*SBB*/
|
||||
get_cf(ir, IREG_temp2);
|
||||
uop_SUB_IMM(ir, IREG_temp1_B, IREG_temp0_B, imm);
|
||||
uop_SUB(ir, IREG_temp1_B, IREG_temp1_B, IREG_temp2_B);
|
||||
uop_MEM_STORE_REG(ir, ireg_seg_base(target_seg), IREG_eaaddr, IREG_temp1_B);
|
||||
uop_MOVZX(ir, IREG_flags_op1, IREG_temp0_B);
|
||||
uop_MOV_IMM(ir, IREG_flags_op2, imm);
|
||||
uop_MOV_IMM(ir, IREG_flags_op, FLAGS_SBC8);
|
||||
uop_MOVZX(ir, IREG_flags_res, IREG_temp1_B);
|
||||
break;
|
||||
|
||||
case 0x20: /*AND*/
|
||||
uop_AND_IMM(ir, IREG_temp0_B, IREG_temp0_B, imm);
|
||||
uop_MEM_STORE_REG(ir, ireg_seg_base(target_seg), IREG_eaaddr, IREG_temp0_B);
|
||||
|
|
@ -826,9 +1376,6 @@ uint32_t rop80(codeblock_t *block, ir_data_t *ir, uint8_t opcode, uint32_t fetch
|
|||
}
|
||||
uint32_t rop81_w(codeblock_t *block, ir_data_t *ir, uint8_t opcode, uint32_t fetchdat, uint32_t op_32, uint32_t op_pc)
|
||||
{
|
||||
if ((fetchdat & 0x30) == 0x10) /*ADC/SBB*/
|
||||
return 0;
|
||||
|
||||
if ((fetchdat & 0xc0) == 0xc0)
|
||||
{
|
||||
int dest_reg = fetchdat & 7;
|
||||
|
|
@ -850,6 +1397,26 @@ uint32_t rop81_w(codeblock_t *block, ir_data_t *ir, uint8_t opcode, uint32_t fet
|
|||
uop_MOVZX(ir, IREG_flags_res, IREG_16(dest_reg));
|
||||
break;
|
||||
|
||||
case 0x10: /*ADC*/
|
||||
get_cf(ir, IREG_temp1);
|
||||
uop_MOVZX(ir, IREG_flags_op1, IREG_16(dest_reg));
|
||||
uop_ADD_IMM(ir, IREG_16(dest_reg), IREG_16(dest_reg), imm);
|
||||
uop_MOV_IMM(ir, IREG_flags_op2, imm);
|
||||
uop_ADD(ir, IREG_16(dest_reg), IREG_16(dest_reg), IREG_temp1_W);
|
||||
uop_MOV_IMM(ir, IREG_flags_op, FLAGS_ADC16);
|
||||
uop_MOVZX(ir, IREG_flags_res, IREG_16(dest_reg));
|
||||
break;
|
||||
|
||||
case 0x18: /*SBB*/
|
||||
get_cf(ir, IREG_temp1);
|
||||
uop_MOVZX(ir, IREG_flags_op1, IREG_16(dest_reg));
|
||||
uop_SUB_IMM(ir, IREG_16(dest_reg), IREG_16(dest_reg), imm);
|
||||
uop_MOV_IMM(ir, IREG_flags_op2, imm);
|
||||
uop_SUB(ir, IREG_16(dest_reg), IREG_16(dest_reg), IREG_temp1_W);
|
||||
uop_MOV_IMM(ir, IREG_flags_op, FLAGS_SBC16);
|
||||
uop_MOVZX(ir, IREG_flags_res, IREG_16(dest_reg));
|
||||
break;
|
||||
|
||||
case 0x20: /*AND*/
|
||||
uop_AND_IMM(ir, IREG_16(dest_reg), IREG_16(dest_reg), imm);
|
||||
uop_MOV_IMM(ir, IREG_flags_op, FLAGS_ZN16);
|
||||
|
|
@ -914,6 +1481,28 @@ uint32_t rop81_w(codeblock_t *block, ir_data_t *ir, uint8_t opcode, uint32_t fet
|
|||
uop_MOV_IMM(ir, IREG_flags_op, FLAGS_ZN16);
|
||||
break;
|
||||
|
||||
case 0x10: /*ADC*/
|
||||
get_cf(ir, IREG_temp2);
|
||||
uop_ADD_IMM(ir, IREG_temp1_W, IREG_temp0_W, imm);
|
||||
uop_ADD(ir, IREG_temp1_W, IREG_temp1_W, IREG_temp2_W);
|
||||
uop_MEM_STORE_REG(ir, ireg_seg_base(target_seg), IREG_eaaddr, IREG_temp1_W);
|
||||
uop_MOVZX(ir, IREG_flags_op1, IREG_temp0_W);
|
||||
uop_MOV_IMM(ir, IREG_flags_op2, imm);
|
||||
uop_MOV_IMM(ir, IREG_flags_op, FLAGS_ADC16);
|
||||
uop_MOVZX(ir, IREG_flags_res, IREG_temp1_W);
|
||||
break;
|
||||
|
||||
case 0x18: /*SBB*/
|
||||
get_cf(ir, IREG_temp2);
|
||||
uop_SUB_IMM(ir, IREG_temp1_W, IREG_temp0_W, imm);
|
||||
uop_SUB(ir, IREG_temp1_W, IREG_temp1_W, IREG_temp2_W);
|
||||
uop_MEM_STORE_REG(ir, ireg_seg_base(target_seg), IREG_eaaddr, IREG_temp1_W);
|
||||
uop_MOVZX(ir, IREG_flags_op1, IREG_temp0_W);
|
||||
uop_MOV_IMM(ir, IREG_flags_op2, imm);
|
||||
uop_MOV_IMM(ir, IREG_flags_op, FLAGS_SBC16);
|
||||
uop_MOVZX(ir, IREG_flags_res, IREG_temp1_W);
|
||||
break;
|
||||
|
||||
case 0x20: /*AND*/
|
||||
uop_AND_IMM(ir, IREG_temp0_W, IREG_temp0_W, imm);
|
||||
uop_MEM_STORE_REG(ir, ireg_seg_base(target_seg), IREG_eaaddr, IREG_temp0_W);
|
||||
|
|
@ -955,9 +1544,6 @@ uint32_t rop81_w(codeblock_t *block, ir_data_t *ir, uint8_t opcode, uint32_t fet
|
|||
}
|
||||
uint32_t rop81_l(codeblock_t *block, ir_data_t *ir, uint8_t opcode, uint32_t fetchdat, uint32_t op_32, uint32_t op_pc)
|
||||
{
|
||||
if ((fetchdat & 0x30) == 0x10) /*ADC/SBB*/
|
||||
return 0;
|
||||
|
||||
if ((fetchdat & 0xc0) == 0xc0)
|
||||
{
|
||||
int dest_reg = fetchdat & 7;
|
||||
|
|
@ -979,6 +1565,26 @@ uint32_t rop81_l(codeblock_t *block, ir_data_t *ir, uint8_t opcode, uint32_t fet
|
|||
uop_MOV(ir, IREG_flags_res, IREG_32(dest_reg));
|
||||
break;
|
||||
|
||||
case 0x10: /*ADC*/
|
||||
get_cf(ir, IREG_temp1);
|
||||
uop_MOV(ir, IREG_flags_op1, IREG_32(dest_reg));
|
||||
uop_ADD_IMM(ir, IREG_32(dest_reg), IREG_32(dest_reg), imm);
|
||||
uop_MOV_IMM(ir, IREG_flags_op2, imm);
|
||||
uop_ADD(ir, IREG_32(dest_reg), IREG_32(dest_reg), IREG_temp1);
|
||||
uop_MOV_IMM(ir, IREG_flags_op, FLAGS_ADC32);
|
||||
uop_MOV(ir, IREG_flags_res, IREG_32(dest_reg));
|
||||
break;
|
||||
|
||||
case 0x18: /*SBB*/
|
||||
get_cf(ir, IREG_temp1);
|
||||
uop_MOV(ir, IREG_flags_op1, IREG_32(dest_reg));
|
||||
uop_SUB_IMM(ir, IREG_32(dest_reg), IREG_32(dest_reg), imm);
|
||||
uop_MOV_IMM(ir, IREG_flags_op2, imm);
|
||||
uop_SUB(ir, IREG_32(dest_reg), IREG_32(dest_reg), IREG_temp1);
|
||||
uop_MOV_IMM(ir, IREG_flags_op, FLAGS_SBC32);
|
||||
uop_MOV(ir, IREG_flags_res, IREG_32(dest_reg));
|
||||
break;
|
||||
|
||||
case 0x20: /*AND*/
|
||||
uop_AND_IMM(ir, IREG_32(dest_reg), IREG_32(dest_reg), imm);
|
||||
uop_MOV_IMM(ir, IREG_flags_op, FLAGS_ZN32);
|
||||
|
|
@ -1041,6 +1647,28 @@ uint32_t rop81_l(codeblock_t *block, ir_data_t *ir, uint8_t opcode, uint32_t fet
|
|||
uop_MOV(ir, IREG_flags_res, IREG_temp0);
|
||||
uop_MOV_IMM(ir, IREG_flags_op, FLAGS_ZN32);
|
||||
break;
|
||||
|
||||
case 0x10: /*ADC*/
|
||||
get_cf(ir, IREG_temp2);
|
||||
uop_ADD_IMM(ir, IREG_temp1, IREG_temp0, imm);
|
||||
uop_ADD(ir, IREG_temp1, IREG_temp1, IREG_temp2);
|
||||
uop_MEM_STORE_REG(ir, ireg_seg_base(target_seg), IREG_eaaddr, IREG_temp1);
|
||||
uop_MOV(ir, IREG_flags_op1, IREG_temp0);
|
||||
uop_MOV_IMM(ir, IREG_flags_op2, imm);
|
||||
uop_MOV_IMM(ir, IREG_flags_op, FLAGS_ADC32);
|
||||
uop_MOV(ir, IREG_flags_res, IREG_temp1);
|
||||
break;
|
||||
|
||||
case 0x18: /*SBB*/
|
||||
get_cf(ir, IREG_temp2);
|
||||
uop_SUB_IMM(ir, IREG_temp1, IREG_temp0, imm);
|
||||
uop_SUB(ir, IREG_temp1, IREG_temp1, IREG_temp2);
|
||||
uop_MEM_STORE_REG(ir, ireg_seg_base(target_seg), IREG_eaaddr, IREG_temp1);
|
||||
uop_MOV(ir, IREG_flags_op1, IREG_temp0);
|
||||
uop_MOV_IMM(ir, IREG_flags_op2, imm);
|
||||
uop_MOV_IMM(ir, IREG_flags_op, FLAGS_SBC32);
|
||||
uop_MOV(ir, IREG_flags_res, IREG_temp1);
|
||||
break;
|
||||
|
||||
case 0x20: /*AND*/
|
||||
uop_AND_IMM(ir, IREG_temp0, IREG_temp0, imm);
|
||||
|
|
@ -1083,9 +1711,6 @@ uint32_t rop81_l(codeblock_t *block, ir_data_t *ir, uint8_t opcode, uint32_t fet
|
|||
|
||||
uint32_t rop83_w(codeblock_t *block, ir_data_t *ir, uint8_t opcode, uint32_t fetchdat, uint32_t op_32, uint32_t op_pc)
|
||||
{
|
||||
if ((fetchdat & 0x30) == 0x10) /*ADC/SBB*/
|
||||
return 0;
|
||||
|
||||
if ((fetchdat & 0xc0) == 0xc0)
|
||||
{
|
||||
int dest_reg = fetchdat & 7;
|
||||
|
|
@ -1107,6 +1732,26 @@ uint32_t rop83_w(codeblock_t *block, ir_data_t *ir, uint8_t opcode, uint32_t fet
|
|||
uop_MOVZX(ir, IREG_flags_res, IREG_16(dest_reg));
|
||||
break;
|
||||
|
||||
case 0x10: /*ADC*/
|
||||
get_cf(ir, IREG_temp1);
|
||||
uop_MOVZX(ir, IREG_flags_op1, IREG_16(dest_reg));
|
||||
uop_ADD_IMM(ir, IREG_16(dest_reg), IREG_16(dest_reg), imm);
|
||||
uop_MOV_IMM(ir, IREG_flags_op2, imm);
|
||||
uop_ADD(ir, IREG_16(dest_reg), IREG_16(dest_reg), IREG_temp1_W);
|
||||
uop_MOV_IMM(ir, IREG_flags_op, FLAGS_ADC16);
|
||||
uop_MOVZX(ir, IREG_flags_res, IREG_16(dest_reg));
|
||||
break;
|
||||
|
||||
case 0x18: /*SBB*/
|
||||
get_cf(ir, IREG_temp1);
|
||||
uop_MOVZX(ir, IREG_flags_op1, IREG_16(dest_reg));
|
||||
uop_SUB_IMM(ir, IREG_16(dest_reg), IREG_16(dest_reg), imm);
|
||||
uop_MOV_IMM(ir, IREG_flags_op2, imm);
|
||||
uop_SUB(ir, IREG_16(dest_reg), IREG_16(dest_reg), IREG_temp1_W);
|
||||
uop_MOV_IMM(ir, IREG_flags_op, FLAGS_SBC16);
|
||||
uop_MOVZX(ir, IREG_flags_res, IREG_16(dest_reg));
|
||||
break;
|
||||
|
||||
case 0x20: /*AND*/
|
||||
uop_AND_IMM(ir, IREG_16(dest_reg), IREG_16(dest_reg), imm);
|
||||
uop_MOV_IMM(ir, IREG_flags_op, FLAGS_ZN16);
|
||||
|
|
@ -1170,6 +1815,28 @@ uint32_t rop83_w(codeblock_t *block, ir_data_t *ir, uint8_t opcode, uint32_t fet
|
|||
uop_MOVZX(ir, IREG_flags_res, IREG_temp0_W);
|
||||
uop_MOV_IMM(ir, IREG_flags_op, FLAGS_ZN16);
|
||||
break;
|
||||
|
||||
case 0x10: /*ADC*/
|
||||
get_cf(ir, IREG_temp2);
|
||||
uop_ADD_IMM(ir, IREG_temp1_W, IREG_temp0_W, imm);
|
||||
uop_ADD(ir, IREG_temp1_W, IREG_temp1_W, IREG_temp2_W);
|
||||
uop_MEM_STORE_REG(ir, ireg_seg_base(target_seg), IREG_eaaddr, IREG_temp1_W);
|
||||
uop_MOVZX(ir, IREG_flags_op1, IREG_temp0_W);
|
||||
uop_MOV_IMM(ir, IREG_flags_op2, imm);
|
||||
uop_MOV_IMM(ir, IREG_flags_op, FLAGS_ADC16);
|
||||
uop_MOVZX(ir, IREG_flags_res, IREG_temp1_W);
|
||||
break;
|
||||
|
||||
case 0x18: /*SBB*/
|
||||
get_cf(ir, IREG_temp2);
|
||||
uop_SUB_IMM(ir, IREG_temp1_W, IREG_temp0_W, imm);
|
||||
uop_SUB(ir, IREG_temp1_W, IREG_temp1_W, IREG_temp2_W);
|
||||
uop_MEM_STORE_REG(ir, ireg_seg_base(target_seg), IREG_eaaddr, IREG_temp1_W);
|
||||
uop_MOVZX(ir, IREG_flags_op1, IREG_temp0_W);
|
||||
uop_MOV_IMM(ir, IREG_flags_op2, imm);
|
||||
uop_MOV_IMM(ir, IREG_flags_op, FLAGS_SBC16);
|
||||
uop_MOVZX(ir, IREG_flags_res, IREG_temp1_W);
|
||||
break;
|
||||
|
||||
case 0x20: /*AND*/
|
||||
uop_AND_IMM(ir, IREG_temp0_W, IREG_temp0_W, imm);
|
||||
|
|
@ -1212,11 +1879,6 @@ uint32_t rop83_w(codeblock_t *block, ir_data_t *ir, uint8_t opcode, uint32_t fet
|
|||
}
|
||||
uint32_t rop83_l(codeblock_t *block, ir_data_t *ir, uint8_t opcode, uint32_t fetchdat, uint32_t op_32, uint32_t op_pc)
|
||||
{
|
||||
uint32_t imm;
|
||||
|
||||
if ((fetchdat & 0x30) == 0x10) /*ADC/SBB*/
|
||||
return 0;
|
||||
|
||||
if ((fetchdat & 0xc0) == 0xc0)
|
||||
{
|
||||
int dest_reg = fetchdat & 7;
|
||||
|
|
@ -1237,6 +1899,26 @@ uint32_t rop83_l(codeblock_t *block, ir_data_t *ir, uint8_t opcode, uint32_t fet
|
|||
uop_MOV_IMM(ir, IREG_flags_op, FLAGS_ZN32);
|
||||
uop_MOV(ir, IREG_flags_res, IREG_32(dest_reg));
|
||||
break;
|
||||
|
||||
case 0x10: /*ADC*/
|
||||
get_cf(ir, IREG_temp1);
|
||||
uop_MOV(ir, IREG_flags_op1, IREG_32(dest_reg));
|
||||
uop_ADD_IMM(ir, IREG_32(dest_reg), IREG_32(dest_reg), imm);
|
||||
uop_MOV_IMM(ir, IREG_flags_op2, imm);
|
||||
uop_ADD(ir, IREG_32(dest_reg), IREG_32(dest_reg), IREG_temp1);
|
||||
uop_MOV_IMM(ir, IREG_flags_op, FLAGS_ADC32);
|
||||
uop_MOV(ir, IREG_flags_res, IREG_32(dest_reg));
|
||||
break;
|
||||
|
||||
case 0x18: /*SBB*/
|
||||
get_cf(ir, IREG_temp1);
|
||||
uop_MOV(ir, IREG_flags_op1, IREG_32(dest_reg));
|
||||
uop_SUB_IMM(ir, IREG_32(dest_reg), IREG_32(dest_reg), imm);
|
||||
uop_MOV_IMM(ir, IREG_flags_op2, imm);
|
||||
uop_SUB(ir, IREG_32(dest_reg), IREG_32(dest_reg), IREG_temp1);
|
||||
uop_MOV_IMM(ir, IREG_flags_op, FLAGS_SBC32);
|
||||
uop_MOV(ir, IREG_flags_res, IREG_32(dest_reg));
|
||||
break;
|
||||
|
||||
case 0x20: /*AND*/
|
||||
uop_AND_IMM(ir, IREG_32(dest_reg), IREG_32(dest_reg), imm);
|
||||
|
|
@ -1272,6 +1954,7 @@ uint32_t rop83_l(codeblock_t *block, ir_data_t *ir, uint8_t opcode, uint32_t fet
|
|||
else
|
||||
{
|
||||
x86seg *target_seg;
|
||||
uint32_t imm;
|
||||
|
||||
uop_MOV_IMM(ir, IREG_oldpc, cpu_state.oldpc);
|
||||
target_seg = codegen_generate_ea(ir, op_ea_seg, fetchdat, op_ssegs, &op_pc, op_32, 0);
|
||||
|
|
@ -1299,6 +1982,28 @@ uint32_t rop83_l(codeblock_t *block, ir_data_t *ir, uint8_t opcode, uint32_t fet
|
|||
uop_MOV(ir, IREG_flags_res, IREG_temp0);
|
||||
uop_MOV_IMM(ir, IREG_flags_op, FLAGS_ZN32);
|
||||
break;
|
||||
|
||||
case 0x10: /*ADC*/
|
||||
get_cf(ir, IREG_temp2);
|
||||
uop_ADD_IMM(ir, IREG_temp1, IREG_temp0, imm);
|
||||
uop_ADD(ir, IREG_temp1, IREG_temp1, IREG_temp2);
|
||||
uop_MEM_STORE_REG(ir, ireg_seg_base(target_seg), IREG_eaaddr, IREG_temp1);
|
||||
uop_MOV(ir, IREG_flags_op1, IREG_temp0);
|
||||
uop_MOV_IMM(ir, IREG_flags_op2, imm);
|
||||
uop_MOV_IMM(ir, IREG_flags_op, FLAGS_ADC32);
|
||||
uop_MOV(ir, IREG_flags_res, IREG_temp1);
|
||||
break;
|
||||
|
||||
case 0x18: /*SBB*/
|
||||
get_cf(ir, IREG_temp2);
|
||||
uop_SUB_IMM(ir, IREG_temp1, IREG_temp0, imm);
|
||||
uop_SUB(ir, IREG_temp1, IREG_temp1, IREG_temp2);
|
||||
uop_MEM_STORE_REG(ir, ireg_seg_base(target_seg), IREG_eaaddr, IREG_temp1);
|
||||
uop_MOV(ir, IREG_flags_op1, IREG_temp0);
|
||||
uop_MOV_IMM(ir, IREG_flags_op2, imm);
|
||||
uop_MOV_IMM(ir, IREG_flags_op, FLAGS_SBC32);
|
||||
uop_MOV(ir, IREG_flags_res, IREG_temp1);
|
||||
break;
|
||||
|
||||
case 0x20: /*AND*/
|
||||
uop_AND_IMM(ir, IREG_temp0, IREG_temp0, imm);
|
||||
|
|
|
|||
Loading…
Reference in a new issue