From 1878e3ab82d8711f305e7b8bbc43c5ed21bf140b Mon Sep 17 00:00:00 2001
From: Cyrille Bagard <nocbos@gmail.com>
Date: Wed, 25 May 2016 23:29:53 +0200
Subject: Applied conditional bits as keyword suffixes for ARM instructions.

---
 ChangeLog                  |  6 ++++++
 src/arch/arm/cond.h        | 12 ++++++------
 src/arch/arm/instruction.c | 35 ++++++++++++++++++++++++++++++++++-
 3 files changed, 46 insertions(+), 7 deletions(-)

diff --git a/ChangeLog b/ChangeLog
index 3660bbd..1f6cf83 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,11 @@
 16-05-25  Cyrille Bagard <nocbos@gmail.com>
 
+	* src/arch/arm/cond.h:
+	* src/arch/arm/instruction.c:
+	Apply conditional bits as keyword suffixes for ARM instructions.
+
+16-05-25  Cyrille Bagard <nocbos@gmail.com>
+
 	* src/arch/arm/v7/arm.c:
 	* src/arch/arm/v7/opcodes/opcodes_tmp_arm.h:
 	* src/arch/arm/v7/pseudo.c:
diff --git a/src/arch/arm/cond.h b/src/arch/arm/cond.h
index 942c243..faa0727 100644
--- a/src/arch/arm/cond.h
+++ b/src/arch/arm/cond.h
@@ -43,12 +43,12 @@ typedef enum _ArmCondCode
     ACC_EQ = 0x0,                           /* Equal                       */
     ACC_NE = 0x1,                           /* Not equal                   */
     ACC_HS = 0x2,                           /* Unsigned higher or same     */
-    ACC_LO = 0x2,                           /* Unsigned lower              */
-    ACC_MI = 0x3,                           /* Minus                       */
-    ACC_PL = 0x4,                           /* Plus or zero                */
-    ACC_VS = 0x5,                           /* Overflow set                */
-    ACC_VC = 0x6,                           /* Overflow clear              */
-    ACC_HI = 0x7,                           /* Unsigned higher             */
+    ACC_LO = 0x3,                           /* Unsigned lower              */
+    ACC_MI = 0x4,                           /* Minus                       */
+    ACC_PL = 0x5,                           /* Plus or zero                */
+    ACC_VS = 0x6,                           /* Overflow set                */
+    ACC_VC = 0x7,                           /* Overflow clear              */
+    ACC_HI = 0x8,                           /* Unsigned higher             */
     ACC_LS = 0x9,                           /* Unsigned lower or same      */
     ACC_GE = 0xa,                           /* Signed greater than or equal*/
     ACC_LT = 0xb,                           /* Signed less than            */
diff --git a/src/arch/arm/instruction.c b/src/arch/arm/instruction.c
index 47c9b4b..2c1f3b8 100644
--- a/src/arch/arm/instruction.c
+++ b/src/arch/arm/instruction.c
@@ -155,12 +155,16 @@ static void g_arm_instruction_build_keyword(const GArmInstruction *instr, AsmSyn
 {
     GArchInstruction *base;                 /* Instruction, vue générique  */
 
+    /* FIXME : tout bouger dans la base des instructions ? */
+
     base = G_ARCH_INSTRUCTION(instr);
 
     base->cached_keyword = strdup(instr->keyword);
 
+    /*
     if (base->suffix != NULL)
         base->cached_keyword = stradd(base->cached_keyword, base->suffix);
+    */
 
 }
 
@@ -180,9 +184,38 @@ static void g_arm_instruction_build_keyword(const GArmInstruction *instr, AsmSyn
 
 bool g_arm_instruction_set_cond(GArmInstruction *instr, ArmCondCode cond)
 {
+    bool result;                            /* Bilan à retourner           */
+    const char *suffix;                     /* Eventuelle marque à ajouter */
+
     instr->cond = cond;
 
-    return true;
+    switch (cond)
+    {
+        case ACC_EQ: suffix = "eq"; break;
+        case ACC_NE: suffix = "ne"; break;
+        case ACC_HS: suffix = "hs"; break;
+        case ACC_LO: suffix = "lo"; break;
+        case ACC_MI: suffix = "mi"; break;
+        case ACC_PL: suffix = "pl"; break;
+        case ACC_VS: suffix = "vs"; break;
+        case ACC_VC: suffix = "vc"; break;
+        case ACC_HI: suffix = "hi"; break;
+        case ACC_LS: suffix = "ls"; break;
+        case ACC_GE: suffix = "ge"; break;
+        case ACC_LT: suffix = "lt"; break;
+        case ACC_GT: suffix = "gt"; break;
+        case ACC_LE: suffix = "le"; break;
+        case ACC_AL: suffix = NULL; break;
+        case ACC_NV: suffix = "nv"; break;
+    }
+
+    if (suffix != NULL)
+        result = g_arch_instruction_extend_keyword(G_ARCH_INSTRUCTION(instr), suffix);
+
+    else
+        result = true;
+
+    return result;
 
 }
 
-- 
cgit v0.11.2-87-g4458