diff --git a/source/Cosmos.Core.Plugs/Assemblers/UpdateIDT.cs b/source/Cosmos.Core.Plugs/Assemblers/UpdateIDT.cs index 2ca8d9692..b345d6d29 100644 --- a/source/Cosmos.Core.Plugs/Assemblers/UpdateIDT.cs +++ b/source/Cosmos.Core.Plugs/Assemblers/UpdateIDT.cs @@ -108,7 +108,7 @@ namespace Cosmos.Core.Plugs var xInterruptsWithParam = new int[] { 8, 10, 11, 12, 13, 14 }; for (int j = 0; j < 256; j++) { - new CPUAll.Label("__ISR_Handler_" + j.ToString("X2")); + XS.Label("__ISR_Handler_" + j.ToString("X2")); XS.Call("__INTERRUPT_OCCURRED__"); if (Array.IndexOf(xInterruptsWithParam, j) == -1) @@ -129,11 +129,9 @@ namespace Cosmos.Core.Plugs XS.Push(XSRegisters.OldToNewRegister(CPUx86.RegistersEnum.EAX)); // XS.Push(XSRegisters.OldToNewRegister(CPUx86.RegistersEnum.EAX)); // pass old stack address (pointer to InterruptContext struct) to the interrupt handler - //new CPUx86.Move("eax", - // "esp"); - //new CPUx86.Push("eax"); - new CPUx86.JumpToSegment { Segment = 8, DestinationLabel = "__ISR_Handler_" + j.ToString("X2") + "_SetCS" }; - new CPUAll.Label("__ISR_Handler_" + j.ToString("X2") + "_SetCS"); + + XS.JumpToSegment(8, "__ISR_Handler_" + j.ToString("X2") + "_SetCS"); + XS.Label("__ISR_Handler_" + j.ToString("X2") + "_SetCS"); MethodBase xHandler = GetInterruptHandler((byte)j); if (xHandler == null) { @@ -152,9 +150,9 @@ namespace Cosmos.Core.Plugs new CPUAll.Label("__ISR_Handler_" + j.ToString("X2") + "_END"); XS.InterruptReturn(); } - new CPUAll.Label("__INTERRUPT_OCCURRED__"); + XS.Label("__INTERRUPT_OCCURRED__"); XS.Return(); - new CPUAll.Label("__AFTER__ALL__ISR__HANDLER__STUBS__"); + XS.Label("__AFTER__ALL__ISR__HANDLER__STUBS__"); XS.Noop(); XS.Set(XSRegisters.OldToNewRegister(CPUx86.RegistersEnum.EAX), XSRegisters.OldToNewRegister(CPUx86.RegistersEnum.EBP), sourceDisplacement: 8); XS.Compare(XSRegisters.OldToNewRegister(CPUx86.RegistersEnum.EAX), 0); @@ -167,7 +165,7 @@ namespace Cosmos.Core.Plugs // Reenable interrupts XS.EnableInterrupts(); - new CPUAll.Label(".__AFTER_ENABLE_INTERRUPTS"); + XS.Label(".__AFTER_ENABLE_INTERRUPTS"); } } } diff --git a/source/Cosmos.Core.Plugs/CPUImpl.cs b/source/Cosmos.Core.Plugs/CPUImpl.cs index 253f2526f..dd7934bad 100644 --- a/source/Cosmos.Core.Plugs/CPUImpl.cs +++ b/source/Cosmos.Core.Plugs/CPUImpl.cs @@ -49,11 +49,11 @@ namespace Cosmos.Core.Plugs { XS.ShiftRight(XSRegisters.OldToNewRegister(CPUx86.RegistersEnum.ECX), 1); XS.Jump(CPUx86.ConditionalTestEnum.NotBelow, ".step2"); XS.StoreByteInString(); - new CPUAll.Label(".step2"); + XS.Label(".step2"); XS.ShiftRight(XSRegisters.OldToNewRegister(CPUx86.RegistersEnum.ECX), 1); XS.Jump(CPUx86.ConditionalTestEnum.NotBelow, ".step3"); XS.StoreWordInString(); - new CPUAll.Label(".step3"); + XS.Label(".step3"); new CPUx86.Stos { Size = 32, Prefixes = CPUx86.InstructionPrefixes.Repeat }; } } diff --git a/source/Cosmos.Core.Plugs/System/Assemblers/InvokeImplAssembler.cs b/source/Cosmos.Core.Plugs/System/Assemblers/InvokeImplAssembler.cs index 36095bf0d..eff435f33 100644 --- a/source/Cosmos.Core.Plugs/System/Assemblers/InvokeImplAssembler.cs +++ b/source/Cosmos.Core.Plugs/System/Assemblers/InvokeImplAssembler.cs @@ -36,7 +36,7 @@ namespace Cosmos.Core.Plugs.System.Assemblers */ XS.ClearInterruptFlag(); XS.Label(".DEBUG"); - //new CPU.Label("____DEBUG_FOR_MULTICAST___"); + //XS.Label("____DEBUG_FOR_MULTICAST___"); XS.Comment("move address of delegate to eax"); XS.Set(XSRegisters.OldToNewRegister(CPUx86.RegistersEnum.EAX), XSRegisters.OldToNewRegister(CPUx86.RegistersEnum.EBP), sourceDisplacement: Ldarg.GetArgumentDisplacement(xMethodInfo, 0)); @@ -130,7 +130,7 @@ namespace Cosmos.Core.Plugs.System.Assemblers XS.Exchange(XSRegisters.EBP, XSRegisters.EDX, destinationIsIndirect: true); XS.Push(XSRegisters.OldToNewRegister(CPUx86.RegistersEnum.EDX));//ebp XS.Set(XSRegisters.ESP, XSRegisters.EDI, destinationDisplacement: 12); - new Assembler.Label(".noReturn"); + XS.Label(".noReturn"); XS.EnableInterrupts(); } @@ -167,7 +167,7 @@ namespace Cosmos.Core.Plugs.System.Assemblers // * EBX contains the number of items in the array // * ECX contains the argument size // */ - // //new CPU.Label("____DEBUG_FOR_MULTICAST___"); + // //XS.Label("____DEBUG_FOR_MULTICAST___"); // // new CPUx86.Cli();//DEBUG ONLY // new CPU.Comment("push address of delgate to stack"); // Ldarg.DoExecute(xAssembler, xMethodInfo, 0); @@ -195,13 +195,13 @@ namespace Cosmos.Core.Plugs.System.Assemblers // new CPU.Comment("ecx points to the size of the delegated methods arguments"); // XS.Xor(XSRegisters.EDX, XSRegisters.CPUx86.Registers.EDX); // ;//make sure edx is 0 - // new CPU.Label(".BEGIN_OF_LOOP"); + // XS.Label(".BEGIN_OF_LOOP"); // XS.Compare(XSRegisters.EDX, XSRegisters.CPUx86.Registers.EBX);//are we at the end of this list // XS.Jump(ConditionalTestEnum.Equal, ".END_OF_INVOKE_");//then we better stop // //new CPUx86.Compare("edx", 0); // //new CPUx86.JumpIfLessOrEqual(".noreturnYet"); // //new CPUx86.Add("esp", 4); - // //new CPU.Label(".noreturnYet"); + // //XS.Label(".noreturnYet"); // //new CPU.Comment("space for the return value"); // //new CPUx86.Pushd("0"); // XS.Pushad(); @@ -217,7 +217,7 @@ namespace Cosmos.Core.Plugs.System.Assemblers // XS.Jump(ConditionalTestEnum.Zero, ".NO_THIS"); // XS.Push(XSRegisters.EDI); - // new CPU.Label(".NO_THIS"); + // XS.Label(".NO_THIS"); // new CPU.Comment("make space for us to copy the arguments too"); // XS.Sub(XSRegisters.ESP, XSRegisters.CPUx86.Registers.EBX); @@ -245,7 +245,7 @@ namespace Cosmos.Core.Plugs.System.Assemblers // //new CPUx86.JumpIfEqual(".getReturn"); // //new CPUx86.Move(Registers_Old.EAX, "[esp]"); // //new CPUx86.Move("[esp+0x20]", Registers_Old.EAX); - // //new CPU.Label(".getReturn"); + // //XS.Label(".getReturn"); // Ldarg.DoExecute(xAssembler, xMethodInfo, 0); // Ldfld.DoExecute(xAssembler, xMethodInfo.MethodBase.DeclaringType, "System.Object System.Delegate._target"); // // edi contains $this now @@ -262,15 +262,15 @@ namespace Cosmos.Core.Plugs.System.Assemblers // //new CPUx86.Move("ecx", "[ecx + " + (MethodInfo.Arguments[0].TypeInfo.Fields["$$ArgSize$$"].Offset + 12) + "]");//the size of the arguments to the method? + 12??? -- 12 is the size of the current call stack.. i think // //new CPUx86.Compare("ecx", "0"); // //new CPUx86.JumpIfLessOrEqual(".noTHIStoPop"); - // //new CPU.Label(".needToPopThis"); + // //XS.Label(".needToPopThis"); // //new CPUx86.Pop("edi"); // //new CPUx86.Move("[esp]", "edi"); - // new CPU.Label(".noTHIStoPop"); + // XS.Label(".noTHIStoPop"); // XS.Popad(); // XS.INC(XSRegisters.EDX); // XS.Add(XSRegisters.EAX, 4); // XS.Jump(".BEGIN_OF_LOOP"); - // new CPU.Label(".END_OF_INVOKE_"); + // XS.Label(".END_OF_INVOKE_"); // new CPU.Comment("get the return value"); // // TEMP!!! // // XS.Add(XSRegisters.ESP, 4); @@ -288,7 +288,7 @@ namespace Cosmos.Core.Plugs.System.Assemblers // //XS.Xchg(XSRegisters.EBP, XSRegisters.EDX, destinationIsIndirect: true); // //XS.Push(XSRegisters.EDX);//ebp // //XS.Mov(XSRegisters.ESP, XSRegisters.EDI, destinationDisplacement: 12); - // new CPU.Label(".noReturn"); + // XS.Label(".noReturn"); // // XS.Sti(); // //#warning remove this ^ sti call when issue is fixed!!! // //MethodInfo.Arguments[0]. diff --git a/source/Cosmos.Debug.GDB/BreakpointUC.Designer.cs b/source/Cosmos.Debug.GDB/BreakpointUC.Designer.cs index 2fa381afe..2f104d873 100644 --- a/source/Cosmos.Debug.GDB/BreakpointUC.Designer.cs +++ b/source/Cosmos.Debug.GDB/BreakpointUC.Designer.cs @@ -1,4 +1,4 @@ -namespace Cosmos.Debug.GDB { +namespace Cosmos.Debug.GDB { partial class BreakpointUC { /// /// Required designer variable. @@ -23,10 +23,10 @@ /// the contents of this method with the code editor. /// private void InitializeComponent() { - this.lablNum = new System.Windows.Forms.Label(); + this.lablNum = XS.Label(); this.cboxEnabled = new System.Windows.Forms.CheckBox(); - this.lablName = new System.Windows.Forms.Label(); - this.lablDelete = new System.Windows.Forms.Label(); + this.lablName = XS.Label(); + this.lablDelete = XS.Label(); this.SuspendLayout(); // // lablNum diff --git a/source/Cosmos.Debug.GDB/FormLog.Designer.cs b/source/Cosmos.Debug.GDB/FormLog.Designer.cs index 25fabeb9a..bc5259819 100644 --- a/source/Cosmos.Debug.GDB/FormLog.Designer.cs +++ b/source/Cosmos.Debug.GDB/FormLog.Designer.cs @@ -1,4 +1,4 @@ -namespace Cosmos.Debug.GDB { +namespace Cosmos.Debug.GDB { partial class FormLog { /// /// Required designer variable. @@ -30,7 +30,7 @@ this.panel2 = new System.Windows.Forms.Panel(); this.butnSendCmd = new System.Windows.Forms.Button(); this.textSendCmd = new System.Windows.Forms.TextBox(); - this.label1 = new System.Windows.Forms.Label(); + this.label1 = XS.Label(); this.panel1 = new System.Windows.Forms.Panel(); this.lboxDebug = new System.Windows.Forms.ListBox(); this.lboxCmd = new System.Windows.Forms.ListBox(); diff --git a/source/Cosmos.Debug.GDB/FormMain.Designer.cs b/source/Cosmos.Debug.GDB/FormMain.Designer.cs index 7993faf46..2817f0161 100644 --- a/source/Cosmos.Debug.GDB/FormMain.Designer.cs +++ b/source/Cosmos.Debug.GDB/FormMain.Designer.cs @@ -1,4 +1,4 @@ -namespace Cosmos.Debug.GDB { +namespace Cosmos.Debug.GDB { partial class FormMain { /// /// Required designer variable. @@ -27,8 +27,8 @@ this.panel1 = new System.Windows.Forms.Panel(); this.butnBreak = new System.Windows.Forms.Button(); this.butnBreakpoints = new System.Windows.Forms.Button(); - this.lablRunning = new System.Windows.Forms.Label(); - this.lablConnected = new System.Windows.Forms.Label(); + this.lablRunning = XS.Label(); + this.lablConnected = XS.Label(); this.butnContinue = new System.Windows.Forms.Button(); this.butnConnect = new System.Windows.Forms.Button(); this.menuMain = new System.Windows.Forms.MenuStrip(); @@ -54,7 +54,7 @@ this.mitmWindowsToForeground = new System.Windows.Forms.ToolStripMenuItem(); this.panel4 = new System.Windows.Forms.Panel(); this.textCurrentFunction = new System.Windows.Forms.TextBox(); - this.label5 = new System.Windows.Forms.Label(); + this.label5 = XS.Label(); this.lboxDisassemble = new Cosmos.Debug.GDB.ToolTipListBox(); this.menuDisassembly = new System.Windows.Forms.ContextMenuStrip(this.components); this.mitemDisassemblyAddBreakpoint = new System.Windows.Forms.ToolStripMenuItem(); diff --git a/source/Cosmos.Debug.GDB/FormRegisters.Designer.cs b/source/Cosmos.Debug.GDB/FormRegisters.Designer.cs index b4adcb0e0..8370027c5 100644 --- a/source/Cosmos.Debug.GDB/FormRegisters.Designer.cs +++ b/source/Cosmos.Debug.GDB/FormRegisters.Designer.cs @@ -1,4 +1,4 @@ -namespace Cosmos.Debug.GDB { +namespace Cosmos.Debug.GDB { partial class FormRegisters { /// /// Required designer variable. @@ -24,65 +24,65 @@ /// private void InitializeComponent() { this.panel5 = new System.Windows.Forms.Panel(); - this.label2 = new System.Windows.Forms.Label(); - this.lablFlagsText = new System.Windows.Forms.Label(); - this.label3 = new System.Windows.Forms.Label(); - this.lablFlags = new System.Windows.Forms.Label(); - this.label4 = new System.Windows.Forms.Label(); - this.label11 = new System.Windows.Forms.Label(); - this.lablALText = new System.Windows.Forms.Label(); - this.lablGS = new System.Windows.Forms.Label(); - this.lablEAX = new System.Windows.Forms.Label(); - this.label32 = new System.Windows.Forms.Label(); - this.lablAX = new System.Windows.Forms.Label(); - this.lablFS = new System.Windows.Forms.Label(); - this.lablAH = new System.Windows.Forms.Label(); - this.label29 = new System.Windows.Forms.Label(); - this.lablEBXLabel = new System.Windows.Forms.Label(); - this.lablES = new System.Windows.Forms.Label(); - this.lablBXLabel = new System.Windows.Forms.Label(); - this.label17 = new System.Windows.Forms.Label(); - this.label8 = new System.Windows.Forms.Label(); - this.lablDS = new System.Windows.Forms.Label(); - this.lablEBX = new System.Windows.Forms.Label(); - this.label19 = new System.Windows.Forms.Label(); - this.lablBX = new System.Windows.Forms.Label(); - this.lablCS = new System.Windows.Forms.Label(); - this.lablBH = new System.Windows.Forms.Label(); - this.label22 = new System.Windows.Forms.Label(); - this.lablECXLabel = new System.Windows.Forms.Label(); - this.lablSS = new System.Windows.Forms.Label(); - this.lablCXLabel = new System.Windows.Forms.Label(); - this.label25 = new System.Windows.Forms.Label(); - this.label14 = new System.Windows.Forms.Label(); - this.lablEDI = new System.Windows.Forms.Label(); - this.lablECX = new System.Windows.Forms.Label(); - this.label7 = new System.Windows.Forms.Label(); - this.lablCX = new System.Windows.Forms.Label(); - this.lablESI = new System.Windows.Forms.Label(); - this.lablCH = new System.Windows.Forms.Label(); - this.label10 = new System.Windows.Forms.Label(); - this.lablEDXLabel = new System.Windows.Forms.Label(); - this.lablEBP = new System.Windows.Forms.Label(); - this.lablDXLabel = new System.Windows.Forms.Label(); - this.label12 = new System.Windows.Forms.Label(); - this.label20 = new System.Windows.Forms.Label(); - this.lablESP = new System.Windows.Forms.Label(); - this.lablEDX = new System.Windows.Forms.Label(); - this.label15 = new System.Windows.Forms.Label(); - this.lablDX = new System.Windows.Forms.Label(); - this.lablEIPText = new System.Windows.Forms.Label(); - this.lablDH = new System.Windows.Forms.Label(); - this.lablEIP = new System.Windows.Forms.Label(); - this.label30 = new System.Windows.Forms.Label(); - this.label6 = new System.Windows.Forms.Label(); - this.lablAL = new System.Windows.Forms.Label(); - this.lablDL = new System.Windows.Forms.Label(); - this.label28 = new System.Windows.Forms.Label(); - this.label24 = new System.Windows.Forms.Label(); - this.lablBL = new System.Windows.Forms.Label(); - this.lablCL = new System.Windows.Forms.Label(); - this.label26 = new System.Windows.Forms.Label(); + this.label2 = XS.Label(); + this.lablFlagsText = XS.Label(); + this.label3 = XS.Label(); + this.lablFlags = XS.Label(); + this.label4 = XS.Label(); + this.label11 = XS.Label(); + this.lablALText = XS.Label(); + this.lablGS = XS.Label(); + this.lablEAX = XS.Label(); + this.label32 = XS.Label(); + this.lablAX = XS.Label(); + this.lablFS = XS.Label(); + this.lablAH = XS.Label(); + this.label29 = XS.Label(); + this.lablEBXLabel = XS.Label(); + this.lablES = XS.Label(); + this.lablBXLabel = XS.Label(); + this.label17 = XS.Label(); + this.label8 = XS.Label(); + this.lablDS = XS.Label(); + this.lablEBX = XS.Label(); + this.label19 = XS.Label(); + this.lablBX = XS.Label(); + this.lablCS = XS.Label(); + this.lablBH = XS.Label(); + this.label22 = XS.Label(); + this.lablECXLabel = XS.Label(); + this.lablSS = XS.Label(); + this.lablCXLabel = XS.Label(); + this.label25 = XS.Label(); + this.label14 = XS.Label(); + this.lablEDI = XS.Label(); + this.lablECX = XS.Label(); + this.label7 = XS.Label(); + this.lablCX = XS.Label(); + this.lablESI = XS.Label(); + this.lablCH = XS.Label(); + this.label10 = XS.Label(); + this.lablEDXLabel = XS.Label(); + this.lablEBP = XS.Label(); + this.lablDXLabel = XS.Label(); + this.label12 = XS.Label(); + this.label20 = XS.Label(); + this.lablESP = XS.Label(); + this.lablEDX = XS.Label(); + this.label15 = XS.Label(); + this.lablDX = XS.Label(); + this.lablEIPText = XS.Label(); + this.lablDH = XS.Label(); + this.lablEIP = XS.Label(); + this.label30 = XS.Label(); + this.label6 = XS.Label(); + this.lablAL = XS.Label(); + this.lablDL = XS.Label(); + this.label28 = XS.Label(); + this.label24 = XS.Label(); + this.lablBL = XS.Label(); + this.lablCL = XS.Label(); + this.label26 = XS.Label(); this.panel5.SuspendLayout(); this.SuspendLayout(); // diff --git a/source/Cosmos.Debug.GDB/WatchUC.Designer.cs b/source/Cosmos.Debug.GDB/WatchUC.Designer.cs index 7dc805114..12fe3ce67 100644 --- a/source/Cosmos.Debug.GDB/WatchUC.Designer.cs +++ b/source/Cosmos.Debug.GDB/WatchUC.Designer.cs @@ -1,4 +1,4 @@ -namespace Cosmos.Debug.GDB { +namespace Cosmos.Debug.GDB { partial class WatchUC { /// /// Required designer variable. @@ -23,10 +23,10 @@ /// the contents of this method with the code editor. /// private void InitializeComponent() { - this.lablAddress = new System.Windows.Forms.Label(); + this.lablAddress = XS.Label(); this.cboxEnabled = new System.Windows.Forms.CheckBox(); this.lablValue = new System.Windows.Forms.TextBox(); - this.lablDelete = new System.Windows.Forms.Label(); + this.lablDelete = XS.Label(); this.SuspendLayout(); // // lablAddress diff --git a/source/Cosmos.IL2CPU/AppAssembler.cs b/source/Cosmos.IL2CPU/AppAssembler.cs index 00a8d8195..7a08ae4f8 100644 --- a/source/Cosmos.IL2CPU/AppAssembler.cs +++ b/source/Cosmos.IL2CPU/AppAssembler.cs @@ -1508,7 +1508,7 @@ namespace Cosmos.IL2CPU new Mov { DestinationRef = ElementReference.New("DebugStub_CallerEIP"), DestinationIsIndirect = true, SourceReg = RegistersEnum.EAX }; XS.Call("DebugStub_SendStackCorruptionOccurred"); XS.Halt(); - new Assembler.Label(xLabel + ".StackCorruptionCheck_End"); + XS.Label(xLabel + ".StackCorruptionCheck_End"); } } diff --git a/source/Cosmos.IL2CPU/ILOp.cs b/source/Cosmos.IL2CPU/ILOp.cs index eca7ff987..ce5491466 100644 --- a/source/Cosmos.IL2CPU/ILOp.cs +++ b/source/Cosmos.IL2CPU/ILOp.cs @@ -434,7 +434,7 @@ namespace Cosmos.IL2CPU { XS.ClearInterruptFlag(); // don't remove the call. It seems pointless, but we need it to retrieve the EIP value XS.Call(".NullCheck_GetCurrAddress"); - new Assembler.Label(".NullCheck_GetCurrAddress"); + XS.Label(".NullCheck_GetCurrAddress"); XS.Pop(XSRegisters.OldToNewRegister(CPU.RegistersEnum.EAX)); new CPU.Mov {DestinationRef = ElementReference.New("DebugStub_CallerEIP"), DestinationIsIndirect = true, SourceReg = CPU.RegistersEnum.EAX}; XS.Call("DebugStub_SendNullReferenceOccurred"); diff --git a/source/XSharp.Compiler/XS.cs b/source/XSharp.Compiler/XS.cs index eeece0e5f..ea361151e 100644 --- a/source/XSharp.Compiler/XS.cs +++ b/source/XSharp.Compiler/XS.cs @@ -1214,5 +1214,14 @@ namespace XSharp.Compiler ArgumentReg = argumentReg }; } + + public static void JumpToSegment(ushort segment, string targetLabel) + { + new JumpToSegment + { + Segment = segment, + DestinationLabel = targetLabel + }; + } } }