diff options
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); \ }) |