mirror of
https://github.com/danbulant/Cosmos
synced 2026-05-30 12:50:19 +00:00
27 lines
No EOL
872 B
C#
27 lines
No EOL
872 B
C#
using System;
|
|
using CPUx86 = Cosmos.Assembler.x86;
|
|
|
|
namespace Cosmos.IL2CPU.X86.IL
|
|
{
|
|
[Cosmos.IL2CPU.OpCode(ILOpCode.Code.Dup)]
|
|
public class Dup : ILOp
|
|
{
|
|
public Dup(Cosmos.Assembler.Assembler aAsmblr)
|
|
: base(aAsmblr)
|
|
{
|
|
}
|
|
|
|
public override void Execute(MethodInfo aMethod, ILOpCode aOpCode)
|
|
{
|
|
var xStackContent = Assembler.Stack.Peek();
|
|
var StackSize = (int)((xStackContent.Size / 4) + (xStackContent.Size % 4 == 0 ? 0 : 1));
|
|
|
|
for (int i = StackSize; i > 0; i--)
|
|
{
|
|
new CPUx86.Push { DestinationReg = CPUx86.Registers.ESP, DestinationIsIndirect = true, DestinationDisplacement = (int)((StackSize - 1) * 4) };
|
|
}
|
|
Assembler.Stack.Push(xStackContent.Size, xStackContent.ContentType);
|
|
}
|
|
|
|
}
|
|
} |