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/operand.h | |
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/operand.h')
-rw-r--r-- | src/arch/x86/operand.h | 54 |
1 files changed, 51 insertions, 3 deletions
diff --git a/src/arch/x86/operand.h b/src/arch/x86/operand.h index 04c0cb6..c48a0be 100644 --- a/src/arch/x86/operand.h +++ b/src/arch/x86/operand.h @@ -29,7 +29,8 @@ #include <stdint.h> -#include "../operand.h" /* TODO : AsmSyntax ? */ +#include "instruction.h" + /* Définition d'une opérande x86 */ @@ -57,13 +58,13 @@ asm_x86_operand *x86_create_content1632_operand(const uint8_t *, off_t *, off_t, asm_x86_operand *x86_create_r8_operand(uint8_t, bool); /* Crée une opérande à partir d'un registre/une mémoire 8 bits. */ -asm_x86_operand *x86_create_rm8_operand(const uint8_t *, off_t *, off_t, bool); +asm_x86_operand *x86_create_rm8_operand(const uint8_t *, off_t *, off_t, ...); /* Crée une opérande renvoyant vers un registre 16 ou 32 bits. */ asm_x86_operand *x86_create_r1632_operand(uint8_t, bool, bool); /* Crée une opérande à partir d'un registre/une mémoire 16/32b. */ -asm_x86_operand *x86_create_rm1632_operand(const uint8_t *, off_t *, off_t, bool, bool); +asm_x86_operand *x86_create_rm1632_operand(const uint8_t *, off_t *, off_t, bool, ...); @@ -92,6 +93,53 @@ void x86_print_moffs_operand(const asm_x86_operand *, char *, size_t, AsmSyntax) /* Crée une opérande à partir d'une adresse relative (8 bits). */ asm_x86_operand *x86_create_rel8_operand_in_32b(uint64_t, const uint8_t *, off_t *, off_t); +/* Crée une opérande à partir d'une adresse relative (16/32b). */ +asm_x86_operand *x86_create_rel1632_operand_in_32b(uint64_t, const uint8_t *, off_t *, off_t, bool); + + + +/* ------------------------- AIDE A LA CREATION D'OPERANDES ------------------------- */ + + +/* Construction d'identifiants typés */ + +#define X86_OTP_IMM_TYPE 0x8000 +#define X86_OTP_REG_TYPE 0x4000 +#define X86_OTP_RM_TYPE 0x2000 + +#define X86_OTP_IMM(b) X86_OTP_IMM_TYPE | (1 << b) +#define X86_OTP_REG(b) X86_OTP_REG_TYPE | (1 << b) +#define X86_OTP_RM(b) X86_OTP_RM_TYPE | (1 << b) + +/* Types d'opérandes supportés */ +typedef enum _X86OperandType +{ + X86_OTP_IMM8 = X86_OTP_IMM(1), /* Valeur immédiate sur 8 bits */ + X86_OTP_IMM1632 = X86_OTP_IMM(2), /* Valeur immédiate sur 16/32b */ + X86_OTP_MOFFS8 = X86_OTP_IMM(3), /* Décallage immédiat 8 bits */ + X86_OTP_MOFFS1632 = X86_OTP_IMM(4), /* Décallage immédiat 16/32b */ + X86_OTP_REL8 = X86_OTP_IMM(5), /* Adresse relative 8 bits */ + X86_OTP_REL1632 = X86_OTP_IMM(6), /* Adresse relative 16/32 bits */ + + X86_OTP_R8 = X86_OTP_REG(1), /* Registre 8 bits */ + X86_OTP_R1632 = X86_OTP_REG(2), /* Registre 16 ou 32 bits */ + X86_OTP_OP_R1632 = X86_OTP_REG(3), /* Registre 16 ou 32 bits */ + + X86_OTP_RM8 = X86_OTP_RM(1), /* Registre 8 bits ou mémoire */ + X86_OTP_RM1632 = X86_OTP_RM(2), /* Registre 16/32b ou mémoire */ + + X86_OTP_AL = 0x0ffe, /* Registre al */ + X86_OTP_E_AX = 0x0fff /* Registre eax ou ax */ + +} X86OperandType; + + +/* Procède à la lecture d'un opérande donné. */ +bool x86_read_one_operand(asm_x86_instr *, const uint8_t *, off_t *, off_t, X86OperandType, ...); + +/* Procède à la lecture de deux opérandes donnés. */ +bool x86_read_two_operands(asm_x86_instr *, const uint8_t *, off_t *, off_t, X86OperandType, X86OperandType, ...); + #endif /* _ARCH_X86_OPERAND_H */ |