mirror of
https://github.com/danbulant/Cosmos
synced 2026-05-19 20:39:01 +00:00
Made Dup IL working for stack content size greater than 4
This commit is contained in:
parent
cc6d1951ce
commit
b4e746fcf8
1 changed files with 9 additions and 8 deletions
|
|
@ -3,24 +3,25 @@ using CPUx86 = Cosmos.Assembler.x86;
|
|||
|
||||
namespace Cosmos.IL2CPU.X86.IL
|
||||
{
|
||||
[Cosmos.IL2CPU.OpCode( ILOpCode.Code.Dup )]
|
||||
[Cosmos.IL2CPU.OpCode(ILOpCode.Code.Dup)]
|
||||
public class Dup : ILOp
|
||||
{
|
||||
public Dup( Cosmos.Assembler.Assembler aAsmblr )
|
||||
: base( aAsmblr )
|
||||
public Dup(Cosmos.Assembler.Assembler aAsmblr)
|
||||
: base(aAsmblr)
|
||||
{
|
||||
}
|
||||
|
||||
public override void Execute( MethodInfo aMethod, ILOpCode aOpCode )
|
||||
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++ )
|
||||
var StackSize = (int)((xStackContent.Size / 4) + (xStackContent.Size % 4 == 0 ? 0 : 1));
|
||||
|
||||
for (int i = StackSize; i > 0; i--)
|
||||
{
|
||||
new CPUx86.Mov { DestinationReg = CPUx86.Registers.EAX, SourceReg = CPUx86.Registers.ESP, SourceDisplacement = i * 4, SourceIsIndirect = true };
|
||||
new CPUx86.Push { DestinationReg = CPUx86.Registers.EAX };
|
||||
new CPUx86.Push { DestinationReg = CPUx86.Registers.ESP, DestinationIsIndirect = true, DestinationDisplacement = (int)((StackSize - 1) * 4) };
|
||||
}
|
||||
Assembler.Stack.Push(xStackContent.Size, xStackContent.ContentType);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
Loading…
Reference in a new issue