Fixes a bug in the CBW/CWDE/CDQE instruction

Was running at the wrong size the entire time
This commit is contained in:
Ryan Houdek authored and Stefanos Kornilios Mitsis Poiitidis committed 2020-03-06 07:55:14 +02:00
1 parent 199cfd76d8
commit 4ccdd689ce
2 files changed
+11 -12

No files matched your search

+7 -8
View File
@@ -836,14 +836,14 @@ void OpDispatchBuilder::XCHGOp(OpcodeArgs) {
void OpDispatchBuilder::CDQOp(OpcodeArgs) {
OrderedNode *Src = LoadSource(Op, Op->Src1, Op->Flags);
// Op size is destination size
// Therefore sext OpSize/2
uint8_t SrcSize = GetSrcSize(Op) / 2;
Src = _Sext(SrcSize * 8, Src);
if (SrcSize == 4)
Src = _Zext(SrcSize * 2 * 8, Src);
uint8_t SrcSize = GetSrcSize(Op);
StoreResult_WithOpSize(Op, Op->Dest, Src, SrcSize * 2 * 8);
Src = _Sext(SrcSize * 4, Src);
if (SrcSize == 4) {
Src = _Zext(SrcSize * 8, Src);
SrcSize *= 2;
}
StoreResult_WithOpSize(Op, Op->Dest, Src, SrcSize * 8);
}
void OpDispatchBuilder::SAHFOp(OpcodeArgs) {
@@ -3242,7 +3242,6 @@ void OpDispatchBuilder::ReplaceAllUsesWithInclusive(OrderedNode *Node, OrderedNo
for (uint8_t i = 0; i < IROp->NumArgs; ++i) {
if (IROp->Args[i].ID() == Node->Wrapped(ListBegin).ID()) {
LogMan::Msg::D("\tAt %%ssa%d: Replacing ID %%ssa%d with %%ssa%d", WrapperOp->ID(), IROp->Args[i].ID(), NewNode->Wrapped(ListBegin).ID());
Node->RemoveUse();
NewNode->AddUse();
IROp->Args[i].NodeOffset = NewNode->Wrapped(ListBegin).NodeOffset;
+4 -4
View File
@@ -174,11 +174,11 @@ public:
IRPair<IROp_Select> _Select(uint8_t Cond, OrderedNode *ssa0, OrderedNode *ssa1, OrderedNode *ssa2, OrderedNode *ssa3) {
return _Select(ssa0, ssa1, ssa2, ssa3, Cond);
}
IRPair<IROp_Sext> _Sext(uint8_t Size, OrderedNode *ssa0) {
return _Sext(ssa0, Size);
IRPair<IROp_Sext> _Sext(uint8_t SrcSize, OrderedNode *ssa0) {
return _Sext(ssa0, SrcSize);
}
IRPair<IROp_Zext> _Zext(uint8_t Size, OrderedNode *ssa0) {
return _Zext(ssa0, Size);
IRPair<IROp_Zext> _Zext(uint8_t SrcSize, OrderedNode *ssa0) {
return _Zext(ssa0, SrcSize);
}
IRPair<IROp_VInsElement> _VInsElement(uint8_t RegisterSize, uint8_t ElementSize, uint8_t DestIdx, uint8_t SrcIdx, OrderedNode *ssa0, OrderedNode *ssa1) {
return _VInsElement(ssa0, ssa1, RegisterSize, ElementSize, DestIdx, SrcIdx);