Implement LDR[S]B/LDR[S]H (2)
Jeffrey Pfau jeffrey@endrift.com
Sun, 14 Apr 2013 03:38:09 -0700
1 files changed,
6 insertions(+),
4 deletions(-)
jump to
M
src/isa-thumb.c
→
src/isa-thumb.c
@@ -265,16 +265,18 @@
#define DEFINE_LOAD_STORE_WITH_REGISTER_EX_THUMB(NAME, RM, BODY) \ DEFINE_INSTRUCTION_THUMB(NAME, \ int rm = RM; \ + int rd = opcode & 0x0007; \ + int rn = (opcode >> 3) & 0x0007; \ BODY;) #define DEFINE_LOAD_STORE_WITH_REGISTER_THUMB(NAME, BODY) \ COUNT_3(DEFINE_LOAD_STORE_WITH_REGISTER_EX_THUMB, NAME ## _R, BODY) DEFINE_LOAD_STORE_WITH_REGISTER_THUMB(LDR2, ARM_STUB) -DEFINE_LOAD_STORE_WITH_REGISTER_THUMB(LDRB2, ARM_STUB) -DEFINE_LOAD_STORE_WITH_REGISTER_THUMB(LDRH2, ARM_STUB) -DEFINE_LOAD_STORE_WITH_REGISTER_THUMB(LDRSB, ARM_STUB) -DEFINE_LOAD_STORE_WITH_REGISTER_THUMB(LDRSH, ARM_STUB) +DEFINE_LOAD_STORE_WITH_REGISTER_THUMB(LDRB2, cpu->gprs[rd] = cpu->memory->loadU8(cpu->memory, cpu->gprs[rn] + cpu->gprs[rm])) +DEFINE_LOAD_STORE_WITH_REGISTER_THUMB(LDRH2, cpu->gprs[rd] = cpu->memory->loadU16(cpu->memory, cpu->gprs[rn] + cpu->gprs[rm])) +DEFINE_LOAD_STORE_WITH_REGISTER_THUMB(LDRSB, cpu->gprs[rd] = cpu->memory->load8(cpu->memory, cpu->gprs[rn] + cpu->gprs[rm])) +DEFINE_LOAD_STORE_WITH_REGISTER_THUMB(LDRSH, cpu->gprs[rd] = cpu->memory->load16(cpu->memory, cpu->gprs[rn] + cpu->gprs[rm])) DEFINE_LOAD_STORE_WITH_REGISTER_THUMB(STR2, ARM_STUB) DEFINE_LOAD_STORE_WITH_REGISTER_THUMB(STRB2, ARM_STUB) DEFINE_LOAD_STORE_WITH_REGISTER_THUMB(STRH2, ARM_STUB)