summaryrefslogtreecommitdiff
path: root/plugins/arm/v7/operands/register.c
diff options
context:
space:
mode:
Diffstat (limited to 'plugins/arm/v7/operands/register.c')
-rw-r--r--plugins/arm/v7/operands/register.c95
1 files changed, 95 insertions, 0 deletions
diff --git a/plugins/arm/v7/operands/register.c b/plugins/arm/v7/operands/register.c
index 33a14f6..412d0f9 100644
--- a/plugins/arm/v7/operands/register.c
+++ b/plugins/arm/v7/operands/register.c
@@ -36,6 +36,8 @@ struct _GArmV7RegisterOperand
{
GRegisterOperand parent; /* Instance parente */
+ bool write_back; /* Mise à jour du registre ? */
+
};
@@ -59,6 +61,9 @@ static void g_armv7_register_operand_dispose(GArmV7RegisterOperand *);
/* Procède à la libération totale de la mémoire. */
static void g_armv7_register_operand_finalize(GArmV7RegisterOperand *);
+/* Traduit un opérande en version humainement lisible. */
+static void g_armv7_register_operand_print(const GArmV7RegisterOperand *, GBufferLine *, AsmSyntax);
+
/* --------------------- TRANSPOSITIONS VIA CACHE DES OPERANDES --------------------- */
@@ -100,6 +105,8 @@ static void g_armv7_register_operand_class_init(GArmV7RegisterOperandClass *klas
operand = G_ARCH_OPERAND_CLASS(klass);
+ operand->print = (operand_print_fc)g_armv7_register_operand_print;
+
operand->unserialize = (unserialize_operand_fc)g_armv7_register_operand_unserialize;
operand->serialize = (serialize_operand_fc)g_armv7_register_operand_serialize;
@@ -120,6 +127,7 @@ static void g_armv7_register_operand_class_init(GArmV7RegisterOperandClass *klas
static void g_armv7_register_operand_init(GArmV7RegisterOperand *operand)
{
+ operand->write_back = false;
}
@@ -164,6 +172,34 @@ static void g_armv7_register_operand_finalize(GArmV7RegisterOperand *operand)
/******************************************************************************
* *
+* 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_armv7_register_operand_print(const GArmV7RegisterOperand *operand, GBufferLine *line, AsmSyntax syntax)
+{
+ GArchOperandClass *parent; /* Classe parente */
+
+ parent = G_ARCH_OPERAND_CLASS(g_armv7_register_operand_parent_class);
+
+ parent->print(G_ARCH_OPERAND(operand), line, syntax);
+
+ if (operand->write_back)
+ g_buffer_line_append_text(line, BLC_ASSEMBLY, "!", 1, RTT_PUNCT, NULL);
+
+}
+
+
+/******************************************************************************
+* *
* Paramètres : reg = registre déjà en place. *
* *
* Description : Crée un opérande visant un registre ARMv7. *
@@ -210,6 +246,48 @@ const GArmV7Register *g_armv7_register_operand_get(const GArmV7RegisterOperand *
}
+/******************************************************************************
+* *
+* Paramètres : operand = opérande représentant un registre. *
+* wback = indique si le registre est mis à jour après coup. *
+* *
+* Description : Détermine si le registre est mis à jour après l'opération. *
+* *
+* Retour : - *
+* *
+* Remarques : - *
+* *
+******************************************************************************/
+
+void g_armv7_register_operand_write_back(GArmV7RegisterOperand *operand, bool wback)
+{
+ operand->write_back = wback;
+
+}
+
+
+/******************************************************************************
+* *
+* Paramètres : operand = opérande représentant un registre. *
+* *
+* Description : Indique si le registre est mis à jour après coup. *
+* *
+* Retour : Evolution du registre. *
+* *
+* Remarques : - *
+* *
+******************************************************************************/
+
+bool g_armv7_register_operand_is_written_back(const GArmV7RegisterOperand *operand)
+{
+ bool result; /* Statut à retourner */
+
+ result = operand->write_back;
+
+ return result;
+
+}
+
/* ---------------------------------------------------------------------------------- */
/* TRANSPOSITIONS VIA CACHE DES OPERANDES */
@@ -237,6 +315,7 @@ static bool g_armv7_register_operand_unserialize(GArmV7RegisterOperand *operand,
GArchOperandClass *parent; /* Classe parente à consulter */
uint8_t index; /* Identifiant de registre */
GArmV7Register *reg; /* Registre à intégrer */
+ uint8_t wback; /* Mise à jour après coup ? */
parent = G_ARCH_OPERAND_CLASS(g_armv7_register_operand_parent_class);
@@ -257,6 +336,15 @@ static bool g_armv7_register_operand_unserialize(GArmV7RegisterOperand *operand,
}
+ if (result)
+ {
+ result = extract_packed_buffer(pbuf, &wback, sizeof(uint8_t), false);
+
+ if (result)
+ operand->write_back = (wback == 1 ? true : false);
+
+ }
+
return result;
}
@@ -281,6 +369,7 @@ static bool g_armv7_register_operand_serialize(const GArmV7RegisterOperand *oper
bool result; /* Bilan à retourner */
GArchOperandClass *parent; /* Classe parente à consulter */
uint8_t index; /* Identifiant de registre */
+ uint8_t wback; /* Mise à jour après coup ? */
parent = G_ARCH_OPERAND_CLASS(g_armv7_register_operand_parent_class);
@@ -292,6 +381,12 @@ static bool g_armv7_register_operand_serialize(const GArmV7RegisterOperand *oper
result = extend_packed_buffer(pbuf, &index, sizeof(uint8_t), false);
}
+ if (result)
+ {
+ wback = (operand->write_back ? 1 : 0);
+ result = extend_packed_buffer(pbuf, &wback, sizeof(uint8_t), false);
+ }
+
return result;
}