JIT: handle STR post with rd == rn

fixes Zelda Four Swords
This commit is contained in:
RSDuck
2021-01-19 23:49:32 +01:00
parent 31c9d116bd
commit 771dfaca2e
5 changed files with 53 additions and 21 deletions

View File

@ -130,6 +130,12 @@ void Compiler::Comp_MemAccess(int rd, int rn, const Op2& op2, int size, int flag
if (Thumb && rn == 15)
rnMapped = Imm32(R15 & ~0x2);
if (flags & memop_Store && flags & (memop_Post|memop_Writeback) && rd == rn)
{
MOV(32, R(RSCRATCH4), rdMapped);
rdMapped = R(RSCRATCH4);
}
X64Reg finalAddr = RSCRATCH3;
if (flags & memop_Post)
{
@ -282,13 +288,15 @@ void Compiler::Comp_MemAccess(int rd, int rn, const Op2& op2, int size, int flag
{
if (Num == 0)
{
// on Windows param 3 is R8 which is also scratch 4 which can be used for rd
if (flags & memop_Store)
MOV(32, R(ABI_PARAM3), rdMapped);
MOV(64, R(ABI_PARAM2), R(RCPU));
if (ABI_PARAM1 != RSCRATCH3)
MOV(32, R(ABI_PARAM1), R(RSCRATCH3));
if (flags & memop_Store)
{
MOV(32, R(ABI_PARAM3), rdMapped);
switch (size | NDS::ConsoleType)
{
case 32: CALL((void*)&SlowWrite9<u32, 0>); break;