summaryrefslogtreecommitdiff
path: root/src/arch/immediate.c
diff options
context:
space:
mode:
authorCyrille Bagard <nocbos@gmail.com>2009-09-30 00:00:43 (GMT)
committerCyrille Bagard <nocbos@gmail.com>2009-09-30 00:00:43 (GMT)
commit3c6968d4d5a8918c456cdea28a7c6195368d996e (patch)
treee6909254a8033cdabd116f287db2893e938a636d /src/arch/immediate.c
parent1beaa1af679d49d99696ec907662b764f7ba1867 (diff)
Parsed and replaced ModRM operands.
git-svn-id: svn://svn.gna.org/svn/chrysalide/trunk@121 abbe820e-26c8-41b2-8c08-b7b2b41f8b0a
Diffstat (limited to 'src/arch/immediate.c')
-rw-r--r--src/arch/immediate.c68
1 files changed, 65 insertions, 3 deletions
diff --git a/src/arch/immediate.c b/src/arch/immediate.c
index 54d8135..73a7648 100644
--- a/src/arch/immediate.c
+++ b/src/arch/immediate.c
@@ -313,8 +313,6 @@ bool g_imm_operand_is_negative(const GImmOperand *operand)
{
bool result; /* Bilan à renvoyer */
- result = false;
-
switch (operand->size)
{
case AOS_8_BITS_SIGNED:
@@ -330,7 +328,7 @@ bool g_imm_operand_is_negative(const GImmOperand *operand)
result = (operand->signed_imm.val64 & 0x8000000000000000ll);
break;
default:
- /* Traitement non nécessaire */
+ result = false;
break;
}
@@ -561,3 +559,67 @@ bool g_imm_operand_to_vmpa_t(const GImmOperand *operand, vmpa_t *addr)
return result;
}
+
+
+/******************************************************************************
+* *
+* Paramètres : operand = opérande à traiter. *
+* value = valeur résultante. [OUT] *
+* negative = indique si la valeur était négative à l'origine. *
+* *
+* Description : Convertit une valeur immédiate en valeur de type size_t. *
+* *
+* Retour : Bilan de l'opération. *
+* *
+* Remarques : - *
+* *
+******************************************************************************/
+
+bool g_imm_operand_to_size_t(const GImmOperand *operand, size_t *value, bool *negative)
+{
+ bool result; /* Bilan à renvoyer */
+
+ *negative = g_imm_operand_is_negative(operand);
+
+ switch (operand->size)
+ {
+ case AOS_8_BITS_UNSIGNED:
+ result = (sizeof(size_t) >= 1);
+ if (result) *value = operand->unsigned_imm.val8;
+ break;
+ case AOS_16_BITS_UNSIGNED:
+ result = (sizeof(size_t) >= 2);
+ if (result) *value = operand->unsigned_imm.val16;
+ break;
+ case AOS_32_BITS_UNSIGNED:
+ result = (sizeof(size_t) >= 4);
+ if (result) *value = operand->unsigned_imm.val32;
+ break;
+ case AOS_64_BITS_UNSIGNED:
+ result = (sizeof(size_t) >= 8);
+ if (result) *value = operand->unsigned_imm.val64;
+ break;
+ case AOS_8_BITS_SIGNED:
+ result = (sizeof(size_t) >= 1);
+ if (result) *value = (*negative ? -1 : 1 ) * operand->signed_imm.val8;
+ break;
+ case AOS_16_BITS_SIGNED:
+ result = (sizeof(size_t) >= 2);
+ if (result) *value = (*negative ? -1 : 1 ) * operand->signed_imm.val16;
+ break;
+ case AOS_32_BITS_SIGNED:
+ result = (sizeof(size_t) >= 4);
+ if (result) *value = (*negative ? -1 : 1 ) * operand->signed_imm.val32;
+ break;
+ case AOS_64_BITS_SIGNED:
+ result = (sizeof(size_t) >= 8);
+ if (result) *value = (*negative ? -1 : 1 ) * operand->signed_imm.val64;
+ break;
+ default:
+ result = false;
+ break;
+ }
+
+ return result;
+
+}