From 76f44a20a5b277d7cbc441c4e71943d4e5507a9d Mon Sep 17 00:00:00 2001
From: Cyrille Bagard <nocbos@gmail.com>
Date: Tue, 9 Feb 2016 15:03:11 +0100
Subject: Set the initial display value and avoided to pad octal and decimal
 values.

---
 ChangeLog            | 10 ++++++++++
 src/arch/archbase.h  |  4 ++--
 src/arch/immediate.c | 31 +++++++++++++++++++++++++++++++
 src/arch/immediate.h |  3 +++
 4 files changed, 46 insertions(+), 2 deletions(-)

diff --git a/ChangeLog b/ChangeLog
index e4f72b4..128478a 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,13 @@
+16-02-09  Cyrille Bagard <nocbos@gmail.com>
+
+	* src/arch/archbase.h:
+	Fix a bug by handling non rugular sizes of values.
+
+	* src/arch/immediate.c:
+	* src/arch/immediate.h:
+	Set the initial display value and avoid to pad octal and decimal values.
+	Provide a conversion to 'phys_t' types.
+
 16-02-03  Cyrille Bagard <nocbos@gmail.com>
 
 	* src/arch/immediate.c:
diff --git a/src/arch/archbase.h b/src/arch/archbase.h
index fc6fe4d..867030d 100644
--- a/src/arch/archbase.h
+++ b/src/arch/archbase.h
@@ -85,10 +85,10 @@ typedef enum _MemoryDataSize
              case 2:                                \
                  __result = MDS_16_BITS_UNSIGNED;   \
                  break;                             \
-             case 4:                                \
+             case 3 ... 4:                          \
                  __result = MDS_32_BITS_UNSIGNED;   \
                  break;                             \
-             case 8:                                \
+             case 5 ... 8:                          \
                  __result = MDS_64_BITS_UNSIGNED;   \
                  break;                             \
              default:                               \
diff --git a/src/arch/immediate.c b/src/arch/immediate.c
index cd36de2..40533ae 100644
--- a/src/arch/immediate.c
+++ b/src/arch/immediate.c
@@ -172,6 +172,8 @@ static void g_imm_operand_class_init(GImmOperandClass *klass)
 static void g_imm_operand_init(GImmOperand *operand)
 {
     operand->zpad = false;
+
+    operand->def_display = IOD_HEX;
     operand->display = IOD_HEX;
 
 }
@@ -741,6 +743,8 @@ size_t g_imm_operand_to_string(const GImmOperand *operand, AsmSyntax syntax, cha
     {
         case IOD_BIN:
         case IOD_CHAR:
+        case IOD_OCT:
+        case IOD_DEC:
             zpad = "";
             break;
         default:
@@ -883,6 +887,33 @@ static void g_imm_operand_print(const GImmOperand *operand, GBufferLine *line, A
 /******************************************************************************
 *                                                                             *
 *  Paramètres  : operand = opérande à traiter.                                *
+*                pos     = valeur résultante. [OUT]                           *
+*                                                                             *
+*  Description : Convertit une valeur immédiate en position de type phys_t.   *
+*                                                                             *
+*  Retour      : Bilan de l'opération.                                        *
+*                                                                             *
+*  Remarques   : -                                                            *
+*                                                                             *
+******************************************************************************/
+
+bool g_imm_operand_to_phys_t(const GImmOperand *operand, phys_t *pos)
+{
+    bool result;                            /* Bilan à renvoyer            */
+
+    result = !MDS_IS_SIGNED(operand->size);
+
+    if (result)
+        *pos = operand->raw;
+
+    return result;
+
+}
+
+
+/******************************************************************************
+*                                                                             *
+*  Paramètres  : operand = opérande à traiter.                                *
 *                addr    = valeur résultante. [OUT]                           *
 *                                                                             *
 *  Description : Convertit une valeur immédiate en adresse de type virt_t.    *
diff --git a/src/arch/immediate.h b/src/arch/immediate.h
index 640ac50..e6da2f4 100644
--- a/src/arch/immediate.h
+++ b/src/arch/immediate.h
@@ -119,6 +119,9 @@ bool g_imm_operand_is_null(const GImmOperand *);
 /* Construit la chaîne de caractères correspondant à l'opérande. */
 size_t g_imm_operand_to_string(const GImmOperand *, AsmSyntax, char [IMM_MAX_SIZE]);
 
+/* Convertit une valeur immédiate en position de type phys_t. */
+bool g_imm_operand_to_phys_t(const GImmOperand *, phys_t *);
+
 /* Convertit une valeur immédiate en adresse de type virt_t. */
 bool g_imm_operand_to_virt_t(const GImmOperand *, virt_t *);
 
-- 
cgit v0.11.2-87-g4458