mirror of
https://github.com/melonDS-emu/melonDS.git
synced 2025-07-25 23:29:55 -06:00
improve data aborts for ldm
This commit is contained in:
@ -397,6 +397,7 @@ void A_LDM(ARM* cpu)
|
|||||||
u32 wbbase;
|
u32 wbbase;
|
||||||
u32 preinc = (cpu->CurInstr & (1<<24));
|
u32 preinc = (cpu->CurInstr & (1<<24));
|
||||||
bool first = true;
|
bool first = true;
|
||||||
|
int abortreg = 16;
|
||||||
|
|
||||||
if (!(cpu->CurInstr & (1<<23)))
|
if (!(cpu->CurInstr & (1<<23)))
|
||||||
{
|
{
|
||||||
@ -415,10 +416,32 @@ void A_LDM(ARM* cpu)
|
|||||||
preinc = !preinc;
|
preinc = !preinc;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// check for data aborts
|
||||||
|
if (cpu->Num == 0)
|
||||||
|
{
|
||||||
|
u32 tmpbase = base;
|
||||||
|
for (int i = 0; i < 16; i++)
|
||||||
|
{
|
||||||
|
if (cpu->CurInstr & (1<<i))
|
||||||
|
{
|
||||||
|
if (preinc) tmpbase += 4;
|
||||||
|
if(((ARMv5*)cpu)->PU_Map[tmpbase>>12] & 0x01)
|
||||||
|
{
|
||||||
|
if (!preinc) tmpbase += 4;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
abortreg = i;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if ((cpu->CurInstr & (1<<22)) && !(cpu->CurInstr & (1<<15)))
|
if ((cpu->CurInstr & (1<<22)) && !(cpu->CurInstr & (1<<15)))
|
||||||
cpu->UpdateMode(cpu->CPSR, (cpu->CPSR&~0x1F)|0x10, true);
|
cpu->UpdateMode(cpu->CPSR, (cpu->CPSR&~0x1F)|0x10, true);
|
||||||
|
|
||||||
for (int i = 0; i < 15; i++)
|
for (int i = 0; i < std::min(15, abortreg); i++)
|
||||||
{
|
{
|
||||||
if (cpu->CurInstr & (1<<i))
|
if (cpu->CurInstr & (1<<i))
|
||||||
{
|
{
|
||||||
@ -431,7 +454,7 @@ void A_LDM(ARM* cpu)
|
|||||||
}
|
}
|
||||||
|
|
||||||
u32 pc;
|
u32 pc;
|
||||||
if (cpu->CurInstr & (1<<15))
|
if ((cpu->CurInstr & (1<<15)) && (abortreg == 16))
|
||||||
{
|
{
|
||||||
if (preinc) base += 4;
|
if (preinc) base += 4;
|
||||||
if (first) cpu->DataRead32 (base, &pc);
|
if (first) cpu->DataRead32 (base, &pc);
|
||||||
@ -445,6 +468,9 @@ void A_LDM(ARM* cpu)
|
|||||||
if ((cpu->CurInstr & (1<<22)) && !(cpu->CurInstr & (1<<15)))
|
if ((cpu->CurInstr & (1<<22)) && !(cpu->CurInstr & (1<<15)))
|
||||||
cpu->UpdateMode((cpu->CPSR&~0x1F)|0x10, cpu->CPSR, true);
|
cpu->UpdateMode((cpu->CPSR&~0x1F)|0x10, cpu->CPSR, true);
|
||||||
|
|
||||||
|
// if it's 16 then there was no data abort
|
||||||
|
if (abortreg == 16)
|
||||||
|
{
|
||||||
if (cpu->CurInstr & (1<<21))
|
if (cpu->CurInstr & (1<<21))
|
||||||
{
|
{
|
||||||
// post writeback
|
// post writeback
|
||||||
@ -466,6 +492,11 @@ void A_LDM(ARM* cpu)
|
|||||||
|
|
||||||
if (cpu->CurInstr & (1<<15))
|
if (cpu->CurInstr & (1<<15))
|
||||||
cpu->JumpTo(pc, cpu->CurInstr & (1<<22));
|
cpu->JumpTo(pc, cpu->CurInstr & (1<<22));
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
((ARMv5*)cpu)->DataAbort();
|
||||||
|
}
|
||||||
|
|
||||||
cpu->AddCycles_CDI();
|
cpu->AddCycles_CDI();
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user