From e1a1b54b675daf46a2b4f42e78a2aa415fcfbae3 Mon Sep 17 00:00:00 2001
From: mterwoord_cp <7cd3fd84a0151ea055c2f79e4d2eef9576fe9afesxUZAwxD>
Date: Mon, 3 Sep 2007 11:23:10 +0000
Subject: [PATCH] produces valid output now
---
source/Indy.IL2CPU.Assembler/Assembler.cs | 46 +++++++++++--------
.../Indy.IL2CPU.IL.X86.csproj.user | 5 --
.../Indy.IL2CPU.IL/Indy.IL2CPU.IL.csproj.user | 5 --
source/Indy.IL2CPU/Engine.cs | 2 +
4 files changed, 28 insertions(+), 30 deletions(-)
delete mode 100644 source/Indy.IL2CPU.IL.X86/Indy.IL2CPU.IL.X86.csproj.user
delete mode 100644 source/Indy.IL2CPU.IL/Indy.IL2CPU.IL.csproj.user
diff --git a/source/Indy.IL2CPU.Assembler/Assembler.cs b/source/Indy.IL2CPU.Assembler/Assembler.cs
index 3e9db1351..8dcc30f15 100644
--- a/source/Indy.IL2CPU.Assembler/Assembler.cs
+++ b/source/Indy.IL2CPU.Assembler/Assembler.cs
@@ -88,28 +88,34 @@ namespace Indy.IL2CPU.Assembler {
mOutputWriter.WriteLine("include '{0}'", xInclude);
}
mOutputWriter.WriteLine();
- mOutputWriter.WriteLine("section '.data' data readable writeable");
- mOutputWriter.WriteLine();
- foreach (DataMember xMember in mDataMembers) {
- mOutputWriter.WriteLine("\t" + xMember);
- }
- mOutputWriter.WriteLine();
- mOutputWriter.WriteLine("section '.code' code readable executable");
- mOutputWriter.WriteLine();
- mOutputWriter.WriteLine(" " + EntryPointLabelName + ":");
- foreach (Instruction x in mInstructions) {
- string prefix = "\t";
- if (x is Label) {
- mOutputWriter.WriteLine();
- prefix = " ";
+ if (mDataMembers.Count > 0) {
+ mOutputWriter.WriteLine("section '.data' data readable writeable");
+ mOutputWriter.WriteLine();
+ foreach (DataMember xMember in mDataMembers) {
+ mOutputWriter.WriteLine("\t" + xMember);
}
- mOutputWriter.WriteLine(prefix + x);
+ mOutputWriter.WriteLine();
}
- mOutputWriter.WriteLine();
- mOutputWriter.WriteLine("section '.idata' import data readable writeable");
- mOutputWriter.WriteLine();
- foreach (ImportMember xImportMember in mImportMembers) {
- mOutputWriter.WriteLine("\t" + xImportMember);
+ if (mInstructions.Count > 0) {
+ mOutputWriter.WriteLine("section '.code' code readable executable");
+ mOutputWriter.WriteLine();
+ mOutputWriter.WriteLine("\t" + EntryPointLabelName + ":");
+ foreach (Instruction x in mInstructions) {
+ string prefix = "\t\t";
+ if (x is Label) {
+ mOutputWriter.WriteLine();
+ prefix = " ";
+ }
+ mOutputWriter.WriteLine(prefix + x);
+ }
+ mOutputWriter.WriteLine();
+ }
+ if (mImportMembers.Count > 0) {
+ mOutputWriter.WriteLine("section '.idata' import data readable writeable");
+ mOutputWriter.WriteLine();
+ foreach (ImportMember xImportMember in mImportMembers) {
+ mOutputWriter.WriteLine("\t" + xImportMember);
+ }
}
}
diff --git a/source/Indy.IL2CPU.IL.X86/Indy.IL2CPU.IL.X86.csproj.user b/source/Indy.IL2CPU.IL.X86/Indy.IL2CPU.IL.X86.csproj.user
deleted file mode 100644
index b875c0c26..000000000
--- a/source/Indy.IL2CPU.IL.X86/Indy.IL2CPU.IL.X86.csproj.user
+++ /dev/null
@@ -1,5 +0,0 @@
-
-
- ProjectFiles
-
-
\ No newline at end of file
diff --git a/source/Indy.IL2CPU.IL/Indy.IL2CPU.IL.csproj.user b/source/Indy.IL2CPU.IL/Indy.IL2CPU.IL.csproj.user
deleted file mode 100644
index 5c2d6e6a7..000000000
--- a/source/Indy.IL2CPU.IL/Indy.IL2CPU.IL.csproj.user
+++ /dev/null
@@ -1,5 +0,0 @@
-
-
- ShowAllFiles
-
-
\ No newline at end of file
diff --git a/source/Indy.IL2CPU/Engine.cs b/source/Indy.IL2CPU/Engine.cs
index e3e12ad2a..611905a8a 100644
--- a/source/Indy.IL2CPU/Engine.cs
+++ b/source/Indy.IL2CPU/Engine.cs
@@ -80,6 +80,8 @@ namespace Indy.IL2CPU {
IL.Op.QueueMethod += QueueMethod;
try {
mMethods.Add(mCrawledAssembly.EntryPoint, false);
+ // first instructions are for calling the entrypoint
+ mAssembler.Add(new JumpAlways(new Label(mCrawledAssembly.EntryPoint).Name));
ProcessAllMethods();
} finally {
mAssembler.Flush();