diff options
author | Cyrille Bagard <nocbos@gmail.com> | 2008-09-09 22:52:57 (GMT) |
---|---|---|
committer | Cyrille Bagard <nocbos@gmail.com> | 2008-09-09 22:52:57 (GMT) |
commit | 15387adcbd3e27fe581754c0ee56edc64272d58e (patch) | |
tree | 45c655c89c7da57fff822569c4bc3dc655032eb6 /src/arch/x86/operand.c | |
parent | b77dcf34b9b2308978e1c6333b34cde9f0e27a8c (diff) |
Supported the 'moffs' type of operand.
git-svn-id: svn://svn.gna.org/svn/chrysalide/trunk@28 abbe820e-26c8-41b2-8c08-b7b2b41f8b0a
Diffstat (limited to 'src/arch/x86/operand.c')
-rw-r--r-- | src/arch/x86/operand.c | 118 |
1 files changed, 118 insertions, 0 deletions
diff --git a/src/arch/x86/operand.c b/src/arch/x86/operand.c index a232211..281c139 100644 --- a/src/arch/x86/operand.c +++ b/src/arch/x86/operand.c @@ -1070,3 +1070,121 @@ void x86_print_reg_operand(const asm_x86_operand *operand, char *buffer, size_t } } + + + + + + + + + + +/* ---------------------------------------------------------------------------------- */ +/* OPERANDES D'EMPLACEMENTS MEMOIRE */ +/* ---------------------------------------------------------------------------------- */ + + +/****************************************************************************** +* * +* Paramètres : data = flux de données à analyser. * +* pos = position courante dans ce flux. [OUT] * +* len = taille totale des données à analyser. * +* * +* Description : Crée une opérande à partir d'un emplacement mémoire 8 bits. * +* * +* Retour : Opérande mise en place ou NULL. * +* * +* Remarques : - * +* * +******************************************************************************/ + +asm_x86_operand *x86_create_moffs8_operand(const uint8_t *data, off_t *pos, off_t len) +{ + asm_x86_operand *result; /* Emplacement à retourner */ + + result = create_new_x86_operand(); + + if (!fill_imm_operand(ASM_OPERAND(result), AOS_8_BITS, data, pos, len)) + { + free(result); + return NULL; + } + + ASM_OPERAND(result)->type = AOT_MOFFS; + + return result; + +} + + +/****************************************************************************** +* * +* Paramètres : data = flux de données à analyser. * +* pos = position courante dans ce flux. [OUT] * +* len = taille totale des données à analyser. * +* is_reg32 = indique si le registre est un registre 32 bits. * +* * +* Description : Crée une opérande à partir d'un emplacement mémoire 16/32b. * +* * +* Retour : Opérande mise en place ou NULL. * +* * +* Remarques : - * +* * +******************************************************************************/ + +asm_x86_operand *x86_create_moffs1632_operand(const uint8_t *data, off_t *pos, off_t len, bool is_reg32) +{ + asm_x86_operand *result; /* Emplacement à retourner */ + + result = create_new_x86_operand(); + + if (!fill_imm_operand(ASM_OPERAND(result), is_reg32 ? AOS_32_BITS : AOS_16_BITS, data, pos, len)) + { + free(result); + return NULL; + } + + ASM_OPERAND(result)->type = AOT_MOFFS; + + return result; + +} + + +/****************************************************************************** +* * +* Paramètres : operand = instruction à traiter. * +* buffer = tampon de sortie mis à disposition. [OUT] * +* len = taille de ce tampon. * +* syntax = type de représentation demandée. * +* * +* Description : Traduit une opérande d'emplacement mémoire en texte. * +* * +* Retour : - * +* * +* Remarques : - * +* * +******************************************************************************/ + +void x86_print_moffs_operand(const asm_x86_operand *operand, char *buffer, size_t len, AsmSyntax syntax) +{ + size_t pos; /* Position de traitement */ + + switch (syntax) + { + case ASX_INTEL: + if (len > 3) + { + strcpy(buffer, "ds:"); + print_imm_operand(ASM_OPERAND(operand), &buffer[3], len - 3, ASX_INTEL); + } + break; + + case ASX_ATT: + print_imm_operand(ASM_OPERAND(operand), buffer, len, ASX_INTEL); + break; + + } + +} |