diff options
Diffstat (limited to 'src/arch/immediate.c')
-rw-r--r-- | src/arch/immediate.c | 87 |
1 files changed, 84 insertions, 3 deletions
diff --git a/src/arch/immediate.c b/src/arch/immediate.c index 3018b6b..ec689b8 100644 --- a/src/arch/immediate.c +++ b/src/arch/immediate.c @@ -95,6 +95,9 @@ static void g_imm_operand_add_text(const GImmOperand *, GRenderingOptions *, Mai /* Ajoute à un tampon GLib le contenu de l'instance spécifiée. */ static void g_imm_operand_to_buffer(const GImmOperand *, GBufferLine *, GRenderingOptions *); +/* Traduit un opérande en version humainement lisible. */ +static void g_imm_operand_print(const GImmOperand *, GBufferLine *, AsmSyntax); + /* Indique le type défini pour un opérande de valeur numérique. */ @@ -134,13 +137,18 @@ static void g_imm_operand_class_init(GImmOperandClass *klass) static void g_imm_operand_init(GImmOperand *operand) { - GContentExporter *parent; /* Instance parente */ + GContentExporter *parent; /* Instance parente #1 */ + GArchOperand *arch; /* Instance parente #2 */ parent = G_CONTENT_EXPORTER(operand); parent->add_text = (add_text_fc)g_imm_operand_add_text; parent->export_buffer = (export_buffer_fc)g_imm_operand_to_buffer; + arch = G_ARCH_OPERAND(operand); + + arch->print = (operand_print_fc)g_imm_operand_print; + operand->zpad = false; } @@ -653,7 +661,52 @@ static size_t g_imm_operand_to_string(const GImmOperand *operand, AsmSyntax synt } break; - default: + case ASX_COUNT: + switch (operand->size) + { + case MDS_UNDEFINED: + result = snprintf(value, VMPA_MAX_SIZE, "0x???"); + break; + + case MDS_4_BITS_UNSIGNED: + result = snprintf(value, VMPA_MAX_SIZE, "%hhu", operand->unsigned_imm.val8); + + case MDS_8_BITS_UNSIGNED: + result = snprintf(value, VMPA_MAX_SIZE, "%hhu", operand->unsigned_imm.val8); + break; + + case MDS_16_BITS_UNSIGNED: + result = snprintf(value, VMPA_MAX_SIZE, "%hu", operand->unsigned_imm.val16); + break; + + case MDS_32_BITS_UNSIGNED: + result = snprintf(value, VMPA_MAX_SIZE, "%u", operand->unsigned_imm.val32); + break; + + case MDS_64_BITS_UNSIGNED: + result = snprintf(value, VMPA_MAX_SIZE, "%llu", operand->unsigned_imm.val64); + break; + + case MDS_4_BITS_SIGNED: + result = snprintf(value, VMPA_MAX_SIZE, "%hhd", operand->signed_imm.val8); + break; + + case MDS_8_BITS_SIGNED: + result = snprintf(value, VMPA_MAX_SIZE, "%hhd", operand->signed_imm.val8); + break; + + case MDS_16_BITS_SIGNED: + result = snprintf(value, VMPA_MAX_SIZE, "%hd", operand->signed_imm.val16); + break; + + case MDS_32_BITS_SIGNED: + result = snprintf(value, VMPA_MAX_SIZE, "%d", operand->signed_imm.val32); + break; + + case MDS_64_BITS_SIGNED: + result = snprintf(value, VMPA_MAX_SIZE, "%lld", operand->signed_imm.val64); + break; + } break; } @@ -706,10 +759,12 @@ static void g_imm_operand_add_text(const GImmOperand *operand, GRenderingOptions static void g_imm_operand_to_buffer(const GImmOperand *operand, GBufferLine *buffer, GRenderingOptions *options) { + AsmSyntax syntax; /* Choix de l'exportation */ char value[VMPA_MAX_SIZE]; /* Chaîne à imprimer */ size_t len; /* Taille de l'élément inséré */ - len = g_imm_operand_to_string(operand, g_rendering_options_get_syntax(options), value); + syntax = (options == NULL ? ASX_COUNT : g_rendering_options_get_syntax(options)); + len = g_imm_operand_to_string(operand, syntax, value); g_content_exporter_insert_into_buffer(G_CONTENT_EXPORTER(operand), buffer, BLC_ASSEMBLY, value, len, RTT_IMMEDIATE); @@ -720,6 +775,32 @@ static void g_imm_operand_to_buffer(const GImmOperand *operand, GBufferLine *buf /****************************************************************************** * * * Paramètres : operand = opérande à traiter. * +* line = ligne tampon où imprimer l'opérande donné. * +* syntax = type de représentation demandée. * +* * +* Description : Traduit un opérande en version humainement lisible. * +* * +* Retour : - * +* * +* Remarques : - * +* * +******************************************************************************/ + +static void g_imm_operand_print(const GImmOperand *operand, GBufferLine *line, AsmSyntax syntax) +{ + char value[VMPA_MAX_SIZE]; /* Chaîne à imprimer */ + size_t len; /* Taille de l'élément inséré */ + + len = g_imm_operand_to_string(operand, syntax, value); + + g_buffer_line_insert_text(line, BLC_ASSEMBLY, value, len, RTT_IMMEDIATE); + +} + + +/****************************************************************************** +* * +* Paramètres : operand = opérande à traiter. * * addr = valeur résultante. [OUT] * * * * Description : Convertit une valeur immédiate en adresse de type vmpa_t. * |