- Tried to port

This commit is contained in:
gero_cp 2009-08-24 12:12:34 +00:00
parent 191cf1ee2d
commit 3c81f68c66

View file

@ -1,16 +1,52 @@
using System; using System;
using CPUx86 = Indy.IL2CPU.Assembler.X86;
namespace Cosmos.IL2CPU.X86.IL namespace Cosmos.IL2CPU.X86.IL
{ {
[Cosmos.IL2CPU.OpCode(ILOpCode.Code.Ldobj)] [Cosmos.IL2CPU.OpCode( ILOpCode.Code.Ldobj )]
public class Ldobj: ILOp public class Ldobj : ILOp
{ {
public Ldobj(Cosmos.IL2CPU.Assembler aAsmblr):base(aAsmblr) public Ldobj( Cosmos.IL2CPU.Assembler aAsmblr )
: base( aAsmblr )
{ {
} }
public override void Execute(MethodInfo aMethod, ILOpCode aOpCode) { public override void Execute( MethodInfo aMethod, ILOpCode aOpCode )
//TODO: Implement this Op {
throw new NotImplementedException();
StackContent xSize = Assembler.StackContents.Pop();
new CPUx86.Pop { DestinationReg = CPUx86.Registers.EAX };
for( int i = 1; i <= ( xSize.Size / 4 ); i++ )
{
new CPUx86.Push { DestinationReg = CPUx86.Registers.EAX, DestinationIsIndirect = true, DestinationDisplacement = ( int )( xSize.Size - ( i * 4 ) ) };
}
switch( xSize.Size % 4 )
{
case 1:
{
new CPUx86.Xor { DestinationReg = CPUx86.Registers.EBX, SourceReg = CPUx86.Registers.EBX };
new CPUx86.Move { DestinationReg = CPUx86.Registers.BL, SourceIsIndirect = true, SourceReg = CPUx86.Registers.EAX };
new CPUx86.Push { DestinationReg = CPUx86.Registers.EBX };
break;
}
case 2:
{
new CPUx86.Xor { DestinationReg = CPUx86.Registers.EBX, SourceReg = CPUx86.Registers.EBX };
new CPUx86.Move { DestinationReg = CPUx86.Registers.BX, SourceIsIndirect = true, SourceReg = CPUx86.Registers.EAX };
new CPUx86.Push { DestinationReg = CPUx86.Registers.EBX };
break;
}
case 0:
{
break;
}
default:
throw new Exception( "Remainder not supported!" );
}
//Assembler.StackContents.Pop();
//TODO: Push type not number
//Assembler.StackContents.Push( new StackContent( ( int )xSize.Size, true, false, false ) );
} }