Cosmos/source2/IL2PCU/Cosmos.IL2CPU.X86/IL/Dup.cs
kudzu_cp e6dffc1c69
2009-08-30 21:24:16 +00:00

26 lines
893 B
C#

using System;
using CPUx86 = Indy.IL2CPU.Assembler.X86;
namespace Cosmos.IL2CPU.X86.IL
{
[Cosmos.IL2CPU.OpCode( ILOpCode.Code.Dup )]
public class Dup : ILOp
{
public Dup( Cosmos.IL2CPU.Assembler aAsmblr )
: base( aAsmblr )
{
}
public override void Execute( MethodInfo aMethod, ILOpCode aOpCode )
{
var xStackContent = Assembler.Stack.Peek();
for( int i = 0; i < ( ( xStackContent.Size / 4 ) + ( xStackContent.Size % 4 == 0 ? 0 : 1 ) ); i++ )
{
new CPUx86.Move { DestinationReg = CPUx86.Registers.EAX, SourceReg = CPUx86.Registers.ESP, SourceDisplacement = i * 4, SourceIsIndirect = true };
new CPUx86.Push { DestinationReg = CPUx86.Registers.EAX };
}
Assembler.Stack.Push( xStackContent );
}
}
}