diff options
author | Cyrille Bagard <nocbos@gmail.com> | 2018-04-02 11:58:42 (GMT) |
---|---|---|
committer | Cyrille Bagard <nocbos@gmail.com> | 2018-04-02 12:39:30 (GMT) |
commit | 1db4ef323b7a76093356ae76268132f3760e1631 (patch) | |
tree | fec36ee0ec1b6b2010b62ca4177edca0e31e2114 /plugins/arm/v7/pseudo.c | |
parent | 1bc80837dde03a32b5ab185067f7bd4c499a9850 (diff) |
Rewritten the whole instruction definition format.
Diffstat (limited to 'plugins/arm/v7/pseudo.c')
-rw-r--r-- | plugins/arm/v7/pseudo.c | 49 |
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; + +} |