Skip to content

Commit

Permalink
Fix mulslw and mululw zero calculation
Browse files Browse the repository at this point in the history
  • Loading branch information
987123879113 committed Jan 3, 2025
1 parent d274935 commit fd7af38
Showing 1 changed file with 8 additions and 5 deletions.
13 changes: 8 additions & 5 deletions src/devices/cpu/drcbearm64.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2728,7 +2728,7 @@ void drcbe_arm64::op_mululw(a64::Assembler &a, const uml::instruction &inst)
{
a.mrs(TEMP_REG1, a64::Predicate::SysReg::kNZCV);

a.tst(lo, lo);
a.tst(select_register(lo, inst.size()), select_register(lo, inst.size()));
a.cset(SCRATCH_REG1, a64::CondCode::kEQ);
a.bfi(TEMP_REG1, SCRATCH_REG1, 30, 1); // zero flag

Expand Down Expand Up @@ -2836,7 +2836,9 @@ void drcbe_arm64::op_mulslw(a64::Assembler &a, const uml::instruction &inst)
if ((src1p.is_immediate() && src1p.immediate() == 0) || (src1p.is_immediate() && src1p.immediate() == 0))
{
a.mov(lo, a64::xzr);
a.mov(hi, a64::xzr);

if (inst.flags() && inst.size() == 8)
a.mov(hi, a64::xzr);
}
else
{
Expand All @@ -2846,12 +2848,13 @@ void drcbe_arm64::op_mulslw(a64::Assembler &a, const uml::instruction &inst)
if (inst.size() == 8)
{
a.mul(lo, src1, src2);
a.smulh(hi, src1, src2);

if (inst.flags())
a.smulh(hi, src1, src2);
}
else
{
a.smull(lo, src1.w(), src2.w());
a.lsr(hi, lo, 32);
}
}

Expand All @@ -2861,7 +2864,7 @@ void drcbe_arm64::op_mulslw(a64::Assembler &a, const uml::instruction &inst)
{
a.mrs(SCRATCH_REG1, a64::Predicate::SysReg::kNZCV);

a.tst(lo, lo);
a.tst(select_register(lo, inst.size()), select_register(lo, inst.size()));
a.cset(TEMP_REG1, a64::CondCode::kEQ);
a.bfi(SCRATCH_REG1, TEMP_REG1, 30, 1); // zero flag

Expand Down

0 comments on commit fd7af38

Please sign in to comment.