mirror of https://github.com/mgba-emu/mgba.git
Ensure LDM does not write back incorrectly with register list overlaps
This commit is contained in:
parent
9e578da5a1
commit
425056ca15
|
@ -530,6 +530,7 @@ void ARMStep(struct ARMCore* cpu) {
|
||||||
DEFINE_INSTRUCTION_ARM(NAME, \
|
DEFINE_INSTRUCTION_ARM(NAME, \
|
||||||
int rn = (opcode >> 16) & 0xF; \
|
int rn = (opcode >> 16) & 0xF; \
|
||||||
int rs = opcode & 0x0000FFFF; \
|
int rs = opcode & 0x0000FFFF; \
|
||||||
|
int writeback = 1; \
|
||||||
int m; \
|
int m; \
|
||||||
int i; \
|
int i; \
|
||||||
int total = 0; \
|
int total = 0; \
|
||||||
|
@ -537,9 +538,11 @@ void ARMStep(struct ARMCore* cpu) {
|
||||||
S_PRE; \
|
S_PRE; \
|
||||||
LOOP(BODY); \
|
LOOP(BODY); \
|
||||||
S_POST; \
|
S_POST; \
|
||||||
WRITEBACK; \
|
|
||||||
currentCycles += cpu->memory->waitMultiple(cpu->memory, addr, total); \
|
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) \
|
#define DEFINE_LOAD_STORE_MULTIPLE_INSTRUCTION_ARM(NAME, BODY, POST_BODY) \
|
||||||
|
@ -699,6 +702,10 @@ DEFINE_LOAD_STORE_MULTIPLE_INSTRUCTION_ARM(LDM,
|
||||||
++currentCycles;
|
++currentCycles;
|
||||||
if (rs & 0x8000) {
|
if (rs & 0x8000) {
|
||||||
ARM_WRITE_PC;
|
ARM_WRITE_PC;
|
||||||
|
}
|
||||||
|
int rnx = 1 << rn;
|
||||||
|
if (rnx & rs && ((rnx - 1) & rs)) {
|
||||||
|
writeback = 0;
|
||||||
})
|
})
|
||||||
|
|
||||||
DEFINE_LOAD_STORE_MULTIPLE_INSTRUCTION_ARM(STM,
|
DEFINE_LOAD_STORE_MULTIPLE_INSTRUCTION_ARM(STM,
|
||||||
|
|
Loading…
Reference in New Issue