Added recompiled versions of 8 and 16 bit immediate->reg and reg->reg versions of MOV, ADD, SUB, CMP, AND, OR and XOR.
This commit is contained in:
parent
e4e0f76d5c
commit
648aa0e3e8
17 changed files with 3006 additions and 231 deletions
|
|
@ -8,6 +8,32 @@
|
|||
#include "codegen_ops.h"
|
||||
#include "codegen_ops_arith.h"
|
||||
|
||||
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);
|
||||
|
||||
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_MOV_IMM(ir, IREG_flags_op, FLAGS_ADD8);
|
||||
uop_MOVZX(ir, IREG_flags_res, IREG_AL);
|
||||
|
||||
codegen_flags_changed = 1;
|
||||
return op_pc + 1;
|
||||
}
|
||||
uint32_t ropADD_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);
|
||||
|
||||
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_MOV_IMM(ir, IREG_flags_op, FLAGS_ADD16);
|
||||
uop_MOVZX(ir, IREG_flags_res, IREG_AX);
|
||||
|
||||
codegen_flags_changed = 1;
|
||||
return op_pc + 2;
|
||||
}
|
||||
uint32_t ropADD_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);
|
||||
|
|
@ -21,6 +47,70 @@ uint32_t ropADD_EAX_imm(codeblock_t *block, ir_data_t *ir, uint8_t opcode, uint3
|
|||
codegen_flags_changed = 1;
|
||||
return op_pc + 4;
|
||||
}
|
||||
uint32_t ropADD_b_rm(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 & 7, dest_reg = (fetchdat >> 3) & 7;
|
||||
|
||||
if ((fetchdat & 0xc0) != 0xc0)
|
||||
return 0;
|
||||
|
||||
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_MOV_IMM(ir, IREG_flags_op, FLAGS_ADD8);
|
||||
uop_MOVZX(ir, IREG_flags_res, IREG_8(dest_reg));
|
||||
|
||||
codegen_flags_changed = 1;
|
||||
return op_pc + 1;
|
||||
}
|
||||
uint32_t ropADD_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, dest_reg = fetchdat & 7;
|
||||
|
||||
if ((fetchdat & 0xc0) != 0xc0)
|
||||
return 0;
|
||||
|
||||
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_MOV_IMM(ir, IREG_flags_op, FLAGS_ADD8);
|
||||
uop_MOVZX(ir, IREG_flags_res, IREG_8(dest_reg));
|
||||
|
||||
codegen_flags_changed = 1;
|
||||
return op_pc + 1;
|
||||
}
|
||||
uint32_t ropADD_w_rm(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 & 7, dest_reg = (fetchdat >> 3) & 7;
|
||||
|
||||
if ((fetchdat & 0xc0) != 0xc0)
|
||||
return 0;
|
||||
|
||||
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_MOV_IMM(ir, IREG_flags_op, FLAGS_ADD16);
|
||||
uop_MOVZX(ir, IREG_flags_res, IREG_16(dest_reg));
|
||||
|
||||
codegen_flags_changed = 1;
|
||||
return op_pc + 1;
|
||||
}
|
||||
uint32_t ropADD_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, dest_reg = fetchdat & 7;
|
||||
|
||||
if ((fetchdat & 0xc0) != 0xc0)
|
||||
return 0;
|
||||
|
||||
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_MOV_IMM(ir, IREG_flags_op, FLAGS_ADD16);
|
||||
uop_MOVZX(ir, IREG_flags_res, IREG_16(dest_reg));
|
||||
|
||||
codegen_flags_changed = 1;
|
||||
return op_pc + 1;
|
||||
}
|
||||
uint32_t ropADD_l_rm(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 & 7, dest_reg = (fetchdat >> 3) & 7;
|
||||
|
|
@ -54,6 +144,32 @@ uint32_t ropADD_l_rmw(codeblock_t *block, ir_data_t *ir, uint8_t opcode, uint32_
|
|||
return op_pc + 1;
|
||||
}
|
||||
|
||||
uint32_t ropCMP_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);
|
||||
|
||||
uop_MOVZX(ir, IREG_flags_op1, IREG_AL);
|
||||
uop_SUB_IMM(ir, IREG_flags_res_B, IREG_AL, imm_data);
|
||||
uop_MOVZX(ir, IREG_flags_res, IREG_flags_res_B);
|
||||
uop_MOV_IMM(ir, IREG_flags_op2, imm_data);
|
||||
uop_MOV_IMM(ir, IREG_flags_op, FLAGS_SUB8);
|
||||
|
||||
codegen_flags_changed = 1;
|
||||
return op_pc + 1;
|
||||
}
|
||||
uint32_t ropCMP_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);
|
||||
|
||||
uop_MOVZX(ir, IREG_flags_op1, IREG_AX);
|
||||
uop_SUB_IMM(ir, IREG_flags_res_W, IREG_AX, imm_data);
|
||||
uop_MOVZX(ir, IREG_flags_res, IREG_flags_res_W);
|
||||
uop_MOV_IMM(ir, IREG_flags_op2, imm_data);
|
||||
uop_MOV_IMM(ir, IREG_flags_op, FLAGS_SUB16);
|
||||
|
||||
codegen_flags_changed = 1;
|
||||
return op_pc + 2;
|
||||
}
|
||||
uint32_t ropCMP_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);
|
||||
|
|
@ -66,6 +182,70 @@ uint32_t ropCMP_EAX_imm(codeblock_t *block, ir_data_t *ir, uint8_t opcode, uint3
|
|||
codegen_flags_changed = 1;
|
||||
return op_pc + 4;
|
||||
}
|
||||
uint32_t ropCMP_b_rm(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 & 7, dest_reg = (fetchdat >> 3) & 7;
|
||||
|
||||
if ((fetchdat & 0xc0) != 0xc0)
|
||||
return 0;
|
||||
|
||||
uop_MOVZX(ir, IREG_flags_op1, IREG_8(dest_reg));
|
||||
uop_MOVZX(ir, IREG_flags_op2, IREG_8(src_reg));
|
||||
uop_SUB(ir, IREG_flags_res_B, IREG_8(dest_reg), IREG_8(src_reg));
|
||||
uop_MOVZX(ir, IREG_flags_res, IREG_flags_res_B);
|
||||
uop_MOV_IMM(ir, IREG_flags_op, FLAGS_SUB8);
|
||||
|
||||
codegen_flags_changed = 1;
|
||||
return op_pc + 1;
|
||||
}
|
||||
uint32_t ropCMP_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, dest_reg = fetchdat & 7;
|
||||
|
||||
if ((fetchdat & 0xc0) != 0xc0)
|
||||
return 0;
|
||||
|
||||
uop_MOVZX(ir, IREG_flags_op1, IREG_8(dest_reg));
|
||||
uop_MOVZX(ir, IREG_flags_op2, IREG_8(src_reg));
|
||||
uop_SUB(ir, IREG_flags_res_B, IREG_8(dest_reg), IREG_8(src_reg));
|
||||
uop_MOVZX(ir, IREG_flags_res, IREG_flags_res_B);
|
||||
uop_MOV_IMM(ir, IREG_flags_op, FLAGS_SUB8);
|
||||
|
||||
codegen_flags_changed = 1;
|
||||
return op_pc + 1;
|
||||
}
|
||||
uint32_t ropCMP_w_rm(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 & 7, dest_reg = (fetchdat >> 3) & 7;
|
||||
|
||||
if ((fetchdat & 0xc0) != 0xc0)
|
||||
return 0;
|
||||
|
||||
uop_MOVZX(ir, IREG_flags_op1, IREG_16(dest_reg));
|
||||
uop_MOVZX(ir, IREG_flags_op2, IREG_16(src_reg));
|
||||
uop_SUB(ir, IREG_flags_res_W, IREG_16(dest_reg), IREG_16(src_reg));
|
||||
uop_MOVZX(ir, IREG_flags_res, IREG_flags_res_W);
|
||||
uop_MOV_IMM(ir, IREG_flags_op, FLAGS_SUB16);
|
||||
|
||||
codegen_flags_changed = 1;
|
||||
return op_pc + 1;
|
||||
}
|
||||
uint32_t ropCMP_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, dest_reg = fetchdat & 7;
|
||||
|
||||
if ((fetchdat & 0xc0) != 0xc0)
|
||||
return 0;
|
||||
|
||||
uop_MOVZX(ir, IREG_flags_op1, IREG_16(dest_reg));
|
||||
uop_MOVZX(ir, IREG_flags_op2, IREG_16(src_reg));
|
||||
uop_SUB(ir, IREG_flags_res_W, IREG_16(dest_reg), IREG_16(src_reg));
|
||||
uop_MOVZX(ir, IREG_flags_res, IREG_flags_res_W);
|
||||
uop_MOV_IMM(ir, IREG_flags_op, FLAGS_SUB16);
|
||||
|
||||
codegen_flags_changed = 1;
|
||||
return op_pc + 1;
|
||||
}
|
||||
uint32_t ropCMP_l_rm(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 & 7, dest_reg = (fetchdat >> 3) & 7;
|
||||
|
|
@ -97,6 +277,32 @@ uint32_t ropCMP_l_rmw(codeblock_t *block, ir_data_t *ir, uint8_t opcode, uint32_
|
|||
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);
|
||||
|
||||
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_MOV_IMM(ir, IREG_flags_op, FLAGS_SUB8);
|
||||
uop_MOVZX(ir, IREG_flags_res, IREG_AL);
|
||||
|
||||
codegen_flags_changed = 1;
|
||||
return op_pc + 1;
|
||||
}
|
||||
uint32_t ropSUB_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);
|
||||
|
||||
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_MOV_IMM(ir, IREG_flags_op, FLAGS_SUB16);
|
||||
uop_MOVZX(ir, IREG_flags_res, IREG_AX);
|
||||
|
||||
codegen_flags_changed = 1;
|
||||
return op_pc + 2;
|
||||
}
|
||||
uint32_t ropSUB_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);
|
||||
|
|
@ -110,6 +316,70 @@ uint32_t ropSUB_EAX_imm(codeblock_t *block, ir_data_t *ir, uint8_t opcode, uint3
|
|||
codegen_flags_changed = 1;
|
||||
return op_pc + 4;
|
||||
}
|
||||
uint32_t ropSUB_b_rm(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 & 7, dest_reg = (fetchdat >> 3) & 7;
|
||||
|
||||
if ((fetchdat & 0xc0) != 0xc0)
|
||||
return 0;
|
||||
|
||||
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_MOV_IMM(ir, IREG_flags_op, FLAGS_SUB8);
|
||||
uop_MOVZX(ir, IREG_flags_res, IREG_8(dest_reg));
|
||||
|
||||
codegen_flags_changed = 1;
|
||||
return op_pc + 1;
|
||||
}
|
||||
uint32_t ropSUB_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, dest_reg = fetchdat & 7;
|
||||
|
||||
if ((fetchdat & 0xc0) != 0xc0)
|
||||
return 0;
|
||||
|
||||
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_MOV_IMM(ir, IREG_flags_op, FLAGS_SUB8);
|
||||
uop_MOVZX(ir, IREG_flags_res, IREG_8(dest_reg));
|
||||
|
||||
codegen_flags_changed = 1;
|
||||
return op_pc + 1;
|
||||
}
|
||||
uint32_t ropSUB_w_rm(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 & 7, dest_reg = (fetchdat >> 3) & 7;
|
||||
|
||||
if ((fetchdat & 0xc0) != 0xc0)
|
||||
return 0;
|
||||
|
||||
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_MOV_IMM(ir, IREG_flags_op, FLAGS_SUB16);
|
||||
uop_MOVZX(ir, IREG_flags_res, IREG_16(dest_reg));
|
||||
|
||||
codegen_flags_changed = 1;
|
||||
return op_pc + 1;
|
||||
}
|
||||
uint32_t ropSUB_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, dest_reg = fetchdat & 7;
|
||||
|
||||
if ((fetchdat & 0xc0) != 0xc0)
|
||||
return 0;
|
||||
|
||||
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_MOV_IMM(ir, IREG_flags_op, FLAGS_SUB16);
|
||||
uop_MOVZX(ir, IREG_flags_res, IREG_16(dest_reg));
|
||||
|
||||
codegen_flags_changed = 1;
|
||||
return op_pc + 1;
|
||||
}
|
||||
uint32_t ropSUB_l_rm(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 & 7, dest_reg = (fetchdat >> 3) & 7;
|
||||
|
|
@ -143,6 +413,148 @@ uint32_t ropSUB_l_rmw(codeblock_t *block, ir_data_t *ir, uint8_t opcode, uint32_
|
|||
return op_pc + 1;
|
||||
}
|
||||
|
||||
uint32_t rop80(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 & 7;
|
||||
uint8_t imm;
|
||||
|
||||
if ((fetchdat & 0xc0) != 0xc0)
|
||||
return 0;
|
||||
|
||||
switch (fetchdat & 0x38)
|
||||
{
|
||||
case 0x00: /*ADD*/
|
||||
imm = fastreadb(cs + op_pc + 1);
|
||||
|
||||
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_MOV_IMM(ir, IREG_flags_op, FLAGS_ADD8);
|
||||
uop_MOVZX(ir, IREG_flags_res, IREG_8(dest_reg));
|
||||
break;
|
||||
|
||||
case 0x08: /*OR*/
|
||||
imm = fastreadb(cs + op_pc + 1);
|
||||
|
||||
uop_OR_IMM(ir, IREG_8(dest_reg), IREG_8(dest_reg), imm);
|
||||
uop_MOV_IMM(ir, IREG_flags_op, FLAGS_ZN8);
|
||||
uop_MOVZX(ir, IREG_flags_res, IREG_8(dest_reg));
|
||||
break;
|
||||
|
||||
case 0x20: /*AND*/
|
||||
imm = fastreadb(cs + op_pc + 1);
|
||||
|
||||
uop_AND_IMM(ir, IREG_8(dest_reg), IREG_8(dest_reg), imm);
|
||||
uop_MOV_IMM(ir, IREG_flags_op, FLAGS_ZN8);
|
||||
uop_MOVZX(ir, IREG_flags_res, IREG_8(dest_reg));
|
||||
break;
|
||||
|
||||
case 0x28: /*SUB*/
|
||||
imm = fastreadb(cs + op_pc + 1);
|
||||
|
||||
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_MOV_IMM(ir, IREG_flags_op, FLAGS_SUB8);
|
||||
uop_MOVZX(ir, IREG_flags_res, IREG_8(dest_reg));
|
||||
break;
|
||||
|
||||
case 0x30: /*XOR*/
|
||||
imm = fastreadb(cs + op_pc + 1);
|
||||
|
||||
uop_XOR_IMM(ir, IREG_8(dest_reg), IREG_8(dest_reg), imm);
|
||||
uop_MOV_IMM(ir, IREG_flags_op, FLAGS_ZN8);
|
||||
uop_MOVZX(ir, IREG_flags_res, IREG_8(dest_reg));
|
||||
break;
|
||||
|
||||
case 0x38: /*CMP*/
|
||||
imm = fastreadb(cs + op_pc + 1);
|
||||
|
||||
uop_MOVZX(ir, IREG_flags_op1, IREG_8(dest_reg));
|
||||
uop_SUB_IMM(ir, IREG_flags_res_B, IREG_8(dest_reg), imm);
|
||||
uop_MOVZX(ir, IREG_flags_res, IREG_flags_res_B);
|
||||
uop_MOV_IMM(ir, IREG_flags_op2, imm);
|
||||
uop_MOV_IMM(ir, IREG_flags_op, FLAGS_SUB8);
|
||||
break;
|
||||
|
||||
default:
|
||||
return 0;
|
||||
}
|
||||
|
||||
codegen_flags_changed = 1;
|
||||
return op_pc + 2;
|
||||
}
|
||||
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)
|
||||
{
|
||||
int dest_reg = fetchdat & 7;
|
||||
uint16_t imm;
|
||||
|
||||
if ((fetchdat & 0xc0) != 0xc0)
|
||||
return 0;
|
||||
|
||||
switch (fetchdat & 0x38)
|
||||
{
|
||||
case 0x00: /*ADD*/
|
||||
imm = fastreadw(cs + op_pc + 1);
|
||||
|
||||
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_MOV_IMM(ir, IREG_flags_op, FLAGS_ADD16);
|
||||
uop_MOVZX(ir, IREG_flags_res, IREG_16(dest_reg));
|
||||
break;
|
||||
|
||||
case 0x08: /*OR*/
|
||||
imm = fastreadw(cs + op_pc + 1);
|
||||
|
||||
uop_OR_IMM(ir, IREG_16(dest_reg), IREG_16(dest_reg), imm);
|
||||
uop_MOV_IMM(ir, IREG_flags_op, FLAGS_ZN16);
|
||||
uop_MOVZX(ir, IREG_flags_res, IREG_16(dest_reg));
|
||||
break;
|
||||
|
||||
case 0x20: /*AND*/
|
||||
imm = fastreadw(cs + op_pc + 1);
|
||||
|
||||
uop_AND_IMM(ir, IREG_16(dest_reg), IREG_16(dest_reg), imm);
|
||||
uop_MOV_IMM(ir, IREG_flags_op, FLAGS_ZN16);
|
||||
uop_MOVZX(ir, IREG_flags_res, IREG_16(dest_reg));
|
||||
break;
|
||||
|
||||
case 0x28: /*SUB*/
|
||||
imm = fastreadw(cs + op_pc + 1);
|
||||
|
||||
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_MOV_IMM(ir, IREG_flags_op, FLAGS_SUB16);
|
||||
uop_MOVZX(ir, IREG_flags_res, IREG_16(dest_reg));
|
||||
break;
|
||||
|
||||
case 0x30: /*XOR*/
|
||||
imm = fastreadw(cs + op_pc + 1);
|
||||
|
||||
uop_XOR_IMM(ir, IREG_16(dest_reg), IREG_16(dest_reg), imm);
|
||||
uop_MOV_IMM(ir, IREG_flags_op, FLAGS_ZN16);
|
||||
uop_MOVZX(ir, IREG_flags_res, IREG_16(dest_reg));
|
||||
break;
|
||||
|
||||
case 0x38: /*CMP*/
|
||||
imm = fastreadw(cs + op_pc + 1);
|
||||
|
||||
uop_MOVZX(ir, IREG_flags_op1, IREG_16(dest_reg));
|
||||
uop_SUB_IMM(ir, IREG_flags_res_W, IREG_16(dest_reg), imm);
|
||||
uop_MOVZX(ir, IREG_flags_res, IREG_flags_res_W);
|
||||
uop_MOV_IMM(ir, IREG_flags_op2, imm);
|
||||
uop_MOV_IMM(ir, IREG_flags_op, FLAGS_SUB16);
|
||||
break;
|
||||
|
||||
default:
|
||||
return 0;
|
||||
}
|
||||
|
||||
codegen_flags_changed = 1;
|
||||
return op_pc + 3;
|
||||
}
|
||||
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)
|
||||
{
|
||||
int dest_reg = fetchdat & 7;
|
||||
|
|
@ -213,6 +625,78 @@ uint32_t rop81_l(codeblock_t *block, ir_data_t *ir, uint8_t opcode, uint32_t fet
|
|||
codegen_flags_changed = 1;
|
||||
return op_pc + 5;
|
||||
}
|
||||
|
||||
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)
|
||||
{
|
||||
int dest_reg = fetchdat & 7;
|
||||
uint16_t imm;
|
||||
|
||||
if ((fetchdat & 0xc0) != 0xc0)
|
||||
return 0;
|
||||
|
||||
switch (fetchdat & 0x38)
|
||||
{
|
||||
case 0x00: /*ADD*/
|
||||
imm = (int16_t)(int8_t)fastreadb(cs + op_pc + 1);
|
||||
|
||||
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_MOV_IMM(ir, IREG_flags_op, FLAGS_ADD16);
|
||||
uop_MOVZX(ir, IREG_flags_res, IREG_16(dest_reg));
|
||||
break;
|
||||
|
||||
case 0x08: /*OR*/
|
||||
imm = (int16_t)(int8_t)fastreadb(cs + op_pc + 1);
|
||||
|
||||
uop_OR_IMM(ir, IREG_16(dest_reg), IREG_16(dest_reg), imm);
|
||||
uop_MOV_IMM(ir, IREG_flags_op, FLAGS_ZN16);
|
||||
uop_MOVZX(ir, IREG_flags_res, IREG_16(dest_reg));
|
||||
break;
|
||||
|
||||
case 0x20: /*AND*/
|
||||
imm = (int16_t)(int8_t)fastreadb(cs + op_pc + 1);
|
||||
|
||||
uop_AND_IMM(ir, IREG_16(dest_reg), IREG_16(dest_reg), imm);
|
||||
uop_MOV_IMM(ir, IREG_flags_op, FLAGS_ZN16);
|
||||
uop_MOVZX(ir, IREG_flags_res, IREG_16(dest_reg));
|
||||
break;
|
||||
|
||||
case 0x28: /*SUB*/
|
||||
imm = (int16_t)(int8_t)fastreadb(cs + op_pc + 1);
|
||||
|
||||
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_MOV_IMM(ir, IREG_flags_op, FLAGS_SUB16);
|
||||
uop_MOVZX(ir, IREG_flags_res, IREG_16(dest_reg));
|
||||
break;
|
||||
|
||||
case 0x30: /*XOR*/
|
||||
imm = (int16_t)(int8_t)fastreadb(cs + op_pc + 1);
|
||||
|
||||
uop_XOR_IMM(ir, IREG_16(dest_reg), IREG_16(dest_reg), imm);
|
||||
uop_MOV_IMM(ir, IREG_flags_op, FLAGS_ZN16);
|
||||
uop_MOVZX(ir, IREG_flags_res, IREG_16(dest_reg));
|
||||
break;
|
||||
|
||||
case 0x38: /*CMP*/
|
||||
imm = (int16_t)(int8_t)fastreadb(cs + op_pc + 1);
|
||||
|
||||
uop_MOVZX(ir, IREG_flags_op1, IREG_16(dest_reg));
|
||||
uop_SUB_IMM(ir, IREG_flags_res_W, IREG_16(dest_reg), imm);
|
||||
uop_MOVZX(ir, IREG_flags_res, IREG_flags_res_W);
|
||||
uop_MOV_IMM(ir, IREG_flags_op2, imm);
|
||||
uop_MOV_IMM(ir, IREG_flags_op, FLAGS_SUB16);
|
||||
break;
|
||||
|
||||
default:
|
||||
return 0;
|
||||
}
|
||||
|
||||
codegen_flags_changed = 1;
|
||||
return op_pc + 2;
|
||||
}
|
||||
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)
|
||||
{
|
||||
int dest_reg = fetchdat & 7;
|
||||
|
|
|
|||
Loading…
Reference in a new issue