This implements emitters for INSN_CMP_* instructions.
Signed-off-by: Eduard - Gabriel Munteanu <[email protected]>
---
arch/x86/emit-code.c | 38 ++++++++++++++++++++++++++++++++++++++
1 files changed, 38 insertions(+), 0 deletions(-)
diff --git a/arch/x86/emit-code.c b/arch/x86/emit-code.c
index 46c586a..c54f428 100644
--- a/arch/x86/emit-code.c
+++ b/arch/x86/emit-code.c
@@ -2165,10 +2165,48 @@ static void emit_mov_reg_memlocal(struct buffer *buf,
__emit_reg_membase(buf, 1, 0x89, src_reg, REG_RBP, disp);
}
+static void __emit_cmp_imm_reg(struct buffer *buf,
+ int rex_w,
+ long imm,
+ enum machine_reg reg)
+{
+ emit_alu_imm_reg(buf, rex_w, 0x07, imm, reg);
+}
+
+static void emit_cmp_imm_reg(struct buffer *buf,
+ struct operand *src,
+ struct operand *dest)
+{
+ int rex_w = is_64bit_reg(dest);
+
+ __emit_cmp_imm_reg(buf, rex_w, src->imm, mach_reg(&dest->reg));
+}
+
+static void emit_cmp_membase_reg(struct buffer *buf,
+ struct operand *src,
+ struct operand *dest)
+{
+ int rex_w = is_64bit_reg(dest);
+
+ emit_membase_reg(buf, rex_w, 0x3b, src, dest);
+}
+
+static void emit_cmp_reg_reg(struct buffer *buf,
+ struct operand *src,
+ struct operand *dest)
+{
+ int rex_w = is_64bit_bin_reg_op(src, dest);
+
+ emit_reg_reg(buf, rex_w, 0x39, src, dest);
+}
+
struct emitter emitters[] = {
GENERIC_X86_EMITTERS,
DECL_EMITTER(INSN_ADD_IMM_REG, emit_add_imm_reg, TWO_OPERANDS),
DECL_EMITTER(INSN_ADD_REG_REG, emit_add_reg_reg, TWO_OPERANDS),
+ DECL_EMITTER(INSN_CMP_IMM_REG, emit_cmp_imm_reg, TWO_OPERANDS),
+ DECL_EMITTER(INSN_CMP_MEMBASE_REG, emit_cmp_membase_reg, TWO_OPERANDS),
+ DECL_EMITTER(INSN_CMP_REG_REG, emit_cmp_reg_reg, TWO_OPERANDS),
DECL_EMITTER(INSN_MOV_IMM_REG, emit_mov_imm_reg, TWO_OPERANDS),
DECL_EMITTER(INSN_MOV_MEMBASE_REG, emit_mov_membase_reg, TWO_OPERANDS),
DECL_EMITTER(INSN_MOV_MEMLOCAL_REG, emit_mov_memlocal_reg,
TWO_OPERANDS),
--
1.6.0.6
------------------------------------------------------------------------------
_______________________________________________
Jatovm-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/jatovm-devel