From 1e8194e367517b6c08b0bc4ae38971843973c656 Mon Sep 17 00:00:00 2001 From: Jaklyy <102590697+Jaklyy@users.noreply.github.com> Date: Tue, 4 Jun 2024 19:06:54 -0400 Subject: [PATCH] fix ldr and str --- src/ARMInterpreter_LoadStore.cpp | 24 ++++++++++++++---------- 1 file changed, 14 insertions(+), 10 deletions(-) diff --git a/src/ARMInterpreter_LoadStore.cpp b/src/ARMInterpreter_LoadStore.cpp index 96766288..fe9bfd0c 100644 --- a/src/ARMInterpreter_LoadStore.cpp +++ b/src/ARMInterpreter_LoadStore.cpp @@ -65,9 +65,10 @@ namespace melonDS::ARMInterpreter u32 storeval = cpu->R[(cpu->CurInstr>>12) & 0xF]; \ if (((cpu->CurInstr>>12) & 0xF) == 0xF) \ storeval += 4; \ - cpu->DataWrite32(offset, storeval); \ - if (cpu->CurInstr & (1<<21)) cpu->R[(cpu->CurInstr>>16) & 0xF] = offset; \ - cpu->AddCycles_CD(); + bool dataabort = !cpu->DataWrite32(offset, storeval); \ + cpu->AddCycles_CD(); \ + if (dataabort) return; \ + if (cpu->CurInstr & (1<<21)) cpu->R[(cpu->CurInstr>>16) & 0xF] = offset; // TODO: user mode (bit21) #define A_STR_POST \ @@ -75,9 +76,10 @@ namespace melonDS::ARMInterpreter u32 storeval = cpu->R[(cpu->CurInstr>>12) & 0xF]; \ if (((cpu->CurInstr>>12) & 0xF) == 0xF) \ storeval += 4; \ - cpu->DataWrite32(addr, storeval); \ - cpu->R[(cpu->CurInstr>>16) & 0xF] += offset; \ - cpu->AddCycles_CD(); + bool dataabort = !cpu->DataWrite32(addr, storeval); \ + cpu->AddCycles_CD(); \ + if (dataabort) return; \ + cpu->R[(cpu->CurInstr>>16) & 0xF] += offset; #define A_STRB \ offset += cpu->R[(cpu->CurInstr>>16) & 0xF]; \ @@ -94,10 +96,11 @@ namespace melonDS::ARMInterpreter #define A_LDR \ offset += cpu->R[(cpu->CurInstr>>16) & 0xF]; \ - u32 val; cpu->DataRead32(offset, &val); \ + u32 val; bool dataabort = !cpu->DataRead32(offset, &val); \ + cpu->AddCycles_CDI(); \ + if (dataabort) return; \ val = ROR(val, ((offset&0x3)<<3)); \ if (cpu->CurInstr & (1<<21)) cpu->R[(cpu->CurInstr>>16) & 0xF] = offset; \ - cpu->AddCycles_CDI(); \ if (((cpu->CurInstr>>12) & 0xF) == 15) \ { \ if (cpu->Num==1) val &= ~0x1; \ @@ -111,10 +114,11 @@ namespace melonDS::ARMInterpreter // TODO: user mode #define A_LDR_POST \ u32 addr = cpu->R[(cpu->CurInstr>>16) & 0xF]; \ - u32 val; cpu->DataRead32(addr, &val); \ + u32 val; bool dataabort = !cpu->DataRead32(addr, &val); \ + cpu->AddCycles_CDI(); \ + if (dataabort) return; \ val = ROR(val, ((addr&0x3)<<3)); \ cpu->R[(cpu->CurInstr>>16) & 0xF] += offset; \ - cpu->AddCycles_CDI(); \ if (((cpu->CurInstr>>12) & 0xF) == 15) \ { \ if (cpu->Num==1) val &= ~0x1; \