summaryrefslogtreecommitdiff
path: root/src/arch/immediate.c
diff options
context:
space:
mode:
authorCyrille Bagard <nocbos@gmail.com>2018-05-14 19:40:07 (GMT)
committerCyrille Bagard <nocbos@gmail.com>2018-05-14 19:40:07 (GMT)
commit0286b53bad21abf91cbe17c4772ca9cde6a89cbc (patch)
tree3bec9dc7e118c00ce9c748576b01606a71880ad7 /src/arch/immediate.c
parent267b1ae8608ed4bf52de743798e8647c903ee1b4 (diff)
Created an instruction database for Chrysalide.
Diffstat (limited to 'src/arch/immediate.c')
-rw-r--r--src/arch/immediate.c107
1 files changed, 107 insertions, 0 deletions
diff --git a/src/arch/immediate.c b/src/arch/immediate.c
index bf4a36a..1c084ea 100644
--- a/src/arch/immediate.c
+++ b/src/arch/immediate.c
@@ -109,6 +109,17 @@ static char *g_imm_operand_build_tooltip(const GImmOperand *, const GLoadedBinar
+/* --------------------- TRANSPOSITIONS VIA CACHE DES OPERANDES --------------------- */
+
+
+/* Charge un opérande depuis une mémoire tampon. */
+static bool g_imm_operand_unserialize(GImmOperand *, GAsmStorage *, GBinFormat *, packed_buffer *);
+
+/* Sauvegarde un opérande dans une mémoire tampon. */
+static bool g_imm_operand_serialize(const GImmOperand *, GAsmStorage *, packed_buffer *);
+
+
+
/* Indique le type défini pour un opérande de valeur numérique. */
G_DEFINE_TYPE(GImmOperand, g_imm_operand, G_TYPE_ARCH_OPERAND);
@@ -141,6 +152,9 @@ static void g_imm_operand_class_init(GImmOperandClass *klass)
operand->print = (operand_print_fc)g_imm_operand_print;
operand->build_tooltip = (operand_build_tooltip_fc)g_imm_operand_build_tooltip;
+ operand->unserialize = (unserialize_operand_fc)g_imm_operand_unserialize;
+ operand->serialize = (serialize_operand_fc)g_imm_operand_serialize;
+
}
@@ -1357,3 +1371,96 @@ bool g_imm_operand_to_off_t(const GImmOperand *operand, off_t *value, bool *nega
return false;
}
+
+
+
+/* ---------------------------------------------------------------------------------- */
+/* TRANSPOSITIONS VIA CACHE DES OPERANDES */
+/* ---------------------------------------------------------------------------------- */
+
+
+/******************************************************************************
+* *
+* Paramètres : operand = opérande d'assemblage à constituer. *
+* storage = mécanisme de sauvegarde à manipuler. *
+* format = format binaire chargé associé à l'architecture. *
+* pbuf = zone tampon à remplir. *
+* *
+* Description : Charge un opérande depuis une mémoire tampon. *
+* *
+* Retour : Bilan de l'opération. *
+* *
+* Remarques : - *
+* *
+******************************************************************************/
+
+static bool g_imm_operand_unserialize(GImmOperand *operand, GAsmStorage *storage, GBinFormat *format, packed_buffer *pbuf)
+{
+ bool result; /* Bilan à retourner */
+ GArchOperandClass *parent; /* Classe parente à consulter */
+
+ parent = G_ARCH_OPERAND_CLASS(g_imm_operand_parent_class);
+
+ result = parent->unserialize(G_ARCH_OPERAND(operand), storage, format, pbuf);
+
+ if (result)
+ result = extract_packed_buffer(pbuf, &operand->raw, sizeof(uint64_t), true);
+
+ if (result)
+ result = extract_packed_buffer(pbuf, &operand->size, sizeof(MemoryDataSize), true);
+
+ if (result)
+ result = extract_packed_buffer(pbuf, &operand->def_display, sizeof(ImmOperandDisplay), true);
+
+ if (result)
+ result = extract_packed_buffer(pbuf, &operand->display, sizeof(ImmOperandDisplay), true);
+
+ if (result)
+ result = extract_packed_buffer(pbuf, &operand->misc, sizeof(uint8_t), false);
+
+ return result;
+
+}
+
+
+/******************************************************************************
+* *
+* Paramètres : operand = opérande d'assemblage à consulter. *
+* storage = mécanisme de sauvegarde à manipuler. *
+* pbuf = zone tampon à remplir. *
+* *
+* Description : Sauvegarde un opérande dans une mémoire tampon. *
+* *
+* Retour : Bilan de l'opération. *
+* *
+* Remarques : - *
+* *
+******************************************************************************/
+
+static bool g_imm_operand_serialize(const GImmOperand *operand, GAsmStorage *storage, packed_buffer *pbuf)
+{
+ bool result; /* Bilan à retourner */
+ GArchOperandClass *parent; /* Classe parente à consulter */
+
+ parent = G_ARCH_OPERAND_CLASS(g_imm_operand_parent_class);
+
+ result = parent->serialize(G_ARCH_OPERAND(operand), storage, pbuf);
+
+ if (result)
+ result = extend_packed_buffer(pbuf, &operand->raw, sizeof(uint64_t), true);
+
+ if (result)
+ result = extend_packed_buffer(pbuf, &operand->size, sizeof(MemoryDataSize), true);
+
+ if (result)
+ result = extend_packed_buffer(pbuf, &operand->def_display, sizeof(ImmOperandDisplay), true);
+
+ if (result)
+ result = extend_packed_buffer(pbuf, &operand->display, sizeof(ImmOperandDisplay), true);
+
+ if (result)
+ result = extend_packed_buffer(pbuf, &operand->misc, sizeof(uint8_t), false);
+
+ return result;
+
+}