diff options
author | Cyrille Bagard <nocbos@gmail.com> | 2008-09-20 15:28:57 (GMT) |
---|---|---|
committer | Cyrille Bagard <nocbos@gmail.com> | 2008-09-20 15:28:57 (GMT) |
commit | 2ccf097c9344465944089bebbc2ffd66ac93e1fd (patch) | |
tree | 74c535a32198bb04139cd85431e7c6ed780c5973 /src/arch/x86/op_jump.c | |
parent | 286c0872cc37d3dd6c2633cb61e4680123015d52 (diff) |
Centralized all the code used to decode instructions.
git-svn-id: svn://svn.gna.org/svn/chrysalide/trunk@32 abbe820e-26c8-41b2-8c08-b7b2b41f8b0a
Diffstat (limited to 'src/arch/x86/op_jump.c')
-rw-r--r-- | src/arch/x86/op_jump.c | 30 |
1 files changed, 3 insertions, 27 deletions
diff --git a/src/arch/x86/op_jump.c b/src/arch/x86/op_jump.c index 39683c0..b301b10 100644 --- a/src/arch/x86/op_jump.c +++ b/src/arch/x86/op_jump.c @@ -49,25 +49,17 @@ asm_x86_instr *x86_read_instr_je_8(const uint8_t *data, off_t *pos, off_t len, uint64_t offset, const asm_x86_processor *proc) { asm_x86_instr *result; /* Instruction à retourner */ - asm_x86_operand *address; /* Adresse visée réelle */ result = (asm_x86_instr *)calloc(1, sizeof(asm_x86_instr)); ASM_INSTRUCTION(result)->opcode = data[(*pos)++]; - /* TODO : 64bits */ - address = x86_create_rel8_operand_in_32b(offset + 1, data, pos, len); - if (address == NULL) + if (!x86_read_one_operand(result, data, pos, len, X86_OTP_REL8, offset)) { free(result); return NULL; } - ASM_INSTRUCTION(result)->operands = (asm_operand **)calloc(1, sizeof(asm_operand *)); - ASM_INSTRUCTION(result)->operands_count = 1; - - ASM_INSTRUCTION(result)->operands[0] = ASM_OPERAND(address); - return result; } @@ -92,25 +84,17 @@ asm_x86_instr *x86_read_instr_je_8(const uint8_t *data, off_t *pos, off_t len, u asm_x86_instr *x86_read_instr_jne_8(const uint8_t *data, off_t *pos, off_t len, uint64_t offset, const asm_x86_processor *proc) { asm_x86_instr *result; /* Instruction à retourner */ - asm_x86_operand *address; /* Adresse visée réelle */ result = (asm_x86_instr *)calloc(1, sizeof(asm_x86_instr)); ASM_INSTRUCTION(result)->opcode = data[(*pos)++]; - /* TODO : 64bits */ - address = x86_create_rel8_operand_in_32b(offset + 1, data, pos, len); - if (address == NULL) + if (!x86_read_one_operand(result, data, pos, len, X86_OTP_REL8, offset)) { free(result); return NULL; } - ASM_INSTRUCTION(result)->operands = (asm_operand **)calloc(1, sizeof(asm_operand *)); - ASM_INSTRUCTION(result)->operands_count = 1; - - ASM_INSTRUCTION(result)->operands[0] = ASM_OPERAND(address); - return result; } @@ -135,25 +119,17 @@ asm_x86_instr *x86_read_instr_jne_8(const uint8_t *data, off_t *pos, off_t len, asm_x86_instr *x86_read_instr_jmp_8(const uint8_t *data, off_t *pos, off_t len, uint64_t offset, const asm_x86_processor *proc) { asm_x86_instr *result; /* Instruction à retourner */ - asm_x86_operand *address; /* Adresse visée réelle */ result = (asm_x86_instr *)calloc(1, sizeof(asm_x86_instr)); ASM_INSTRUCTION(result)->opcode = data[(*pos)++]; - /* TODO : 64bits */ - address = x86_create_rel8_operand_in_32b(offset + 1, data, pos, len); - if (address == NULL) + if (!x86_read_one_operand(result, data, pos, len, X86_OTP_REL8, offset)) { free(result); return NULL; } - ASM_INSTRUCTION(result)->operands = (asm_operand **)calloc(1, sizeof(asm_operand *)); - ASM_INSTRUCTION(result)->operands_count = 1; - - ASM_INSTRUCTION(result)->operands[0] = ASM_OPERAND(address); - return result; } |