Cleaning up writeback and add some TODOs

This commit is contained in:
Jeffrey Pfau 2014-07-11 03:19:02 -07:00
parent 874f23fc59
commit ba4874f8b7
2 changed files with 10 additions and 5 deletions

View File

@ -202,7 +202,7 @@ DEFINE_IMMEDIATE_WITH_REGISTER_THUMB(ADD6, ADD, DATA, ARM_SP)
info->memory.baseReg = (opcode >> 3) & 0x0007; \ info->memory.baseReg = (opcode >> 3) & 0x0007; \
info->memory.width = TYPE; \ info->memory.width = TYPE; \
info->operandFormat = ARM_OPERAND_REGISTER_1 | \ info->operandFormat = ARM_OPERAND_REGISTER_1 | \
ARM_OPERAND_AFFECTED_1 | \ ARM_OPERAND_AFFECTED_1 | /* TODO: Remove this for STR */ \
ARM_OPERAND_MEMORY_2; \ ARM_OPERAND_MEMORY_2; \
info->memory.format = ARM_MEMORY_REGISTER_BASE | \ info->memory.format = ARM_MEMORY_REGISTER_BASE | \
ARM_MEMORY_REGISTER_OFFSET; \ ARM_MEMORY_REGISTER_OFFSET; \
@ -220,6 +220,7 @@ DEFINE_LOAD_STORE_WITH_REGISTER_THUMB(STR2, STR, STORE_CYCLES, ARM_ACCESS_WORD)
DEFINE_LOAD_STORE_WITH_REGISTER_THUMB(STRB2, STR, STORE_CYCLES, ARM_ACCESS_BYTE) DEFINE_LOAD_STORE_WITH_REGISTER_THUMB(STRB2, STR, STORE_CYCLES, ARM_ACCESS_BYTE)
DEFINE_LOAD_STORE_WITH_REGISTER_THUMB(STRH2, STR, STORE_CYCLES, ARM_ACCESS_HALFWORD) DEFINE_LOAD_STORE_WITH_REGISTER_THUMB(STRH2, STR, STORE_CYCLES, ARM_ACCESS_HALFWORD)
// TODO: Estimate memory cycles
#define DEFINE_LOAD_STORE_MULTIPLE_EX_THUMB(NAME, RN, MNEMONIC, DIRECTION, ADDITIONAL_REG) \ #define DEFINE_LOAD_STORE_MULTIPLE_EX_THUMB(NAME, RN, MNEMONIC, DIRECTION, ADDITIONAL_REG) \
DEFINE_THUMB_DECODER(NAME, MNEMONIC, \ DEFINE_THUMB_DECODER(NAME, MNEMONIC, \
info->memory.baseReg = RN; \ info->memory.baseReg = RN; \
@ -227,7 +228,8 @@ DEFINE_LOAD_STORE_WITH_REGISTER_THUMB(STRH2, STR, STORE_CYCLES, ARM_ACCESS_HALFW
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.format = ARM_MEMORY_REGISTER_BASE | \ info->memory.format = ARM_MEMORY_REGISTER_BASE | \
ARM_MEMORY_POST_INCREMENT | DIRECTION;) ARM_MEMORY_WRITEBACK | \
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_MEMORY_INCREMENT_AFTER, 0) COUNT_3(DEFINE_LOAD_STORE_MULTIPLE_EX_THUMB, NAME ## IA_R, NAME, ARM_MEMORY_INCREMENT_AFTER, 0)
@ -422,8 +424,12 @@ int ARMDisassembleThumb(uint16_t opcode, uint32_t pc, char* buffer, int blen) {
case ARM_MN_STM: case ARM_MN_STM:
written = _decodeRegister(info.memory.baseReg, buffer, blen); written = _decodeRegister(info.memory.baseReg, buffer, blen);
ADVANCE(written); ADVANCE(written);
strncpy(buffer, "!, ", blen - 1); if (info.memory.format & ARM_MEMORY_WRITEBACK) {
ADVANCE(3); strncpy(buffer, "!", blen - 1);
ADVANCE(1);
}
strncpy(buffer, ", ", blen - 1);
ADVANCE(2);
written = _decodeRegisterList(info.op1.immediate, buffer, blen); written = _decodeRegisterList(info.op1.immediate, buffer, blen);
ADVANCE(written); ADVANCE(written);
break; break;

View File

@ -52,7 +52,6 @@ enum ARMMemoryFormat {
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_WRITEBACK = 0x0080,
ARM_MEMORY_DECREMENT_AFTER = 0x0000, ARM_MEMORY_DECREMENT_AFTER = 0x0000,
ARM_MEMORY_INCREMENT_AFTER = 0x0100, ARM_MEMORY_INCREMENT_AFTER = 0x0100,