Signed-off-by: Vegard Nossum <vegard.nos...@gmail.com> --- arch/x86/emit-code.c | 23 +++++++++++++++++++++++ arch/x86/include/arch/instruction.h | 2 ++ arch/x86/instruction.c | 10 ++++++++++ arch/x86/use-def.c | 1 + 4 files changed, 36 insertions(+), 0 deletions(-)
diff --git a/arch/x86/emit-code.c b/arch/x86/emit-code.c index 91fcf2b..887c716 100644 --- a/arch/x86/emit-code.c +++ b/arch/x86/emit-code.c @@ -1050,6 +1050,28 @@ static void emit_sbb_reg_reg(struct buffer *buf, struct operand *src, emit_reg_reg(buf, 0x19, src, dest); } +static void __emit_test_imm_memdisp(struct buffer *buf, + long imm, long disp) +{ + /* XXX: Supports only byte or long imms */ + + if (is_imm_8(imm)) + emit(buf, 0xf6); + else + emit(buf, 0xf7); + + emit(buf, 0x04); + emit(buf, 0x25); + emit_imm32(buf, disp); + emit_imm(buf, imm); +} + +static void emit_test_imm_memdisp(struct buffer *buf, + struct operand *imm, struct operand *disp) +{ + __emit_test_imm_memdisp(buf, imm->imm, disp->imm); +} + void emit_prolog(struct buffer *buf, unsigned long nr_locals) { /* Unconditionally push callee-saved registers */ @@ -1812,6 +1834,7 @@ struct emitter emitters[] = { DECL_EMITTER(INSN_SUB_IMM_REG, emit_sub_imm_reg, TWO_OPERANDS), DECL_EMITTER(INSN_SUB_MEMBASE_REG, emit_sub_membase_reg, TWO_OPERANDS), DECL_EMITTER(INSN_SUB_REG_REG, emit_sub_reg_reg, TWO_OPERANDS), + DECL_EMITTER(INSN_TEST_IMM_MEMDISP, emit_test_imm_memdisp, TWO_OPERANDS), DECL_EMITTER(INSN_TEST_MEMBASE_REG, emit_test_membase_reg, TWO_OPERANDS), DECL_EMITTER(INSN_XOR_MEMBASE_REG, emit_xor_membase_reg, TWO_OPERANDS), DECL_EMITTER(INSN_XOR_IMM_REG, emit_xor_imm_reg, TWO_OPERANDS), diff --git a/arch/x86/include/arch/instruction.h b/arch/x86/include/arch/instruction.h index 9140484..2ee8787 100644 --- a/arch/x86/include/arch/instruction.h +++ b/arch/x86/include/arch/instruction.h @@ -165,6 +165,7 @@ enum insn_type { INSN_SUB_IMM_REG, INSN_SUB_MEMBASE_REG, INSN_SUB_REG_REG, + INSN_TEST_IMM_MEMDISP, INSN_TEST_MEMBASE_REG, INSN_XOR_MEMBASE_REG, INSN_XOR_IMM_REG, @@ -221,6 +222,7 @@ struct insn *reg_reg_insn(enum insn_type, struct var_info *, struct var_info *); struct insn *imm_reg_insn(enum insn_type, unsigned long, struct var_info *); struct insn *memdisp_reg_insn(enum insn_type, unsigned long, struct var_info *); struct insn *reg_memdisp_insn(enum insn_type, struct var_info *, unsigned long); +struct insn *imm_memdisp_insn(enum insn_type, long, long); struct insn *imm_membase_insn(enum insn_type, unsigned long, struct var_info *, long); struct insn *imm_insn(enum insn_type, unsigned long); struct insn *rel_insn(enum insn_type, unsigned long); diff --git a/arch/x86/instruction.c b/arch/x86/instruction.c index f6ffe20..720dfec 100644 --- a/arch/x86/instruction.c +++ b/arch/x86/instruction.c @@ -280,6 +280,16 @@ struct insn *reg_memdisp_insn(enum insn_type insn_type, return insn; } +struct insn *imm_memdisp_insn(enum insn_type insn_type, long imm, long disp) +{ + struct insn *insn = alloc_insn(insn_type); + if (insn) { + init_imm_operand(insn, 0, imm); + init_imm_operand(insn, 1, imm); + } + return insn; +} + struct insn *imm_membase_insn(enum insn_type insn_type, unsigned long imm, struct var_info *base_reg, long disp) { diff --git a/arch/x86/use-def.c b/arch/x86/use-def.c index 86218b7..02baea2 100644 --- a/arch/x86/use-def.c +++ b/arch/x86/use-def.c @@ -148,6 +148,7 @@ static struct insn_info insn_infos[] = { DECLARE_INFO(INSN_SUB_IMM_REG, USE_DST | DEF_DST), DECLARE_INFO(INSN_SUB_MEMBASE_REG, USE_SRC | USE_DST | DEF_DST), DECLARE_INFO(INSN_SUB_REG_REG, USE_SRC | USE_DST | DEF_DST), + DECLARE_INFO(INSN_TEST_IMM_MEMDISP, USE_NONE | DEF_NONE), DECLARE_INFO(INSN_TEST_MEMBASE_REG, USE_SRC | USE_DST | DEF_NONE), DECLARE_INFO(INSN_XOR_MEMBASE_REG, USE_SRC | USE_DST | DEF_DST), DECLARE_INFO(INSN_XOR_IMM_REG, USE_SRC | USE_DST | DEF_DST), -- 1.6.0.6 ------------------------------------------------------------------------------ Let Crystal Reports handle the reporting - Free Crystal Reports 2008 30-Day trial. Simplify your report design, integration and deployment - and focus on what you do best, core application coding. Discover what's new with Crystal Reports now. http://p.sf.net/sfu/bobj-july _______________________________________________ Jatovm-devel mailing list Jatovm-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/jatovm-devel