diff options
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; + + } + +} |