Merge pull request #645 from lioncash/ldm

Minor bugfixes to LDM/STM.
This commit is contained in:
bunnei 2015-03-09 11:07:52 -04:00
commit f2a7c2b3b7

View file

@ -4362,6 +4362,8 @@ unsigned InterpreterMainLoop(ARMul_State* state) {
cpu->Reg[14] = Memory::Read32(addr); cpu->Reg[14] = Memory::Read32(addr);
else else
cpu->Reg_usr[1] = Memory::Read32(addr); cpu->Reg_usr[1] = Memory::Read32(addr);
addr += 4;
} }
} else if (!BIT(inst, 22)) { } else if (!BIT(inst, 22)) {
for(int i = 0; i < 16; i++ ){ for(int i = 0; i < 16; i++ ){
@ -5974,56 +5976,53 @@ unsigned InterpreterMainLoop(ARMul_State* state) {
ldst_inst* inst_cream = (ldst_inst*)inst_base->component; ldst_inst* inst_cream = (ldst_inst*)inst_base->component;
unsigned int inst = inst_cream->inst; unsigned int inst = inst_cream->inst;
int i;
unsigned int Rn = BITS(inst, 16, 19); unsigned int Rn = BITS(inst, 16, 19);
unsigned int old_RN = cpu->Reg[Rn]; unsigned int old_RN = cpu->Reg[Rn];
inst_cream->get_addr(cpu, inst_cream->inst, addr, 0); inst_cream->get_addr(cpu, inst_cream->inst, addr, 0);
if (BIT(inst_cream->inst, 22) == 1) { if (BIT(inst_cream->inst, 22) == 1) {
for (i = 0; i < 13; i++) { for (int i = 0; i < 13; i++) {
if (BIT(inst_cream->inst, i)) { if (BIT(inst_cream->inst, i)) {
Memory::Write32(addr, cpu->Reg[i]); Memory::Write32(addr, cpu->Reg[i]);
addr += 4; addr += 4;
} }
} }
if (BIT(inst_cream->inst, 13)) { if (BIT(inst_cream->inst, 13)) {
if (cpu->Mode == USER32MODE) { if (cpu->Mode == USER32MODE)
Memory::Write32(addr, cpu->Reg[i]); Memory::Write32(addr, cpu->Reg[13]);
addr += 4; else
} else {
Memory::Write32(addr, cpu->Reg_usr[0]); Memory::Write32(addr, cpu->Reg_usr[0]);
addr += 4; addr += 4;
} }
}
if (BIT(inst_cream->inst, 14)) { if (BIT(inst_cream->inst, 14)) {
if (cpu->Mode == USER32MODE) { if (cpu->Mode == USER32MODE)
Memory::Write32(addr, cpu->Reg[i]); Memory::Write32(addr, cpu->Reg[14]);
addr += 4; else
} else {
Memory::Write32(addr, cpu->Reg_usr[1]); Memory::Write32(addr, cpu->Reg_usr[1]);
addr += 4; addr += 4;
} }
}
if (BIT(inst_cream->inst, 15)) { if (BIT(inst_cream->inst, 15)) {
Memory::Write32(addr, cpu->Reg_usr[1] + 8); Memory::Write32(addr, cpu->Reg_usr[1] + 8);
} }
} else { } else {
for( i = 0; i < 15; i++ ) { for (int i = 0; i < 15; i++) {
if (BIT(inst_cream->inst, i)) { if (BIT(inst_cream->inst, i)) {
if (i == Rn) if (i == Rn)
Memory::Write32(addr, old_RN); Memory::Write32(addr, old_RN);
else else
Memory::Write32(addr, cpu->Reg[i]); Memory::Write32(addr, cpu->Reg[i]);
addr += 4; addr += 4;
} }
} }
// Check PC reg // Check PC reg
if(BIT(inst_cream->inst, i)) { if (BIT(inst_cream->inst, 15))
Memory::Write32(addr, cpu->Reg_usr[1] + 8); Memory::Write32(addr, cpu->Reg_usr[1] + 8);
} }
} }
}
cpu->Reg[15] += GET_INST_SIZE(cpu); cpu->Reg[15] += GET_INST_SIZE(cpu);
INC_PC(sizeof(ldst_inst)); INC_PC(sizeof(ldst_inst));
FETCH_INST; FETCH_INST;