diff --git a/source/Cosmos/Cosmos.Kernel/FileSystem/Ext2.cs b/source/Cosmos/Cosmos.Kernel/FileSystem/Ext2.cs index edec14b48..0f289183b 100644 --- a/source/Cosmos/Cosmos.Kernel/FileSystem/Ext2.cs +++ b/source/Cosmos/Cosmos.Kernel/FileSystem/Ext2.cs @@ -17,30 +17,34 @@ namespace Cosmos.Kernel.FileSystem { int xBlockSize = (int)(1024 << (byte)(xSuperBlock.LogBlockSize)); int xGroupDescriptorPerBlock = xBlockSize / 32;// groupdescriptor size GroupDescriptor[] xGroupDescriptors = ReadGroupDescriptorsOfBlock(aController, aDrive, xSuperBlock.FirstDataBlock + 1, xSuperBlock, xBuffer); + if (xGroupDescriptors != null) { + Console.WriteLine("Successfully read GroupDescriptors"); + } else { + Console.WriteLine("Error while reading GroupDescriptors"); + } return null; } private static unsafe GroupDescriptor[] ReadGroupDescriptorsOfBlock(byte aController, byte aDrive, uint aBlock, SuperBlock aSuperBlock, ushort* aBuffer) { - //GroupDescriptor[] xResult = new GroupDescriptor[32]; + GroupDescriptor[] xResult = new GroupDescriptor[32]; int xBlockSize = (int)(1024 << aSuperBlock.LogBlockSize); int xGroupDescriptorPerBlock = xBlockSize / 32;// groupdescriptor size Hardware.Storage.ATA.ReadDataNew(aController, aDrive, aBlock, aBuffer); - if (!true/*Hardware.Storage.ATA.ReadDataNew(aController, aDrive, aBlock, aBuffer)*/) { - Console.WriteLine("[Ext2|GroupDescriptors] Error while reading GroupDescriptor data"); - return null; + if (!Hardware.Storage.ATA.ReadDataNew(aController, aDrive, aBlock, aBuffer)) { + Console.WriteLine("[Ext2|GroupDescriptors] Error while reading GroupDescriptor data"); + return null; } else { - Console.WriteLine("[Ext2|GroupDescriptors] Block read"); + Console.WriteLine("[Ext2|GroupDescriptors] Block read"); } GroupDescriptor* xDescriptorPtr = (GroupDescriptor*)aBuffer; - //for (uint i = 0; i < 32; i++) { - uint i = 0; - Console.Write("Start Iteration "); - Hardware.Storage.ATA.WriteNumber(i, 8); - Console.WriteLine(""); - //xResult[i] = xDescriptorPtr[i]; - Console.WriteLine("End Iteration"); - ////} - return null; + for (uint i = 0; i < 32; i++) { + Console.Write("Start Iteration "); + Hardware.Storage.ATA.WriteNumber(i, 8); + Console.WriteLine(""); + xResult[i] = xDescriptorPtr[i]; + Console.WriteLine("End Iteration"); + } + return xResult; } } } diff --git a/source/Indy.IL2CPU.IL.X86/Conv_I.cs b/source/Indy.IL2CPU.IL.X86/Conv_I.cs index f86f026a9..6a988eb42 100644 --- a/source/Indy.IL2CPU.IL.X86/Conv_I.cs +++ b/source/Indy.IL2CPU.IL.X86/Conv_I.cs @@ -1,8 +1,6 @@ using System; -using System.IO; -using Mono.Cecil; using Mono.Cecil.Cil; -using CPU = Indy.IL2CPU.Assembler.X86; +using CPUx86 = Indy.IL2CPU.Assembler.X86; namespace Indy.IL2CPU.IL.X86 { [OpCode(Code.Conv_I)] @@ -11,7 +9,24 @@ namespace Indy.IL2CPU.IL.X86 { : base(aInstruction, aMethodInfo) { } public override void DoAssemble() { - // todo: implement correct conversion + int xSource = Assembler.StackSizes.Pop(); + switch (xSource) { + case 1: + case 2: + case 4: { + break; + } + case 8: { + new CPUx86.Pop(CPUx86.Registers.EAX); + new CPUx86.Add("esp", "4"); + new CPUx86.Pushd(CPUx86.Registers.EAX); + break; + + } + default: + throw new Exception("SourceSize " + xSource + " not supported!"); + } + Assembler.StackSizes.Push(4); } } } \ No newline at end of file diff --git a/source/Indy.IL2CPU.IL.X86/Stobj.cs b/source/Indy.IL2CPU.IL.X86/Stobj.cs index b2d390ec2..11768170c 100644 --- a/source/Indy.IL2CPU.IL.X86/Stobj.cs +++ b/source/Indy.IL2CPU.IL.X86/Stobj.cs @@ -9,11 +9,34 @@ namespace Indy.IL2CPU.IL.X86 { : base(aInstruction, aMethodInfo) { } public override void DoAssemble() { - new CPUx86.Pop(CPUx86.Registers.EDX); - new CPUx86.Pop(CPUx86.Registers.EAX); - new CPUx86.Move(CPUx86.Registers.AtEAX, CPUx86.Registers.EDX); - Assembler.StackSizes.Pop(); + //new CPUx86.Pop(CPUx86.Registers.EDX); + //new CPUx86.Pop(CPUx86.Registers.EAX); + //new CPUx86.Move(CPUx86.Registers.AtEAX, CPUx86.Registers.EDX); + int xFieldSize = Assembler.StackSizes.Pop(); Assembler.StackSizes.Pop(); + new CPUx86.Pop("ecx"); + for (int i = 0; i < (xFieldSize / 4); i++) { + new CPUx86.Pop("eax"); + new CPUx86.Move("dword [ecx + 0x" + (xFieldSize - (i * 4)).ToString("X") + "]", "eax"); + } + switch (xFieldSize % 4) { + case 1: { + new CPUx86.Pop("eax"); + new CPUx86.Move("byte [ecx]", "al"); + break; + } + case 2: { + new CPUx86.Pop("eax"); + new CPUx86.Move("word [ecx]", "ax"); + break; + } + case 0: { + break; + } + default: + throw new Exception("Remainder size " + (xFieldSize % 4) + " not supported!"); + + } } } } \ No newline at end of file