-
Notifications
You must be signed in to change notification settings - Fork 71
/
Dup.cs
29 lines (24 loc) · 875 Bytes
/
Dup.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
using XSharp;
using static XSharp.XSRegisters;
namespace Cosmos.IL2CPU.X86.IL
{
[OpCode(ILOpCode.Code.Dup)]
public class Dup : ILOp
{
public Dup(XSharp.Assembler.Assembler aAsmblr)
: base(aAsmblr)
{
}
public override void Execute(Il2cpuMethodInfo aMethod, ILOpCode aOpCode)
{
var xStackContent = aOpCode.StackPopTypes[0];
var xStackContentSize = SizeOfType(xStackContent);
var StackSize = (int)(xStackContentSize / 4 + (xStackContentSize % 4 == 0 ? 0 : 1));
for (int i = StackSize; i > 0; i--)
{
XS.Push(ESP, true, (StackSize - 1) * 4);
//new CPUx86.Push { DestinationReg = CPUx86.RegistersEnum.ESP, DestinationIsIndirect = true, DestinationDisplacement = (int)((StackSize - 1) * 4) };
}
}
}
}