Fixed Conv_I and stobj opcode handling..

This commit is contained in:
mterwoord_cp 2007-12-16 12:41:28 +00:00
parent 50a75f6f1d
commit 5147a015dc
3 changed files with 64 additions and 22 deletions

View file

@ -17,30 +17,34 @@ namespace Cosmos.Kernel.FileSystem {
int xBlockSize = (int)(1024 << (byte)(xSuperBlock.LogBlockSize)); int xBlockSize = (int)(1024 << (byte)(xSuperBlock.LogBlockSize));
int xGroupDescriptorPerBlock = xBlockSize / 32;// groupdescriptor size int xGroupDescriptorPerBlock = xBlockSize / 32;// groupdescriptor size
GroupDescriptor[] xGroupDescriptors = ReadGroupDescriptorsOfBlock(aController, aDrive, xSuperBlock.FirstDataBlock + 1, xSuperBlock, xBuffer); 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; return null;
} }
private static unsafe GroupDescriptor[] ReadGroupDescriptorsOfBlock(byte aController, byte aDrive, uint aBlock, SuperBlock aSuperBlock, ushort* aBuffer) { 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 xBlockSize = (int)(1024 << aSuperBlock.LogBlockSize);
int xGroupDescriptorPerBlock = xBlockSize / 32;// groupdescriptor size int xGroupDescriptorPerBlock = xBlockSize / 32;// groupdescriptor size
Hardware.Storage.ATA.ReadDataNew(aController, aDrive, aBlock, aBuffer); Hardware.Storage.ATA.ReadDataNew(aController, aDrive, aBlock, aBuffer);
if (!true/*Hardware.Storage.ATA.ReadDataNew(aController, aDrive, aBlock, aBuffer)*/) { if (!Hardware.Storage.ATA.ReadDataNew(aController, aDrive, aBlock, aBuffer)) {
Console.WriteLine("[Ext2|GroupDescriptors] Error while reading GroupDescriptor data"); Console.WriteLine("[Ext2|GroupDescriptors] Error while reading GroupDescriptor data");
return null; return null;
} else { } else {
Console.WriteLine("[Ext2|GroupDescriptors] Block read"); Console.WriteLine("[Ext2|GroupDescriptors] Block read");
} }
GroupDescriptor* xDescriptorPtr = (GroupDescriptor*)aBuffer; GroupDescriptor* xDescriptorPtr = (GroupDescriptor*)aBuffer;
//for (uint i = 0; i < 32; i++) { for (uint i = 0; i < 32; i++) {
uint i = 0; Console.Write("Start Iteration ");
Console.Write("Start Iteration "); Hardware.Storage.ATA.WriteNumber(i, 8);
Hardware.Storage.ATA.WriteNumber(i, 8); Console.WriteLine("");
Console.WriteLine(""); xResult[i] = xDescriptorPtr[i];
//xResult[i] = xDescriptorPtr[i]; Console.WriteLine("End Iteration");
Console.WriteLine("End Iteration"); }
////} return xResult;
return null;
} }
} }
} }

View file

@ -1,8 +1,6 @@
using System; using System;
using System.IO;
using Mono.Cecil;
using Mono.Cecil.Cil; using Mono.Cecil.Cil;
using CPU = Indy.IL2CPU.Assembler.X86; using CPUx86 = Indy.IL2CPU.Assembler.X86;
namespace Indy.IL2CPU.IL.X86 { namespace Indy.IL2CPU.IL.X86 {
[OpCode(Code.Conv_I)] [OpCode(Code.Conv_I)]
@ -11,7 +9,24 @@ namespace Indy.IL2CPU.IL.X86 {
: base(aInstruction, aMethodInfo) { : base(aInstruction, aMethodInfo) {
} }
public override void DoAssemble() { 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);
} }
} }
} }

View file

@ -9,11 +9,34 @@ namespace Indy.IL2CPU.IL.X86 {
: base(aInstruction, aMethodInfo) { : base(aInstruction, aMethodInfo) {
} }
public override void DoAssemble() { public override void DoAssemble() {
new CPUx86.Pop(CPUx86.Registers.EDX); //new CPUx86.Pop(CPUx86.Registers.EDX);
new CPUx86.Pop(CPUx86.Registers.EAX); //new CPUx86.Pop(CPUx86.Registers.EAX);
new CPUx86.Move(CPUx86.Registers.AtEAX, CPUx86.Registers.EDX); //new CPUx86.Move(CPUx86.Registers.AtEAX, CPUx86.Registers.EDX);
Assembler.StackSizes.Pop(); int xFieldSize = Assembler.StackSizes.Pop();
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!");
}
} }
} }
} }