diff options
author | Cyrille Bagard <nocbos@gmail.com> | 2014-12-03 22:41:29 (GMT) |
---|---|---|
committer | Cyrille Bagard <nocbos@gmail.com> | 2014-12-03 22:41:29 (GMT) |
commit | 172fce9bab61de1ffa89f731b5d10f96e209afc1 (patch) | |
tree | 31aee5a141979fa99bbf88cbf2b7990de0ec3832 /src/arch/arm/v7/helpers.h | |
parent | f7ef27195f8c9dc35e5e210a333b74fcfae5ad71 (diff) |
Begun to support more than the only 'ARMv7' architecture for ARM (ARM / Thumb16 / Thumb32).
git-svn-id: svn://svn.gna.org/svn/chrysalide/trunk@433 abbe820e-26c8-41b2-8c08-b7b2b41f8b0a
Diffstat (limited to 'src/arch/arm/v7/helpers.h')
-rw-r--r-- | src/arch/arm/v7/helpers.h | 60 |
1 files changed, 48 insertions, 12 deletions
diff --git a/src/arch/arm/v7/helpers.h b/src/arch/arm/v7/helpers.h index d72bb88..394302b 100644 --- a/src/arch/arm/v7/helpers.h +++ b/src/arch/arm/v7/helpers.h @@ -36,20 +36,56 @@ -#define ARMExpandImm_C(imm12, c) \ - ({ \ - uint32_t __val; \ - __val = armv7_arm_expand_imm_c(imm12, (bool []) { c }); \ - g_imm_operand_new_from_value(MDS_32_BITS_UNSIGNED, __val); \ +#define ARMExpandImm_C(imm12, c) \ + ({ \ + GArchOperand *__result; \ + uint32_t __val; \ + if (armv7_arm_expand_imm_c(imm12, (bool []) { c }, &__val)) \ + __result = g_imm_operand_new_from_value(MDS_32_BITS_UNSIGNED, __val); \ + else \ + __result = NULL; \ + __result; \ }) -#define ARMExpandImm(imm12) \ - ({ \ - uint32_t __val; \ - __val = armv7_arm_expand_imm_c(imm12, NULL); \ - g_imm_operand_new_from_value(MDS_32_BITS_UNSIGNED, __val); \ +#define ARMExpandImm(imm12) \ + ({ \ + GArchOperand *__result; \ + uint32_t __val; \ + if (armv7_arm_expand_imm(imm12, &__val)) \ + __result = g_imm_operand_new_from_value(MDS_32_BITS_UNSIGNED, __val); \ + else \ + __result = NULL; \ + __result; \ }) +#define ThumbExpandImm_C(imm12, c) \ + ({ \ + GArchOperand *__result; \ + uint32_t __val; \ + if (armv7_thumb_expand_imm_c(imm12, (bool []) { c }, &__val)) \ + __result = g_imm_operand_new_from_value(MDS_32_BITS_UNSIGNED, __val); \ + else \ + __result = NULL; \ + __result; \ + }) + +#define ThumbExpandImm(imm12) \ + ({ \ + GArchOperand *__result; \ + uint32_t __val; \ + if (armv7_thumb_expand_imm(imm12, &__val)) \ + __result = g_imm_operand_new_from_value(MDS_32_BITS_UNSIGNED, __val); \ + else \ + __result = NULL; \ + __result; \ + }) + + + + + + + #define DecodeImmShift(type, imm5) \ ({ \ GArchOperand *__result; \ @@ -86,7 +122,7 @@ return shift_t; ({ \ MemoryDataSize __mds; \ uint ## i ## _t __val; \ - mds = MDS_ ## sz ## _BITS_UNSIGNED; \ + __mds = MDS_ ## i ## _BITS_UNSIGNED; \ __val = armv7_zero_extend(x, n, i); \ g_imm_operand_new_from_value(__mds, __val); \ }) @@ -97,7 +133,7 @@ return shift_t; ({ \ MemoryDataSize __mds; \ uint ## i ## _t __val; \ - mds = MDS_ ## sz ## _BITS_UNSIGNED; \ + __mds = MDS_ ## i ## _BITS_UNSIGNED; \ __val = 0; \ g_imm_operand_new_from_value(__mds, __val); \ }) |