diff --git a/source2/Compiler/Cosmos.Compiler.Assembler/Assembler.cs b/source2/Compiler/Cosmos.Compiler.Assembler/Assembler.cs index 27f32c6e5..35ab51395 100644 --- a/source2/Compiler/Cosmos.Compiler.Assembler/Assembler.cs +++ b/source2/Compiler/Cosmos.Compiler.Assembler/Assembler.cs @@ -14,8 +14,8 @@ using System.Xml; namespace Cosmos.Compiler.Assembler { public abstract class Assembler { - public virtual void Initialize() { - } + public virtual void Initialize() { } + // Contains info on the current stack structure. What type are on the stack, etc public readonly StackContents Stack = new StackContents(); @@ -23,6 +23,8 @@ namespace Cosmos.Compiler.Assembler { // as it will also cause problems when we thread the compiler private static Assembler mCurrentInstance; + public bool EmitAsmLabels { get; set; } + protected int mCurrentMethodID; public int CurrentMethodID { get { return mCurrentMethodID; } @@ -45,7 +47,7 @@ namespace Cosmos.Compiler.Assembler { protected internal List mInstructions = new List(); private List mDataMembers = new List(); - + public List DataMembers { get { return mDataMembers; } } @@ -101,20 +103,22 @@ namespace Cosmos.Compiler.Assembler { return null; } - public void Add(Instruction aReader){ - if (aReader is Label || aReader is Comment) { - } else { - // Only issue label if its executable code. - // Also above if statement will prevent this new label - // from causing a stack overflow - new Label("." + AsmIlIdx.ToString("X2")); - mAsmIlIdx++; + public void Add(Instruction aReader) { + if (aReader is Label || aReader is Comment) { + } else { + if (EmitAsmLabels) { + // Only issue label if its executable code. + // Also above if statement will prevent this new label + // from causing a stack overflow + new Label("." + AsmIlIdx.ToString("X2")); + mAsmIlIdx++; + } + } + mInstructions.Add(aReader); } - mInstructions.Add(aReader); - } public void Add(params Instruction[] aReaders) { - mInstructions.Capacity += aReaders.Length; + mInstructions.Capacity += aReaders.Length; foreach (Instruction xInstruction in aReaders) { mInstructions.Add(xInstruction); } diff --git a/source2/Compiler/Cosmos.Compiler.XSharp/CodeGroup.cs b/source2/Compiler/Cosmos.Compiler.XSharp/CodeGroup.cs index df38e8524..3eeb1e4db 100644 --- a/source2/Compiler/Cosmos.Compiler.XSharp/CodeGroup.cs +++ b/source2/Compiler/Cosmos.Compiler.XSharp/CodeGroup.cs @@ -51,10 +51,7 @@ namespace Cosmos.Compiler.XSharp { SetDataMembers(xBlock); // Issue label for the routine - // TODO: Instead of issuing IL label, allow ASM option to turn - // off ASM labeling. - mAsm.CurrentIlLabel = CodeBlock.MakeLabel(xType); - xBlock.Label = mAsm.CurrentIlLabel; + xBlock.Label = CodeBlock.MakeLabel(xType); if (xPreserveStack) { xBlock.PushAll(); diff --git a/source2/IL2CPU/Cosmos.IL2CPU.X86/CosmosAssembler.cs b/source2/IL2CPU/Cosmos.IL2CPU.X86/CosmosAssembler.cs index cf109e998..f86f9f0eb 100644 --- a/source2/IL2CPU/Cosmos.IL2CPU.X86/CosmosAssembler.cs +++ b/source2/IL2CPU/Cosmos.IL2CPU.X86/CosmosAssembler.cs @@ -264,6 +264,8 @@ namespace Cosmos.IL2CPU.X86 { new Label("DebugStub_Step"); new Return(); } + // Start emitting assembly labels + Assembler.CurrentInstance.EmitAsmLabels = true; #if !LFB_1024_8 DataMembers.Add(new DataIfNotDefined("ELF_COMPILATION"));