Skip to content

Commit

Permalink
Fix: crash reported by @ptomin.
Browse files Browse the repository at this point in the history
  • Loading branch information
uxmal committed Jul 25, 2023
1 parent 293b769 commit 5a7db36
Show file tree
Hide file tree
Showing 3 changed files with 32 additions and 2 deletions.
4 changes: 3 additions & 1 deletion src/Arch/X86/Analysis/FstswAnalysis.cs
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@
using Reko.Core.Code;
using Reko.Core.Collections;
using Reko.Core.Expressions;
using Reko.Core.Machine;
using Reko.Core.Operators;
using Reko.Core.Services;
using System;
Expand Down Expand Up @@ -208,6 +207,9 @@ binCof.Left is Identifier acc &&
ReplaceWithFpufCopy(use, ass.Dst, sidFpuf);
changed = true;
break;
case MkSequence _:
// An aliasing use of ax or ah; eax = SEQ(<stuff>, ax) can be ignored.
continue;
default:
throw new NotImplementedException($"Fstsw of {ass} not implemented yet.");
}
Expand Down
28 changes: 28 additions & 0 deletions src/UnitTests/Arch/X86/Analysis/FstswAnalysisTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -504,5 +504,33 @@ branch Test(NE,FPUF) l00100000
m.Ret();
});
}


[Test]
public void Fstsw_through_alias()
{
RunTest(@"
l00100000:
ax_4 = __fstsw(FPUF)
ah_5 = SLICE(ax_4, byte, 8) (alias)
SZP_6 = cond(ah_5 & 0x41<8>)
Z_9 = SLICE(SZP_6, bool, 2) (alias)
O_7 = false
C_8 = false
eax_12 = SEQ(eax_16_16, ax_4) (alias)
branch Test(GT,FPUF) l00100000
",
m =>
{
m.Label("foo");
m.Fstsw(m.ax);
m.Test(m.ah, 0x41);
m.Jz("foo");
m.Label("m1");
m.Or(m.eax, m.Imm(0xFFFFFFFF));
m.Ret();
});
}
}
}
2 changes: 1 addition & 1 deletion subjects/regression.log

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 5a7db36

Please sign in to comment.