Ensure LDM does not write back incorrectly with register list overlaps

This commit is contained in:
Jeffrey Pfau 2013-07-27 03:02:52 -07:00
parent 9e578da5a1
commit 425056ca15
1 changed files with 9 additions and 2 deletions

View File

@ -530,6 +530,7 @@ void ARMStep(struct ARMCore* cpu) {
DEFINE_INSTRUCTION_ARM(NAME, \
int rn = (opcode >> 16) & 0xF; \
int rs = opcode & 0x0000FFFF; \
int writeback = 1; \
int m; \
int i; \
int total = 0; \
@ -537,9 +538,11 @@ void ARMStep(struct ARMCore* cpu) {
S_PRE; \
LOOP(BODY); \
S_POST; \
WRITEBACK; \
currentCycles += cpu->memory->waitMultiple(cpu->memory, addr, total); \
POST_BODY;)
POST_BODY; \
if (writeback) { \
WRITEBACK; \
})
#define DEFINE_LOAD_STORE_MULTIPLE_INSTRUCTION_ARM(NAME, BODY, POST_BODY) \
@ -699,6 +702,10 @@ DEFINE_LOAD_STORE_MULTIPLE_INSTRUCTION_ARM(LDM,
++currentCycles;
if (rs & 0x8000) {
ARM_WRITE_PC;
}
int rnx = 1 << rn;
if (rnx & rs && ((rnx - 1) & rs)) {
writeback = 0;
})
DEFINE_LOAD_STORE_MULTIPLE_INSTRUCTION_ARM(STM,