all repos — mgba @ fec40406919485b5175349bc79016768ae1dfcf0

mGBA Game Boy Advance Emulator

Load/store with immediate width corrections
Jeffrey Pfau jeffrey@endrift.com
Sat, 09 Nov 2013 13:49:34 -0800
commit

fec40406919485b5175349bc79016768ae1dfcf0

parent

fc132b4d938f8d19936b9d93863f1d3eab8234ce

1 files changed, 18 insertions(+), 18 deletions(-)

jump to
M src/arm/decoder-thumb.csrc/arm/decoder-thumb.c

@@ -15,7 +15,7 @@ info->mnemonic = THUMB_MN_ ## MNEMONIC; \

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_AFFECTED_1 | \

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 @@ info->memory.format = ARM_MEMORY_REGISTER_BASE | \

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, \