Fold direction into memory format

This commit is contained in:
Jeffrey Pfau 2014-07-11 01:27:32 -07:00
parent 45c6299b3b
commit 2b0dccb243
2 changed files with 18 additions and 21 deletions

View File

@ -226,12 +226,11 @@ DEFINE_LOAD_STORE_WITH_REGISTER_THUMB(STRH2, STR, STORE_CYCLES, ARM_ACCESS_HALFW
info->op1.immediate = (opcode & 0xFF) | ADDITIONAL_REG; \ info->op1.immediate = (opcode & 0xFF) | ADDITIONAL_REG; \
info->branches = info->op1.immediate & (1 << ARM_PC); \ info->branches = info->op1.immediate & (1 << ARM_PC); \
info->operandFormat = ARM_OPERAND_MEMORY_1; \ info->operandFormat = ARM_OPERAND_MEMORY_1; \
info->memory.direction = DIRECTION; \
info->memory.format = ARM_MEMORY_REGISTER_BASE | \ info->memory.format = ARM_MEMORY_REGISTER_BASE | \
ARM_MEMORY_POST_INCREMENT;) ARM_MEMORY_POST_INCREMENT | DIRECTION;)
#define DEFINE_LOAD_STORE_MULTIPLE_THUMB(NAME) \ #define DEFINE_LOAD_STORE_MULTIPLE_THUMB(NAME) \
COUNT_3(DEFINE_LOAD_STORE_MULTIPLE_EX_THUMB, NAME ## IA_R, NAME, ARM_INCREMENT_AFTER, 0) COUNT_3(DEFINE_LOAD_STORE_MULTIPLE_EX_THUMB, NAME ## IA_R, NAME, ARM_MEMORY_INCREMENT_AFTER, 0)
DEFINE_LOAD_STORE_MULTIPLE_THUMB(LDM) DEFINE_LOAD_STORE_MULTIPLE_THUMB(LDM)
DEFINE_LOAD_STORE_MULTIPLE_THUMB(STM) DEFINE_LOAD_STORE_MULTIPLE_THUMB(STM)
@ -270,10 +269,10 @@ DEFINE_CONDITIONAL_BRANCH_THUMB(LE)
DEFINE_SP_MODIFY_THUMB(ADD7, ADD) DEFINE_SP_MODIFY_THUMB(ADD7, ADD)
DEFINE_SP_MODIFY_THUMB(SUB4, SUB) DEFINE_SP_MODIFY_THUMB(SUB4, SUB)
DEFINE_LOAD_STORE_MULTIPLE_EX_THUMB(POP, ARM_SP, LDM, ARM_INCREMENT_AFTER, 0) DEFINE_LOAD_STORE_MULTIPLE_EX_THUMB(POP, ARM_SP, LDM, ARM_MEMORY_INCREMENT_AFTER, 0)
DEFINE_LOAD_STORE_MULTIPLE_EX_THUMB(POPR, ARM_SP, LDM, ARM_INCREMENT_AFTER, 1 << ARM_PC) DEFINE_LOAD_STORE_MULTIPLE_EX_THUMB(POPR, ARM_SP, LDM, ARM_MEMORY_INCREMENT_AFTER, 1 << ARM_PC)
DEFINE_LOAD_STORE_MULTIPLE_EX_THUMB(PUSH, ARM_SP, STM, ARM_DECREMENT_BEFORE, 0) DEFINE_LOAD_STORE_MULTIPLE_EX_THUMB(PUSH, ARM_SP, STM, ARM_MEMORY_DECREMENT_BEFORE, 0)
DEFINE_LOAD_STORE_MULTIPLE_EX_THUMB(PUSHR, ARM_SP, STM, ARM_DECREMENT_BEFORE, 1 << ARM_LR) DEFINE_LOAD_STORE_MULTIPLE_EX_THUMB(PUSHR, ARM_SP, STM, ARM_MEMORY_DECREMENT_BEFORE, 1 << ARM_LR)
DEFINE_THUMB_DECODER(ILL, ILL, info->traps = 1;) DEFINE_THUMB_DECODER(ILL, ILL, info->traps = 1;)
DEFINE_THUMB_DECODER(BKPT, BKPT, info->traps = 1;) DEFINE_THUMB_DECODER(BKPT, BKPT, info->traps = 1;)
@ -396,11 +395,11 @@ int ARMDisassembleThumb(uint16_t opcode, uint32_t pc, char* buffer, int blen) {
switch (info.mnemonic) { switch (info.mnemonic) {
case ARM_MN_LDM: case ARM_MN_LDM:
case ARM_MN_STM: case ARM_MN_STM:
flags = armDirectionStrings[info.memory.direction]; flags = armDirectionStrings[MEMORY_FORMAT_TO_DIRECTION(info.memory.format)];
break; break;
case ARM_MN_LDR: case ARM_MN_LDR:
case ARM_MN_STR: case ARM_MN_STR:
flags = armAccessTypeStrings[info.memory.direction]; flags = armAccessTypeStrings[info.memory.width];
break; break;
default: default:
break; break;

View File

@ -43,9 +43,17 @@ enum ARMMemoryFormat {
ARM_MEMORY_SHIFTED_OFFSET = 0x0008, ARM_MEMORY_SHIFTED_OFFSET = 0x0008,
ARM_MEMORY_PRE_INCREMENT = 0x0010, ARM_MEMORY_PRE_INCREMENT = 0x0010,
ARM_MEMORY_POST_INCREMENT = 0x0020, ARM_MEMORY_POST_INCREMENT = 0x0020,
ARM_MEMORY_OFFSET_SUBTRACT = 0x0040 ARM_MEMORY_OFFSET_SUBTRACT = 0x0040,
ARM_MEMORY_WRITEBACK = 0x0080,
ARM_MEMORY_DECREMENT_AFTER = 0x0000,
ARM_MEMORY_INCREMENT_AFTER = 0x0100,
ARM_MEMORY_DECREMENT_BEFORE = 0x0200,
ARM_MEMORY_INCREMENT_BEFORE = 0x0300,
}; };
#define MEMORY_FORMAT_TO_DIRECTION(F) (((F) >> 8) & 0x7)
enum ARMCondition { enum ARMCondition {
ARM_CONDITION_EQ = 0x0, ARM_CONDITION_EQ = 0x0,
ARM_CONDITION_NE = 0x1, ARM_CONDITION_NE = 0x1,
@ -77,13 +85,6 @@ union ARMOperand {
int32_t immediate; int32_t immediate;
}; };
enum ARMMultipleDirection {
ARM_DECREMENT_AFTER = 0,
ARM_INCREMENT_AFTER = 1,
ARM_DECREMENT_BEFORE = 2,
ARM_INCREMENT_BEFORE = 3,
};
enum ARMMemoryAccessType { enum ARMMemoryAccessType {
ARM_ACCESS_WORD = 4, ARM_ACCESS_WORD = 4,
ARM_ACCESS_HALFWORD = 2, ARM_ACCESS_HALFWORD = 2,
@ -96,11 +97,8 @@ struct ARMMemoryAccess {
uint8_t baseReg; uint8_t baseReg;
uint16_t format; uint16_t format;
union ARMOperand offset; union ARMOperand offset;
union {
enum ARMMultipleDirection direction;
enum ARMMemoryAccessType width; enum ARMMemoryAccessType width;
}; };
};
enum ARMMnemonic { enum ARMMnemonic {
ARM_MN_ILL = 0, ARM_MN_ILL = 0,