From fec40406919485b5175349bc79016768ae1dfcf0 Mon Sep 17 00:00:00 2001 From: Jeffrey Pfau Date: Sat, 9 Nov 2013 13:49:34 -0800 Subject: [PATCH] Load/store with immediate width corrections --- src/arm/decoder-thumb.c | 36 ++++++++++++++++++------------------ 1 file changed, 18 insertions(+), 18 deletions(-) diff --git a/src/arm/decoder-thumb.c b/src/arm/decoder-thumb.c index bd0b7a46e..4074d5f88 100644 --- a/src/arm/decoder-thumb.c +++ b/src/arm/decoder-thumb.c @@ -15,7 +15,7 @@ BODY; \ } -#define DEFINE_IMMEDIATE_5_DECODER_DATA_THUMB(NAME, IMMEDIATE, MNEMONIC) \ +#define DEFINE_IMMEDIATE_5_DECODER_DATA_THUMB(NAME, IMMEDIATE, MNEMONIC, WIDTH) \ DEFINE_THUMB_DECODER(NAME, MNEMONIC, \ info->op3.immediate = IMMEDIATE; \ info->op1.reg = opcode & 0x0007; \ @@ -26,11 +26,11 @@ ARM_OPERAND_REGISTER_2 | \ ARM_OPERAND_IMMEDIATE_3;) -#define DEFINE_IMMEDIATE_5_DECODER_MEM_THUMB(NAME, IMMEDIATE, MNEMONIC, CYCLES) \ +#define DEFINE_IMMEDIATE_5_DECODER_MEM_THUMB(NAME, IMMEDIATE, MNEMONIC, CYCLES, WIDTH) \ DEFINE_THUMB_DECODER(NAME, MNEMONIC, \ info->op1.reg = opcode & 0x0007; \ info->memory.baseReg = (opcode >> 3) & 0x0007; \ - info->memory.offset.immediate = IMMEDIATE << 2; \ + info->memory.offset.immediate = IMMEDIATE * WIDTH; \ info->operandFormat = ARM_OPERAND_REGISTER_1 | \ ARM_OPERAND_AFFECTED_1 | \ ARM_OPERAND_MEMORY_2; \ @@ -38,24 +38,24 @@ ARM_MEMORY_IMMEDIATE_OFFSET; \ CYCLES) -#define DEFINE_IMMEDIATE_5_DECODER_MEM_LOAD_THUMB(NAME, IMMEDIATE, MNEMONIC) \ - DEFINE_IMMEDIATE_5_DECODER_MEM_THUMB(NAME, IMMEDIATE, MNEMONIC, LOAD_CYCLES) +#define DEFINE_IMMEDIATE_5_DECODER_MEM_LOAD_THUMB(NAME, IMMEDIATE, MNEMONIC, WIDTH) \ + DEFINE_IMMEDIATE_5_DECODER_MEM_THUMB(NAME, IMMEDIATE, MNEMONIC, LOAD_CYCLES, WIDTH) -#define DEFINE_IMMEDIATE_5_DECODER_MEM_STORE_THUMB(NAME, IMMEDIATE, MNEMONIC) \ - DEFINE_IMMEDIATE_5_DECODER_MEM_THUMB(NAME, IMMEDIATE, MNEMONIC, STORE_CYCLES) +#define DEFINE_IMMEDIATE_5_DECODER_MEM_STORE_THUMB(NAME, IMMEDIATE, MNEMONIC, WIDTH) \ + DEFINE_IMMEDIATE_5_DECODER_MEM_THUMB(NAME, IMMEDIATE, MNEMONIC, STORE_CYCLES, WIDTH) -#define DEFINE_IMMEDIATE_5_DECODER_THUMB(NAME, MNEMONIC, TYPE) \ - COUNT_5(DEFINE_IMMEDIATE_5_DECODER_ ## TYPE ## _THUMB, NAME ## _, MNEMONIC) +#define DEFINE_IMMEDIATE_5_DECODER_THUMB(NAME, MNEMONIC, TYPE, WIDTH) \ + COUNT_5(DEFINE_IMMEDIATE_5_DECODER_ ## TYPE ## _THUMB, NAME ## _, MNEMONIC, WIDTH) -DEFINE_IMMEDIATE_5_DECODER_THUMB(LSL1, LSL, DATA) -DEFINE_IMMEDIATE_5_DECODER_THUMB(LSR1, LSR, DATA) -DEFINE_IMMEDIATE_5_DECODER_THUMB(ASR1, ASR, DATA) -DEFINE_IMMEDIATE_5_DECODER_THUMB(LDR1, LDR, MEM_LOAD) -DEFINE_IMMEDIATE_5_DECODER_THUMB(LDRB1, LDRB, MEM_LOAD) -DEFINE_IMMEDIATE_5_DECODER_THUMB(LDRH1, LDRH, MEM_LOAD) -DEFINE_IMMEDIATE_5_DECODER_THUMB(STR1, STR, MEM_STORE) -DEFINE_IMMEDIATE_5_DECODER_THUMB(STRB1, STRB, MEM_STORE) -DEFINE_IMMEDIATE_5_DECODER_THUMB(STRH1, STRH, MEM_STORE) +DEFINE_IMMEDIATE_5_DECODER_THUMB(LSL1, LSL, DATA,) +DEFINE_IMMEDIATE_5_DECODER_THUMB(LSR1, LSR, DATA,) +DEFINE_IMMEDIATE_5_DECODER_THUMB(ASR1, ASR, DATA,) +DEFINE_IMMEDIATE_5_DECODER_THUMB(LDR1, LDR, MEM_LOAD, 4) +DEFINE_IMMEDIATE_5_DECODER_THUMB(LDRB1, LDRB, MEM_LOAD, 1) +DEFINE_IMMEDIATE_5_DECODER_THUMB(LDRH1, LDRH, MEM_LOAD, 2) +DEFINE_IMMEDIATE_5_DECODER_THUMB(STR1, STR, MEM_STORE, 4) +DEFINE_IMMEDIATE_5_DECODER_THUMB(STRB1, STRB, MEM_STORE, 1) +DEFINE_IMMEDIATE_5_DECODER_THUMB(STRH1, STRH, MEM_STORE, 2) #define DEFINE_DATA_FORM_1_DECODER_EX_THUMB(NAME, RM, MNEMONIC) \ DEFINE_THUMB_DECODER(NAME, MNEMONIC, \