From 7a4255b7327dc9ccdfa471b5acbc4ece7184b470 Mon Sep 17 00:00:00 2001 From: Arisotura Date: Tue, 29 Oct 2024 14:18:57 +0100 Subject: [PATCH] fix LDM bugs --- src/ARMInterpreter_LoadStore.cpp | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/src/ARMInterpreter_LoadStore.cpp b/src/ARMInterpreter_LoadStore.cpp index cb646df5..f7c24312 100644 --- a/src/ARMInterpreter_LoadStore.cpp +++ b/src/ARMInterpreter_LoadStore.cpp @@ -430,9 +430,9 @@ void A_LDM(ARM* cpu) } } + u32 pc = 0; if (cpu->CurInstr & (1<<15)) { - u32 pc; if (preinc) base += 4; if (first) cpu->DataRead32 (base, &pc); else cpu->DataRead32S(base, &pc); @@ -440,13 +440,8 @@ void A_LDM(ARM* cpu) if (cpu->Num == 1) pc &= ~0x1; - - cpu->JumpTo(pc, cpu->CurInstr & (1<<22)); } - if ((cpu->CurInstr & (1<<22)) && !(cpu->CurInstr & (1<<15))) - cpu->UpdateMode((cpu->CPSR&~0x1F)|0x10, cpu->CPSR, true); - if (cpu->CurInstr & (1<<21)) { // post writeback @@ -466,6 +461,12 @@ void A_LDM(ARM* cpu) cpu->R[baseid] = wbbase; } + if ((cpu->CurInstr & (1<<22)) && !(cpu->CurInstr & (1<<15))) + cpu->UpdateMode((cpu->CPSR&~0x1F)|0x10, cpu->CPSR, true); + + if (cpu->CurInstr & (1<<15)) + cpu->JumpTo(pc, cpu->CurInstr & (1<<22)); + cpu->AddCycles_CDI(); }