summaryrefslogtreecommitdiff
path: root/plugins/arm/v7/pseudo.c
diff options
context:
space:
mode:
Diffstat (limited to 'plugins/arm/v7/pseudo.c')
-rw-r--r--plugins/arm/v7/pseudo.c49
1 files changed, 48 insertions, 1 deletions
diff --git a/plugins/arm/v7/pseudo.c b/plugins/arm/v7/pseudo.c
index e560f5d..12ad50b 100644
--- a/plugins/arm/v7/pseudo.c
+++ b/plugins/arm/v7/pseudo.c
@@ -483,7 +483,7 @@ bool armv7_thumb_expand_imm(uint32_t imm12, uint32_t *value)
* *
******************************************************************************/
-bool armv7_decode_imm_shift(uint8_t type2, uint8_t imm5, SRType *type, uint32_t *value)
+bool armv7_decode_imm_shift(uint8_t type2, uint8_t imm5, SRType *type, uint8_t *value)
{
bool result; /* Bilan à retourner */
@@ -681,3 +681,50 @@ uint32_t armv7_zero_extend(uint32_t x, unsigned int n, unsigned int i)
return x;
}
+
+
+/******************************************************************************
+* *
+* Paramètres : x = valeur sur 32 bits maximum à traiter. *
+* t = bit de poids nombre de bits à prendre en compte. *
+* i = taille finale à obtenir. *
+* *
+* Description : Fournit une aide pour la fonction 'SignExtend'. *
+* *
+* Retour : Nouvelle valeur calculée. *
+* *
+* Remarques : - *
+* *
+******************************************************************************/
+
+uint32_t armv7_sign_extend(uint32_t x, unsigned int t, unsigned int i)
+{
+ uint32_t result; /* Valeur à retourner */
+ bool set; /* Bit de poids fort à 1 ? */
+ unsigned int k; /* Boucle de parcours */
+
+ result = 0;
+
+ set = (x & (1 << t));
+
+ switch (i)
+ {
+
+#define SIGN_EXTEND_CASE(sz) \
+ case sz: \
+ result = x; \
+ if (set) \
+ for (k = t + 1; k < sz; k++) \
+ result |= (1 << k); \
+ break;
+
+ SIGN_EXTEND_CASE(4);
+ SIGN_EXTEND_CASE(8);
+ SIGN_EXTEND_CASE(16);
+ SIGN_EXTEND_CASE(32);
+
+ }
+
+ return result;
+
+}