diff --git a/source/Cosmos.Kernel/ConsoleDrv.cs b/source/Cosmos.Kernel/ConsoleDrv.cs
index 0078b9910..44eb66531 100644
--- a/source/Cosmos.Kernel/ConsoleDrv.cs
+++ b/source/Cosmos.Kernel/ConsoleDrv.cs
@@ -6,8 +6,8 @@ namespace Cosmos.Kernel {
public static void Main() {
Console.WriteLine("This is Indy OS...");
//int xDivider = 0;
- Console.WriteLine("Try Interrupts now");
- System.Diagnostics.Debugger.Break();
+ Console.WriteLine("Done");
+ Console.WriteLine("Testing IDT");
TestIDT();
}
diff --git a/source/IL2CPU.Tests/Tests/SimpleStructSumming/SimpleStructSumming.cs b/source/IL2CPU.Tests/Tests/SimpleStructSumming/SimpleStructSumming.cs
index 311970e48..e99f09570 100644
--- a/source/IL2CPU.Tests/Tests/SimpleStructSumming/SimpleStructSumming.cs
+++ b/source/IL2CPU.Tests/Tests/SimpleStructSumming/SimpleStructSumming.cs
@@ -14,7 +14,6 @@ class ConsoleDrv
public static int Main()
{
mTypes = new VTable[1];
- mTypes[0] = new VTable();
mTypes[0].MethodIndexes = new int[2];
mTypes[0].MethodAddresses = new int[2];
mTypes[0].MethodIndexes[0] = 14;
diff --git a/source/Indy.IL2CPU.Assembler.NativeX86/Assembler.cs b/source/Indy.IL2CPU.Assembler.NativeX86/Assembler.cs
index 66e109e9a..f65a7ee34 100644
--- a/source/Indy.IL2CPU.Assembler.NativeX86/Assembler.cs
+++ b/source/Indy.IL2CPU.Assembler.NativeX86/Assembler.cs
@@ -32,7 +32,7 @@ namespace Indy.IL2CPU.Assembler.NativeX86 {
mOutputWriter.WriteLine("mb_info multiboot_info ; just a dummy ");
mOutputWriter.WriteLine("");
mOutputWriter.WriteLine("");
- mOutputWriter.WriteLine("rb 32768 ; our own stack ");
+ mOutputWriter.WriteLine("rb 50000 ; our own stack ");
mOutputWriter.WriteLine("Kernel_Stack: ");
mOutputWriter.WriteLine("");
mOutputWriter.WriteLine("");
diff --git a/source/Indy.IL2CPU.IL.NativeX86/DebugHelper.cs b/source/Indy.IL2CPU.IL.NativeX86/DebugHelper.cs
new file mode 100644
index 000000000..7f97856be
--- /dev/null
+++ b/source/Indy.IL2CPU.IL.NativeX86/DebugHelper.cs
@@ -0,0 +1,19 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+
+namespace Indy.IL2CPU.IL.NativeX86 {
+ public static class DebugHelper {
+ private static bool mWritingPossible = false;
+ public static void DoWriteIfPossible(string aMessage) {
+ if (mWritingPossible) {
+ System.Diagnostics.Debug.WriteLine(aMessage);
+ }
+ }
+
+ public static void MakeWritingPossible() {
+ //mWritingPossible = true;
+ }
+ }
+}
diff --git a/source/Indy.IL2CPU.IL.NativeX86/Indy.IL2CPU.IL.NativeX86.csproj b/source/Indy.IL2CPU.IL.NativeX86/Indy.IL2CPU.IL.NativeX86.csproj
index 3336fd235..c615cd409 100644
--- a/source/Indy.IL2CPU.IL.NativeX86/Indy.IL2CPU.IL.NativeX86.csproj
+++ b/source/Indy.IL2CPU.IL.NativeX86/Indy.IL2CPU.IL.NativeX86.csproj
@@ -40,6 +40,7 @@
False
..\Mono.Cecil.dll
+
3.5
@@ -55,6 +56,7 @@
+
diff --git a/source/Indy.IL2CPU.IL.NativeX86/NativeX86MethodFooterOp.cs b/source/Indy.IL2CPU.IL.NativeX86/NativeX86MethodFooterOp.cs
index b89f548f3..565f72620 100644
--- a/source/Indy.IL2CPU.IL.NativeX86/NativeX86MethodFooterOp.cs
+++ b/source/Indy.IL2CPU.IL.NativeX86/NativeX86MethodFooterOp.cs
@@ -1,4 +1,4 @@
-/*using System;
+using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
@@ -9,32 +9,14 @@ using CPU = Indy.IL2CPU.Assembler.X86;
namespace Indy.IL2CPU.IL.NativeX86 {
public class NativeX86MethodFooterOp: X86MethodFooterOp {
- private bool mIsInterruptHandler = false;
+ private string mLabelName;
public NativeX86MethodFooterOp(Instruction aInstruction, MethodInformation aMethodInfo)
: base(aInstruction, aMethodInfo) {
- foreach (CustomAttribute xAttrib in aMethodInfo.MethodDefinition.CustomAttributes) {
- if(xAttrib.Constructor.DeclaringType.FullName == typeof(InterruptServiceRoutineAttribute).FullName) {
- mIsInterruptHandler = true;
- break;
- }
- }
+ mLabelName = aMethodInfo.LabelName;
}
public override void DoAssemble() {
- // MtW: after trial and a huge amount of errors, this line doesn't seem to be needed
- //Assembler.Add(new CPU.Add("esp", TotalLocalsSize.ToString()));
- AssembleFooter(HasReturnValue, Assembler, LocalsCount, TotalArgsSize);
- }
-
- public static void AssembleFooter(bool aHasReturnValue, Assembler.Assembler aAssembler, int aLocalsCount, int aTotalArgsSize) {
- if (aHasReturnValue) {
- aAssembler.Add(new Assembler.X86.Pop("eax"));
- }
- for (int i = 0; i < aLocalsCount; i++) {
- aAssembler.Add(new CPU.Add("esp", "4"));
- }
- aAssembler.Add(new CPU.Pop("ebp"));
- aAssembler.Add(new CPU.Ret(aTotalArgsSize == 0 ? "" : aTotalArgsSize.ToString()));
+ base.DoAssemble();
}
}
-}*/
\ No newline at end of file
+}
\ No newline at end of file
diff --git a/source/Indy.IL2CPU.IL.NativeX86/NativeX86OpCodeMap.cs b/source/Indy.IL2CPU.IL.NativeX86/NativeX86OpCodeMap.cs
index a3f82579d..f44ebfa85 100644
--- a/source/Indy.IL2CPU.IL.NativeX86/NativeX86OpCodeMap.cs
+++ b/source/Indy.IL2CPU.IL.NativeX86/NativeX86OpCodeMap.cs
@@ -15,6 +15,10 @@ namespace Indy.IL2CPU.IL.NativeX86 {
return typeof(NativeX86CustomMethodImplementationOp);
}
+ protected override Type GetMethodFooterOp() {
+ return typeof(NativeX86MethodFooterOp);
+ }
+
protected override Type GetMethodHeaderOp() {
return typeof(NativeX86MethodHeaderOp);
}
@@ -99,7 +103,8 @@ namespace Indy.IL2CPU.IL.NativeX86 {
return;
}
case "System_Void___Cosmos_Kernel_ConsoleDrv_TestIDT____": {
- //aAssembler.Add(new Literal("int 0x80"));
+ aAssembler.Add(new Literal("xchg bx, bx"));
+ aAssembler.Add(new Literal("int 3"));
break;
}
case "System_Void___Indy_IL2CPU_IL_NativeX86_RuntimeEngineImpl_IO_WriteToPort___System_UInt16__System_Byte__": {
@@ -173,8 +178,8 @@ namespace Indy.IL2CPU.IL.NativeX86 {
int[] xInterruptsWithParam = new int[] { 8, 10, 11, 12, 13, 14 };
for (int i = 0; i < 256; i++) {
aAssembler.Add(new CPU.Push("0x" + i.ToString("X")));
- if (i == 0) {
- //aAssembler.Add(new Literal("xchg bx, bx"));
+ if (i == 3) {
+ aAssembler.Add(new Literal("xchg bx, bx"));
}
aAssembler.Add(new CPU.Push("____INTERRUPT_HANDLER___" + i));
aAssembler.Add(new CPU.Push("0x08"));
diff --git a/source/Indy.IL2CPU.IL.NativeX86/RuntimeEngineImpl.cs b/source/Indy.IL2CPU.IL.NativeX86/RuntimeEngineImpl.cs
index 97813335e..e5875b121 100644
--- a/source/Indy.IL2CPU.IL.NativeX86/RuntimeEngineImpl.cs
+++ b/source/Indy.IL2CPU.IL.NativeX86/RuntimeEngineImpl.cs
@@ -7,18 +7,19 @@ using System.Text;
namespace Indy.IL2CPU.IL.NativeX86 {
public static partial class RuntimeEngineImpl {
public static void InitializeEngine() {
+ DebugHelper.MakeWritingPossible();
Console.Clear();
Debug.WriteLine("Slowing down PIT");
PIT_SetSlowest();
Debug.WriteLine("Loading IDT");
SetupInterruptDescriptorTable();
Debug.WriteLine("Loading PICs");
- //SetupProgrammableInterruptControllers();
- //Debug.WriteLine("Kernel Booted!");
+ SetupProgrammableInterruptControllers();
+ Debug.WriteLine("Kernel Booted");
}
public static void FinalizeEngine() {
-
+ Debug.WriteLine("Engine Shut down done.");
}
}
}
diff --git a/source/Indy.IL2CPU.IL.NativeX86/RuntimeEngineImpl/IDT.cs b/source/Indy.IL2CPU.IL.NativeX86/RuntimeEngineImpl/IDT.cs
index b9664663d..7735c4c0e 100644
--- a/source/Indy.IL2CPU.IL.NativeX86/RuntimeEngineImpl/IDT.cs
+++ b/source/Indy.IL2CPU.IL.NativeX86/RuntimeEngineImpl/IDT.cs
@@ -39,19 +39,20 @@ namespace Indy.IL2CPU.IL.NativeX86 {
private static void IDT_SetHandler(byte aInterruptNumber, uint aBase, ushort aSel, IDTEntryStruct.FlagsEnum aFlags) {
mIDTEntries[aInterruptNumber].AlwaysZero = 0;
mIDTEntries[aInterruptNumber].Sel = 8;
- mIDTEntries[aInterruptNumber].BaseLow = (ushort)(aBase & 0xFFFF);
- mIDTEntries[aInterruptNumber].BaseHi = (ushort)((aBase >> 16) & 0xFFFF);
+ mIDTEntries[aInterruptNumber].BaseLow = (ushort)(aBase);
+ mIDTEntries[aInterruptNumber].BaseHi = (ushort)(aBase >> 16);
mIDTEntries[aInterruptNumber].Flags = 128 /*Present*/| 0 /*Ring0*/| 8 /*32-bit*/| 0xF /*interrupt gate*/;
} // was E
private static void InterruptHandler(byte aInterrupt, uint aParam) {
- if(aInterrupt >= 40 && aInterrupt <= 47) {
+ Debug.WriteLine("Interrupt received");
+ System.Diagnostics.Debugger.Break();
+ if (aInterrupt >= 40 && aInterrupt <= 47) {
WriteToPort(0xA0, 0x20);
}
if (aInterrupt >= 32 && aInterrupt <= 47) {
WriteToPort(0x20, 0x20);
}
- //Debug.WriteLine("Interrupt received");
}
private static void SetupInterruptDescriptorTable() {
diff --git a/source/Indy.IL2CPU.IL.X86/Conv_U2.cs b/source/Indy.IL2CPU.IL.X86/Conv_U2.cs
index e79adb84e..863aa2135 100644
--- a/source/Indy.IL2CPU.IL.X86/Conv_U2.cs
+++ b/source/Indy.IL2CPU.IL.X86/Conv_U2.cs
@@ -11,7 +11,10 @@ namespace Indy.IL2CPU.IL.X86 {
: base(aInstruction, aMethodInfo) {
}
public override void DoAssemble() {
- // todo: implement correct truncating
+ Pop("ecx");
+ Move(Assembler, "eax", "0");
+ Move(Assembler, "ax", "cx");
+ Pushd("eax");
}
}
}
\ No newline at end of file
diff --git a/source/Indy.IL2CPU.IL.X86/LdStr.cs b/source/Indy.IL2CPU.IL.X86/LdStr.cs
index 4de820ad4..509b3e98a 100644
--- a/source/Indy.IL2CPU.IL.X86/LdStr.cs
+++ b/source/Indy.IL2CPU.IL.X86/LdStr.cs
@@ -14,14 +14,23 @@ namespace Indy.IL2CPU.IL.X86 {
LiteralStr = (string)aInstruction.Operand;
}
+ public LdStr(string aLiteralStr):base(null, null) {
+ LiteralStr = aLiteralStr;
+ }
+
public override void DoAssemble() {
if (Assembler.InMetalMode) {
- string xDataName = Assembler.GetIdentifier("StringLiteral");
var xDataByteArray = new StringBuilder();
xDataByteArray.Append(BitConverter.GetBytes(LiteralStr.Length).Aggregate("", (r, b) => r + b + ","));
xDataByteArray.Append(Encoding.ASCII.GetBytes(LiteralStr).Aggregate("", (r, b) => r + b + ","));
- //xDataByteArray.Append("0,");
- Assembler.DataMembers.Add(new DataMember(xDataName, "db", xDataByteArray.ToString().TrimEnd(',')));
+ string xDataVal = xDataByteArray.ToString().TrimEnd(',');
+ string xDataName = (from item in Assembler.DataMembers
+ where item.DefaultValue == xDataVal
+ select item.Name).FirstOrDefault();
+ if (String.IsNullOrEmpty(xDataName)) {
+ xDataName = Assembler.GetIdentifier("StringLiteral");
+ Assembler.DataMembers.Add(new DataMember(xDataName, "db", xDataVal));
+ }
Move(Assembler, "eax", xDataName);
Pushd("eax");
} else {
diff --git a/source/Indy.IL2CPU/Engine.cs b/source/Indy.IL2CPU/Engine.cs
index c5bcb5a87..a9824bbc1 100644
--- a/source/Indy.IL2CPU/Engine.cs
+++ b/source/Indy.IL2CPU/Engine.cs
@@ -633,6 +633,9 @@ namespace Indy.IL2CPU {
} else {
xTheSize = 4;
}
+ if(xTheSize<4) {
+ xTheSize = 4;
+ }
if (xTheSize == 4) {
theType = "dd";
xTheSize = 1;