Skip to content

Commit

Permalink
arm dynarec: apply mask to mem write8 and write16 value operand
Browse files Browse the repository at this point in the history
Compilers do not cast the operand, which results in u8 handlers being
called with an u32 value.
  • Loading branch information
flyinghead committed Mar 14, 2024
1 parent 3ffb09e commit 6115a91
Showing 1 changed file with 11 additions and 2 deletions.
13 changes: 11 additions & 2 deletions core/rec-ARM/rec_arm.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1136,7 +1136,11 @@ bool Arm32Assembler::writeMemImmediate(RuntimeBlockInfo* block, shil_opcode* op,
if (optp == SZ_64F)
die("SZ_64F not supported");
Mov(r0, op->rs1._imm);
if (optp == SZ_32F)
if (optp == SZ_8)
Uxtb(r1, rs2);
else if (optp == SZ_16)
Uxth(r1, rs2);
else if (optp == SZ_32F)
Vmov(r1, rs2f);
else if (!rs2.Is(r1))
Mov(r1, rs2);
Expand Down Expand Up @@ -2472,12 +2476,17 @@ void Arm32Assembler::genMainLoop()
continue;

const void *v;
if (i == 0)
if (i == 0 && s != 3 && s != 4) {
v = fn;
}
else
{
v = GetCursorAddress<const void *>();
Mov(r0, Register(i));
if (s == 3)
Uxtb(r1, r1);
else if (s == 4)
Uxth(r1, r1);
jump(fn);
}

Expand Down

0 comments on commit 6115a91

Please sign in to comment.