Skip to content

Commit

Permalink
Merge pull request #29 from charsleysa/tgiphil-dev
Browse files Browse the repository at this point in the history
Fix MovStore
  • Loading branch information
tgiphil committed Aug 6, 2017
2 parents 10265cc + 145ba82 commit 8ce3a5f
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 4 deletions.
6 changes: 3 additions & 3 deletions Source/Mosa.Platform.x86/Instructions/MovStore.cs
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ private static void MovImmediateToMemory(InstructionNode node, BaseCodeEmitter e
.Append3Bits(Bits.b011) // 3:opcode
.AppendWidthBit(node.Size != InstructionSize.Size8) // 1:width
.ModRegRMSIBDisplacement(true, node.Operand1, node.Operand3, node.Operand2) // Mod-Reg-RM-?SIB-?Displacement
.AppendInteger(node.Operand3, node.Size) // 8/16/32:immediate
.AppendConditionalIntegerOfSize(!node.Operand3.IsLinkerResolved, node.Operand3, node.Size) // 8/16/32:immediate
.AppendConditionalPatchPlaceholder(node.Operand3.IsLinkerResolved, out patchOffset); // 32:memory

if (node.Operand3.IsLinkerResolved)
Expand All @@ -84,7 +84,7 @@ private static void MovImmediateToFixedMemory(InstructionNode node, BaseCodeEmit
{
Debug.Assert(node.Operand1.IsConstant);
Debug.Assert(node.Operand2.IsResolvedConstant);
Debug.Assert(node.Operand3.IsConstant);
Debug.Assert(node.Operand3.IsResolvedConstant);

int patchOffset;

Expand All @@ -102,7 +102,7 @@ private static void MovImmediateToFixedMemory(InstructionNode node, BaseCodeEmit
.AppendConditionalDisplacement(!node.Operand1.IsLinkerResolved, node.Operand1) // 32:displacement value

.AppendConditionalPatchPlaceholder(node.Operand1.IsLinkerResolved, out patchOffset) // 32:memory
.AppendInteger(node.Operand3, node.Size); // 8/16/32:immediate
.AppendConditionalIntegerOfSize(true, node.Operand3, node.Size); // 8/16/32:immediate

if (node.Operand1.IsLinkerResolved && !node.Operand3.IsLinkerResolved)
{
Expand Down
5 changes: 4 additions & 1 deletion Source/Mosa.Platform.x86/OpcodeEncoder.cs
Original file line number Diff line number Diff line change
Expand Up @@ -355,8 +355,11 @@ public OpcodeEncoder AppendConditionalREXPrefix(bool include, bool w, bool r, bo
return this;
}

public OpcodeEncoder AppendInteger(Operand operand, InstructionSize size)
public OpcodeEncoder AppendConditionalIntegerOfSize(bool include, Operand operand, InstructionSize size)
{
if (!include)
return this;

if (size == InstructionSize.Size32)
return AppendIntegerValue(operand.ConstantUnsignedInteger);
if (size == InstructionSize.Size8)
Expand Down

0 comments on commit 8ce3a5f

Please sign in to comment.