summaryrefslogtreecommitdiff
path: root/src/arch/arm/v456/operands/register.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/arch/arm/v456/operands/register.c')
-rw-r--r--src/arch/arm/v456/operands/register.c232
1 files changed, 232 insertions, 0 deletions
diff --git a/src/arch/arm/v456/operands/register.c b/src/arch/arm/v456/operands/register.c
new file mode 100644
index 0000000..ce51cfc
--- /dev/null
+++ b/src/arch/arm/v456/operands/register.c
@@ -0,0 +1,232 @@
+
+/* OpenIDA - Outil d'analyse de fichiers binaires
+ * register.c - opérandes visant un registre ARM v4/5/6
+ *
+ * Copyright (C) 2013 Cyrille Bagard
+ *
+ * This file is part of OpenIDA.
+ *
+ * OpenIDA is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * OpenIDA is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with Foobar. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+
+#include "register.h"
+
+
+#include "../../../operand-int.h"
+
+
+
+/* Définition d'un opérande visant un registre ARM v4/5/6 (instance) */
+struct _GArmV456RegisterOperand
+{
+ GArchOperand parent; /* Instance parente */
+
+ GArmV456Register *reg; /* Registre représenté */
+ bool is_written; /* Changement de contenu */
+
+};
+
+
+/* Définition d'un opérande visant un registre ARM v4/5/6 (classe) */
+struct _GArmV456RegisterOperandClass
+{
+ GArchOperandClass parent; /* Classe parente */
+
+};
+
+
+/* Initialise la classe des opérandes de registre ARM v4/5/6. */
+static void g_armv456_register_operand_class_init(GArmV456RegisterOperandClass *);
+
+/* Initialise une instance d'opérande de registre ARM v4/5/6. */
+static void g_armv456_register_operand_init(GArmV456RegisterOperand *);
+
+/* Compare un opérande avec un autre. */
+static bool g_armv456_register_operand_compare(const GArmV456RegisterOperand *, const GArmV456RegisterOperand *);
+
+/* Traduit un opérande en version humainement lisible. */
+static void g_armv456_register_operand_print(const GArmV456RegisterOperand *, GBufferLine *, AsmSyntax);
+
+
+
+/* Indique le type défini par la GLib pour un opérande de registre ARM v4/5/6. */
+G_DEFINE_TYPE(GArmV456RegisterOperand, g_armv456_register_operand, G_TYPE_ARCH_OPERAND);
+
+
+/******************************************************************************
+* *
+* Paramètres : klass = classe à initialiser. *
+* *
+* Description : Initialise la classe des opérandes de registre ARM v4/5/6. *
+* *
+* Retour : - *
+* *
+* Remarques : - *
+* *
+******************************************************************************/
+
+static void g_armv456_register_operand_class_init(GArmV456RegisterOperandClass *klass)
+{
+
+}
+
+
+/******************************************************************************
+* *
+* Paramètres : operand = instance à initialiser. *
+* *
+* Description : Initialise une instance d'opérande de registre ARM v4/5/6. *
+* *
+* Retour : - *
+* *
+* Remarques : - *
+* *
+******************************************************************************/
+
+static void g_armv456_register_operand_init(GArmV456RegisterOperand *operand)
+{
+ GArchOperand *parent; /* Instance parente */
+
+ parent = G_ARCH_OPERAND(operand);
+
+ parent->compare = (operand_compare_fc)g_armv456_register_operand_compare;
+ parent->print = (operand_print_fc)g_armv456_register_operand_print;
+
+ operand->is_written = false;
+
+}
+
+
+/******************************************************************************
+* *
+* Paramètres : reg = registre déjà en place. *
+* *
+* Description : Crée un opérande visant un registre ARM v4/5/6. *
+* *
+* Retour : Opérande mis en place. *
+* *
+* Remarques : - *
+* *
+******************************************************************************/
+
+GArchOperand *g_armv456_register_operand_new_from_existing(GArmV456Register *reg)
+{
+ GArmV456RegisterOperand *result; /* Structure à retourner */
+
+ result = g_object_new(G_TYPE_ARMV456_REGISTER_OPERAND, NULL);
+
+ result->reg = reg;
+
+ return G_ARCH_OPERAND(result);
+
+}
+
+
+/******************************************************************************
+* *
+* Paramètres : operand = opérande représentant un registre. *
+* *
+* Description : Fournit le registre ARM v4/5/6 associé à l'opérande. *
+* *
+* Retour : Représentation interne du registre. *
+* *
+* Remarques : - *
+* *
+******************************************************************************/
+
+GArmV456Register *g_armv456_register_operand_get(const GArmV456RegisterOperand *operand)
+{
+ return operand->reg;
+
+}
+
+
+/******************************************************************************
+* *
+* Paramètres : a = premier opérande à consulter. *
+* b = second opérande à consulter. *
+* *
+* Description : Compare un opérande avec un autre. *
+* *
+* Retour : Bilan de la comparaison. *
+* *
+* Remarques : - *
+* *
+******************************************************************************/
+
+static bool g_armv456_register_operand_compare(const GArmV456RegisterOperand *a, const GArmV456RegisterOperand *b)
+{
+ return (g_armv456_register_compare(a->reg, b->reg) == 0);
+
+}
+
+
+/******************************************************************************
+* *
+* 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_armv456_register_operand_print(const GArmV456RegisterOperand *operand, GBufferLine *line, AsmSyntax syntax)
+{
+ g_armv456_register_print(operand->reg, line, syntax);
+
+}
+
+
+/******************************************************************************
+* *
+* Paramètres : operand = opérande représentant un registre à mettre à jour. *
+* *
+* Description : Marque l'opérande comme étant écrit plutôt que consulté. *
+* *
+* Retour : - *
+* *
+* Remarques : - *
+* *
+******************************************************************************/
+
+void g_armv456_register_operand_mark_as_written(GArmV456RegisterOperand *operand)
+{
+ operand->is_written = true;
+
+}
+
+
+/******************************************************************************
+* *
+* Paramètres : operand = opérande représentant un registre à consulter. *
+* *
+* Description : Indique le type d'accès réalisé sur l'opérande. *
+* *
+* Retour : Type d'accès : true en cas d'écriture, false sinon. *
+* *
+* Remarques : - *
+* *
+******************************************************************************/
+
+bool g_armv456_register_operand_is_written(const GArmV456RegisterOperand *operand)
+{
+ return operand->is_written;
+
+}