From 12d1ae56147a7c0bc7fe4594a5ac8d64c3433ae6 Mon Sep 17 00:00:00 2001 From: Matthijs ter Woord Date: Wed, 15 Jun 2016 12:50:06 -0400 Subject: [PATCH] . --- Users/Orvid/OrvidTestOS/AsmMouse.cs | 65 ++++--------------- .../System/Assemblers/InvokeImplAssembler.cs | 24 +++---- source/Cosmos.IL2CPU/IL/Brfalse.cs | 6 +- source/Cosmos.IL2CPU/IL/Brtrue.cs | 6 +- source/Cosmos.IL2CPU/IL/Castclass.cs | 2 +- source/Cosmos.IL2CPU/IL/Cgt_Un.cs | 12 ++-- source/Cosmos.IL2CPU/IL/Conv_I.cs | 6 +- source/Cosmos.IL2CPU/IL/Conv_Ovf_I.cs | 8 +-- source/Cosmos.IL2CPU/IL/Conv_Ovf_I_Un.cs | 4 +- source/Cosmos.IL2CPU/IL/Conv_U.cs | 6 +- source/Cosmos.IL2CPU/IL/Initobj.cs | 2 +- source/Cosmos.IL2CPU/IL/Ldarga.cs | 4 +- source/Cosmos.IL2CPU/IL/Ldelema.cs | 8 +-- source/Cosmos.IL2CPU/IL/Ldind_I.cs | 2 +- source/Cosmos.IL2CPU/IL/Ldind_R4.cs | 2 +- source/Cosmos.IL2CPU/IL/Ldind_R8.cs | 2 +- source/Cosmos.IL2CPU/IL/Ldind_Ref.cs | 2 +- source/Cosmos.IL2CPU/IL/Ldlen.cs | 2 +- source/Cosmos.IL2CPU/IL/Mul_Ovf.cs | 2 +- source/Cosmos.IL2CPU/IL/Shr.cs | 4 +- source/Cosmos.IL2CPU/IL/Starg.cs | 2 +- source/Cosmos.IL2CPU/IL/Stloc.cs | 2 +- source/Cosmos.IL2CPU/IL/Stsfld.cs | 6 +- source/Cosmos.IL2CPU/IL/Switch.cs | 2 +- source/Cosmos.IL2CPU/IL/Throw.cs | 2 +- .../Assemblers/GetAmountOfRAM.cs | 6 +- .../Assemblers/GetCurrentESP.cs | 6 +- .../Assemblers/GetVbeModeAssembler.cs | 4 +- .../Cosmos.Sys.Plugs/Assemblers/Reboot.cs | 18 ++--- 29 files changed, 84 insertions(+), 133 deletions(-) diff --git a/Users/Orvid/OrvidTestOS/AsmMouse.cs b/Users/Orvid/OrvidTestOS/AsmMouse.cs index 2903c52839..dfc3a5f67a 100644 --- a/Users/Orvid/OrvidTestOS/AsmMouse.cs +++ b/Users/Orvid/OrvidTestOS/AsmMouse.cs @@ -69,20 +69,14 @@ public override void AssembleNew(object aAssembler, object aMethodInfo) SourceValue = 0x60 }; - new Push - { - DestinationReg = RegistersEnum.EAX - }; + XS.Push(XSRegisters.EAX); new Call { DestinationLabel = "send_mouse_cmd" }; - new Pop - { - DestinationReg = RegistersEnum.EAX - }; + XS.Pop(XSRegisters.EAX); new Call { @@ -121,15 +115,9 @@ public override void AssembleNew(object aAssembler, object aMethodInfo) #region mouse_read XS.Label("mouse_read"); { - new Push - { - DestinationReg = RegistersEnum.ECX - }; + XS.Push(XSRegisters.ECX); - new Push - { - DestinationReg = RegistersEnum.EDX - }; + XS.Push(XSRegisters.EDX); new Move { @@ -170,10 +158,7 @@ public override void AssembleNew(object aAssembler, object aMethodInfo) XS.Label("mouse_read_ready"); { - new Push - { - DestinationReg = RegistersEnum.ECX - }; + XS.Push(XSRegisters.ECX); new Move { @@ -189,10 +174,7 @@ public override void AssembleNew(object aAssembler, object aMethodInfo) DestinationLabel = "mouse_read_delay" }; - new Pop - { - DestinationReg = RegistersEnum.ECX - }; + XS.Pop(XSRegisters.ECX); new In2Port { @@ -210,15 +192,9 @@ public override void AssembleNew(object aAssembler, object aMethodInfo) XS.Label("mouse_read_exit"); { - new Pop - { - DestinationReg = RegistersEnum.EDX - }; + XS.Pop(XSRegisters.EDX); - new Pop - { - DestinationReg = RegistersEnum.ECX - }; + XS.Pop(XSRegisters.ECX); XS.Return(); } @@ -228,15 +204,9 @@ public override void AssembleNew(object aAssembler, object aMethodInfo) #region mouse_write XS.Label("mouse_write"); { - new Push - { - DestinationReg = RegistersEnum.ECX - }; + XS.Push(XSRegisters.ECX); - new Push - { - DestinationReg = RegistersEnum.EDX - }; + XS.Push(XSRegisters.EDX); new Move { @@ -421,10 +391,7 @@ public override void AssembleNew(object aAssembler, object aMethodInfo) DestinationLabel = "mouse_write_loop5" }; - new Dec - { - DestinationReg = RegistersEnum.AH - }; + XS.Dec(XSRegisters.AH); XS.Jump(ConditionalTestEnum.NotZero, "mouse_write_loop4"); } @@ -440,15 +407,9 @@ public override void AssembleNew(object aAssembler, object aMethodInfo) XS.Label("mouse_write_exit"); { - new Pop - { - DestinationReg = RegistersEnum.EDX - }; + XS.Pop(XSRegisters.EDX); - new Pop - { - DestinationReg = RegistersEnum.ECX - }; + XS.Pop(XSRegisters.ECX); XS.Return(); } diff --git a/source/Cosmos.Core.Plugs/System/Assemblers/InvokeImplAssembler.cs b/source/Cosmos.Core.Plugs/System/Assemblers/InvokeImplAssembler.cs index ae81a1127c..aa6fa010c6 100644 --- a/source/Cosmos.Core.Plugs/System/Assemblers/InvokeImplAssembler.cs +++ b/source/Cosmos.Core.Plugs/System/Assemblers/InvokeImplAssembler.cs @@ -174,7 +174,7 @@ public override void AssembleNew(Cosmos.Assembler.Assembler aAssembler, object a // var xGetInvocationListMethod = typeof(MulticastDelegate).GetMethod("GetInvocationList"); // new CPUx86.Call { DestinationLabel = CPU.MethodInfoLabelGenerator.GenerateLabelName(xGetInvocationListMethod) }; // new CPU.Comment("get address from return value -> eax"); - // new CPUx86.Pop { DestinationReg = CPUx86.Registers.EAX }; + // XS.Pop(XSRegisters.EAX); // ;//list // new CPU.Comment("eax+=8 is where the offset where an array's count is"); // new CPUx86.Add { DestinationReg = CPUx86.Registers.EAX, SourceValue = 8 };//addrof list.count?? @@ -186,12 +186,12 @@ public override void AssembleNew(Cosmos.Assembler.Assembler aAssembler, object a // new CPU.Comment("ecx = ptr to delegate object"); //// Ldarg.DoExecute(xAssembler, xMethodInfo, 0); - // new CPUx86.Push { DestinationReg = CPUx86.Registers.EAX }; + // XS.Push(XSRegisters.EAX); // // make ecx point to the size of arguments // Ldarg.DoExecute(xAssembler, xMethodInfo, 0); // Ldfld.DoExecute(xAssembler, xMethodInfo.MethodBase.DeclaringType, "$$ArgSize$$"); - // new CPUx86.Pop { DestinationReg = CPUx86.Registers.ECX }; - // new CPUx86.Pop { DestinationReg = CPUx86.Registers.EAX }; + // XS.Pop(XSRegisters.ECX); + // XS.Pop(XSRegisters.EAX); // new CPU.Comment("ecx points to the size of the delegated methods arguments"); // new CPUx86.Xor { DestinationReg = CPUx86.Registers.EDX, SourceReg = CPUx86.Registers.EDX }; // ;//make sure edx is 0 @@ -211,11 +211,11 @@ public override void AssembleNew(Cosmos.Assembler.Assembler aAssembler, object a // new CPUx86.Pushad(); // Ldarg.DoExecute(xAssembler, xMethodInfo, 0); // Ldfld.DoExecute(xAssembler, xMethodInfo.MethodBase.DeclaringType, "System.Object System.Delegate._target"); - // new CPUx86.Pop { DestinationReg = CPUx86.Registers.EDI }; + // XS.Pop(XSRegisters.EDI); // new CPUx86.Popad(); // new CPUx86.Compare { DestinationReg = CPUx86.Registers.EDI, SourceValue = 0 }; // new CPUx86.ConditionalJump { Condition = CPUx86.ConditionalTestEnum.Zero, DestinationLabel = ".NO_THIS" }; - // new CPUx86.Push { DestinationReg = CPUx86.Registers.EDI }; + // XS.Push(XSRegisters.EDI); // new CPU.Label(".NO_THIS"); @@ -236,8 +236,8 @@ public override void AssembleNew(Cosmos.Assembler.Assembler aAssembler, object a // new CPU.Comment("add 32 for the Pushad + 16 for the current stack + 4 for the return value"); // new CPUx86.Add { DestinationReg = CPUx86.Registers.ESI, SourceValue = 52 }; // new CPUx86.Movs { Size = 8, Prefixes = CPUx86.InstructionPrefixes.Repeat }; - // new CPUx86.Pop { DestinationReg = CPUx86.Registers.EDI }; - // new CPUx86.Call { DestinationReg = CPUx86.Registers.EDI }; + // XS.Pop(XSRegisters.EDI); + // XS.Call(XSRegisters.EDI); // new CPU.Comment("store return -- return stored into edi after popad"); // //new CPUx86.Move("edx", "[" + MethodInfo.Arguments[0].VirtualAddresses[0] + "]");//addrof the delegate // //new CPUx86.Move("edx", "[edx+" + (MethodInfo.Arguments[0].TypeInfo.Fields["$$ReturnsValue$$"].Offset + 12) + "]"); @@ -249,7 +249,7 @@ public override void AssembleNew(Cosmos.Assembler.Assembler aAssembler, object a // Ldarg.DoExecute(xAssembler, xMethodInfo, 0); // Ldfld.DoExecute(xAssembler, xMethodInfo.MethodBase.DeclaringType, "System.Object System.Delegate._target"); // // edi contains $this now - // new CPUx86.Pop { DestinationReg = CPUx86.Registers.EDI }; + // XS.Pop(XSRegisters.EDI); // //new CPUx86.Compare ("edi", "0"); // //new CPUx86.JumpIfEqual(".noTHIStoPop"); // //new CPUx86.Move("edx", "[" + MethodInfo.Arguments[0].VirtualAddresses[0] + "]");//addrof the delegate @@ -267,7 +267,7 @@ public override void AssembleNew(Cosmos.Assembler.Assembler aAssembler, object a // //new CPUx86.Move("[esp]", "edi"); // new CPU.Label(".noTHIStoPop"); // new CPUx86.Popad(); - // new CPUx86.Inc { DestinationReg = CPUx86.Registers.EDX }; + // XS.INC(XSRegisters.EDX); // new CPUx86.Add { DestinationReg = CPUx86.Registers.EAX, SourceValue = 4 }; // new CPUx86.Jump { DestinationLabel = ".BEGIN_OF_LOOP" }; // new CPU.Label(".END_OF_INVOKE_"); @@ -278,7 +278,7 @@ public override void AssembleNew(Cosmos.Assembler.Assembler aAssembler, object a // //new CPUx86.Pop("eax"); // //Ldarg.DoExecute(xAssembler, xMethodInfo, 0); // //Ldfld.DoExecute(xAssembler, xMethodInfo.MethodBase.DeclaringType, "$$ReturnsValue$$"); - // //new CPUx86.Pop { DestinationReg = CPUx86.Registers.EDX }; + // //XS.Pop(XSRegisters.EDX); // //if(xMethodInfo. // //new CPUx86.Compare { DestinationReg = CPUx86.Registers.EDX, SourceValue = 0 }; // //new CPUx86.ConditionalJump { Condition = CPUx86.ConditionalTestEnum.Equal, DestinationLabel = ".noReturn" }; @@ -286,7 +286,7 @@ public override void AssembleNew(Cosmos.Assembler.Assembler aAssembler, object a // //new CPUx86.Xchg { DestinationReg = CPUx86.Registers.EBP, DestinationIsIndirect = true, DestinationDisplacement = 8, SourceReg = CPUx86.Registers.EDX }; // //new CPUx86.Xchg { DestinationReg = CPUx86.Registers.EBP, DestinationIsIndirect = true, DestinationDisplacement = 4, SourceReg = CPUx86.Registers.EDX }; // //new CPUx86.Xchg { DestinationReg = CPUx86.Registers.EBP, DestinationIsIndirect = true, SourceReg = CPUx86.Registers.EDX }; - // //new CPUx86.Push { DestinationReg = CPUx86.Registers.EDX };//ebp + // //XS.Push(XSRegisters.EDX);//ebp // //new CPUx86.Move { DestinationReg = CPUx86.Registers.ESP, DestinationIsIndirect = true, DestinationDisplacement = 12, SourceReg = CPUx86.Registers.EDI }; // new CPU.Label(".noReturn"); // // new CPUx86.Sti(); diff --git a/source/Cosmos.IL2CPU/IL/Brfalse.cs b/source/Cosmos.IL2CPU/IL/Brfalse.cs index 5c866e031d..d0912a37ef 100644 --- a/source/Cosmos.IL2CPU/IL/Brfalse.cs +++ b/source/Cosmos.IL2CPU/IL/Brfalse.cs @@ -48,8 +48,8 @@ public override void Execute( MethodInfo aMethod, ILOpCode aOpCode ) // // if (xStackContent.Size > 4) // { - // new CPUx86.Pop { DestinationReg = CPUx86.Registers.EAX }; - // new CPUx86.Pop { DestinationReg = CPUx86.Registers.EBX }; + // XS.Pop(XSRegisters.EAX); + // XS.Pop(XSRegisters.EBX); // new CPUx86.Xor { DestinationReg = CPUx86.Registers.EAX, SourceReg = CPUx86.Registers.EAX }; // new CPUx86.ConditionalJump { Condition = CPUx86.ConditionalTestEnum.NotZero, DestinationLabel = LabelFalse }; // new CPUx86.Xor { DestinationReg = CPUx86.Registers.EBX, SourceReg = CPUx86.Registers.EBX }; @@ -58,7 +58,7 @@ public override void Execute( MethodInfo aMethod, ILOpCode aOpCode ) // XS.Label(LabelFalse); // } else // { - // new CPUx86.Pop { DestinationReg = CPUx86.Registers.EAX }; + // XS.Pop(XSRegisters.EAX); // new CPUx86.Compare { DestinationReg = CPUx86.Registers.EAX, SourceValue = 0 }; // new CPUx86.ConditionalJump { Condition = CPUx86.ConditionalTestEnum.Equal, DestinationLabel = TargetLabel }; // } diff --git a/source/Cosmos.IL2CPU/IL/Brtrue.cs b/source/Cosmos.IL2CPU/IL/Brtrue.cs index 5cb660635d..61850d3af8 100644 --- a/source/Cosmos.IL2CPU/IL/Brtrue.cs +++ b/source/Cosmos.IL2CPU/IL/Brtrue.cs @@ -38,15 +38,15 @@ public override void Execute( MethodInfo aMethod, ILOpCode aOpCode ) // } // if (xSize > 4) // { - // new CPUx86.Pop { DestinationReg = CPUx86.Registers.EAX }; - // new CPUx86.Pop { DestinationReg = CPUx86.Registers.EBX }; + // XS.Pop(XSRegisters.EAX); + // XS.Pop(XSRegisters.EBX); // new CPUx86.Xor { DestinationReg = CPUx86.Registers.EAX, SourceReg = CPUx86.Registers.EAX }; // new CPUx86.ConditionalJump { Condition = CPUx86.ConditionalTestEnum.NotZero, DestinationLabel = TargetLabel }; // new CPUx86.Xor { DestinationReg = CPUx86.Registers.EBX, SourceReg = CPUx86.Registers.EBX }; // new CPUx86.ConditionalJump { Condition = CPUx86.ConditionalTestEnum.NotZero, DestinationLabel = TargetLabel }; // } else // { - // new CPUx86.Pop { DestinationReg = CPUx86.Registers.EAX }; + // XS.Pop(XSRegisters.EAX); // new CPUx86.Compare { DestinationReg = CPUx86.Registers.EAX, SourceValue = 0 }; // new CPUx86.ConditionalJump { Condition = CPUx86.ConditionalTestEnum.NotEqual, DestinationLabel = TargetLabel }; // } diff --git a/source/Cosmos.IL2CPU/IL/Castclass.cs b/source/Cosmos.IL2CPU/IL/Castclass.cs index de4c243f14..cdfcd78bba 100644 --- a/source/Cosmos.IL2CPU/IL/Castclass.cs +++ b/source/Cosmos.IL2CPU/IL/Castclass.cs @@ -134,7 +134,7 @@ public override void Execute( MethodInfo aMethod, ILOpCode aOpCode ) // xOp.Assemble(); // XS.Label(mThisLabel + "_After_IsInstance_Call"); // Assembler.Stack.Pop(); - // new CPUx86.Pop { DestinationReg = CPUx86.Registers.EAX }; + // XS.Pop(XSRegisters.EAX); // new CPUx86.Compare { DestinationReg = CPUx86.Registers.EAX, SourceValue = 0 }; // new CPUx86.ConditionalJump { Condition = CPUx86.ConditionalTestEnum.NotEqual, DestinationLabel = mNextOpLabel }; // XS.Label(mReturnNullLabel); diff --git a/source/Cosmos.IL2CPU/IL/Cgt_Un.cs b/source/Cosmos.IL2CPU/IL/Cgt_Un.cs index 6bd43ff9b2..4b1d939450 100644 --- a/source/Cosmos.IL2CPU/IL/Cgt_Un.cs +++ b/source/Cosmos.IL2CPU/IL/Cgt_Un.cs @@ -155,17 +155,17 @@ public override void Execute( MethodInfo aMethod, ILOpCode aOpCode ) // new CPUx86.Add { DestinationReg = CPUx86.Registers.ESI, SourceValue = 1 }; // new CPUx86.Xor { DestinationReg = CPUx86.Registers.EDI, SourceReg = CPUx86.Registers.EDI}; // //esi = 1 - // new CPUx86.Pop { DestinationReg = CPUx86.Registers.EAX }; - // new CPUx86.Pop { DestinationReg = CPUx86.Registers.EDX }; + // XS.Pop(XSRegisters.EAX); + // XS.Pop(XSRegisters.EDX); // //value2: EDX:EAX - // new CPUx86.Pop { DestinationReg = CPUx86.Registers.EBX }; - // new CPUx86.Pop { DestinationReg = CPUx86.Registers.ECX }; + // XS.Pop(XSRegisters.EBX); + // XS.Pop(XSRegisters.ECX); // //value1: ECX:EBX // new CPUx86.Sub { DestinationReg = CPUx86.Registers.EBX, SourceReg = CPUx86.Registers.EAX }; // new CPUx86.SubWithCarry { DestinationReg = CPUx86.Registers.ECX, SourceReg = CPUx86.Registers.EDX }; // //result = value1 - value2 // //new CPUx86.ConditionalMove(Condition.Above, "edi", "esi"); - // //new CPUx86.Push { DestinationReg = Registers.EDI }; + // //XS.Push(XSRegisters.EDI); // // new CPUx86.ConditionalJump { Condition = CPUx86.ConditionalTestEnum.Above, DestinationLabel = LabelTrue }; // new CPUx86.Push { DestinationValue = 0 }; @@ -176,7 +176,7 @@ public override void Execute( MethodInfo aMethod, ILOpCode aOpCode ) // // } else // { - // new CPUx86.Pop{DestinationReg=CPUx86.Registers.EAX}; + // XS.Pop(XSRegisters.EAX); // new CPUx86.Compare { DestinationReg = CPUx86.Registers.EAX, SourceReg = CPUx86.Registers.ESP, SourceIsIndirect = true }; // new CPUx86.ConditionalJump { Condition = CPUx86.ConditionalTestEnum.Below, DestinationLabel = LabelTrue }; // new CPUx86.Jump { DestinationLabel = LabelFalse }; diff --git a/source/Cosmos.IL2CPU/IL/Conv_I.cs b/source/Cosmos.IL2CPU/IL/Conv_I.cs index fb3743f109..5198012c30 100644 --- a/source/Cosmos.IL2CPU/IL/Conv_I.cs +++ b/source/Cosmos.IL2CPU/IL/Conv_I.cs @@ -31,9 +31,9 @@ namespace Cosmos.IL2CPU.X86.IL // case 4: // break; // case 8: - // new CPUx86.Pop { DestinationReg = CPUx86.Registers.EAX }; - // new CPUx86.Pop { DestinationReg = CPUx86.Registers.EDX }; - // new CPUx86.Push { DestinationReg = CPUx86.Registers.EAX }; + // XS.Pop(XSRegisters.EAX); + // XS.Pop(XSRegisters.EDX); + // XS.Push(XSRegisters.EAX); // break; // default: // //EmitNotImplementedException( Assembler, GetServiceProvider(), "Conv_I: SourceSize " + xSource + " not supported!", mCurLabel, mMethodInformation, mCurOffset, mNextLabel ); diff --git a/source/Cosmos.IL2CPU/IL/Conv_Ovf_I.cs b/source/Cosmos.IL2CPU/IL/Conv_Ovf_I.cs index 5777023035..14c52e0585 100644 --- a/source/Cosmos.IL2CPU/IL/Conv_Ovf_I.cs +++ b/source/Cosmos.IL2CPU/IL/Conv_Ovf_I.cs @@ -43,10 +43,10 @@ public override void Execute(MethodInfo aMethod, ILOpCode aOpCode) // } // case 8: // { - // new CPUx86.Pop { DestinationReg = CPUx86.Registers.EAX }; + // XS.Pop(XSRegisters.EAX); // new CPUx86.SignExtendAX { Size = 32 }; // //all bits of EDX == sign (EAX) - // new CPUx86.Pop { DestinationReg = CPUx86.Registers.EBX }; + // XS.Pop(XSRegisters.EBX); // //must be equal to EDX // new CPUx86.Xor { DestinationReg = CPUx86.Registers.EBX, SourceReg = CPUx86.Registers.EDX }; // new CPUx86.ConditionalJump { Condition = CPUx86.ConditionalTestEnum.Zero, DestinationLabel = AssemblerNasm.TmpPosLabel( aMethod, aNextOpCode ) }; @@ -98,10 +98,10 @@ public override void Execute(MethodInfo aMethod, ILOpCode aOpCode) // } // case 8: // { - // new CPUx86.Pop { DestinationReg = CPUx86.Registers.EAX }; + // XS.Pop(XSRegisters.EAX); // new CPUx86.SignExtendAX { Size = 32 }; // //all bits of EDX == sign (EAX) - // new CPUx86.Pop { DestinationReg = CPUx86.Registers.EBX }; + // XS.Pop(XSRegisters.EBX); // //must be equal to EDX // new CPUx86.Xor { DestinationReg = CPUx86.Registers.EBX, SourceReg = CPUx86.Registers.EDX }; // new CPUx86.ConditionalJump { Condition = CPUx86.ConditionalTestEnum.Zero, DestinationLabel = NextInstructionLabel }; diff --git a/source/Cosmos.IL2CPU/IL/Conv_Ovf_I_Un.cs b/source/Cosmos.IL2CPU/IL/Conv_Ovf_I_Un.cs index 87541ecca2..9d10e927e5 100644 --- a/source/Cosmos.IL2CPU/IL/Conv_Ovf_I_Un.cs +++ b/source/Cosmos.IL2CPU/IL/Conv_Ovf_I_Un.cs @@ -82,9 +82,9 @@ public override void Execute(MethodInfo aMethod, ILOpCode aOpCode) { // break; // } // case 8: { - // new CPUx86.Pop { DestinationReg = CPUx86.Registers.EAX }; + // XS.Pop(XSRegisters.EAX); // new CPUx86.Add { DestinationReg = CPUx86.Registers.ESP, SourceValue = 4 }; - // new CPUx86.Push { DestinationReg = CPUx86.Registers.EAX }; + // XS.Push(XSRegisters.EAX); // //new CPUx86.Pop(CPUx86.Registers_Old.EAX); // //new CPUx86.SignExtendAX(4); // ////all bits of EDX == sign (EAX) diff --git a/source/Cosmos.IL2CPU/IL/Conv_U.cs b/source/Cosmos.IL2CPU/IL/Conv_U.cs index 6f85233257..d880206ed4 100644 --- a/source/Cosmos.IL2CPU/IL/Conv_U.cs +++ b/source/Cosmos.IL2CPU/IL/Conv_U.cs @@ -29,9 +29,9 @@ namespace Cosmos.IL2CPU.X86.IL // throw new Exception("The size {0:D} could not exist, because always is pushed Int32 or Int64!"); // case 8: // { - // new CPUx86.Pop { DestinationReg = CPUx86.Registers.EAX }; - // new CPUx86.Pop { DestinationReg = CPUx86.Registers.EDX }; - // new CPUx86.Push { DestinationReg = CPUx86.Registers.EAX }; + // XS.Pop(XSRegisters.EAX); + // XS.Pop(XSRegisters.EDX); + // XS.Push(XSRegisters.EAX); // break; // } // case 4: diff --git a/source/Cosmos.IL2CPU/IL/Initobj.cs b/source/Cosmos.IL2CPU/IL/Initobj.cs index a06f621f34..98043cd33e 100644 --- a/source/Cosmos.IL2CPU/IL/Initobj.cs +++ b/source/Cosmos.IL2CPU/IL/Initobj.cs @@ -88,7 +88,7 @@ public override void Execute( MethodInfo aMethod, ILOpCode aOpCode ) // GetService().GetTypeFieldInfo(mType, out mObjSize); // } // Assembler.Stack.Pop(); - // new CPUx86.Pop { DestinationReg = CPUx86.Registers.EAX }; + // XS.Pop(XSRegisters.EAX); // for (int i = 0; i < (mObjSize / 4); i++) { // new CPUx86.Move { DestinationReg = CPUx86.Registers.EAX, DestinationIsIndirect = true, DestinationDisplacement = i * 4, SourceValue = 0, Size=32 }; // } diff --git a/source/Cosmos.IL2CPU/IL/Ldarga.cs b/source/Cosmos.IL2CPU/IL/Ldarga.cs index a3bd2378dc..4222504d2f 100644 --- a/source/Cosmos.IL2CPU/IL/Ldarga.cs +++ b/source/Cosmos.IL2CPU/IL/Ldarga.cs @@ -66,7 +66,7 @@ public override void Execute( MethodInfo aMethod, ILOpCode aOpCode ) // } // xOffset += xExtraSize; //#warning TODO: check this -// new CPUx86.Push { DestinationReg = CPUx86.Registers.EBP }; +// XS.Push(XSRegisters.EBP); // for( int i = 0; i < ( xCurArgSize / 4 ); i++ ) // { @@ -134,7 +134,7 @@ public override void Execute( MethodInfo aMethod, ILOpCode aOpCode ) // mNextLabel = IL.Op.GetInstructionLabel(aReader.NextPosition); // } // public override void DoAssemble() { - // new CPU.Push { DestinationReg = CPU.Registers.EBP }; + // XS.Push(XSRegisters.EBP); // Assembler.Stack.Push(new StackContent(4, typeof(uint))); // new CPU.Push { DestinationValue = (uint)mAddress }; // Assembler.Stack.Push(new StackContent(4, typeof(uint))); diff --git a/source/Cosmos.IL2CPU/IL/Ldelema.cs b/source/Cosmos.IL2CPU/IL/Ldelema.cs index 34e43847ea..2e9b499b6c 100644 --- a/source/Cosmos.IL2CPU/IL/Ldelema.cs +++ b/source/Cosmos.IL2CPU/IL/Ldelema.cs @@ -72,13 +72,13 @@ public override void Execute(MethodInfo aMethod, ILOpCode aOpCode) // aAssembler.Stack.Pop(); // aAssembler.Stack.Pop(); // aAssembler.Stack.Push(new StackContent(4, typeof(uint))); - // new CPUx86.Pop { DestinationReg = CPUx86.Registers.EAX }; + // XS.Pop(XSRegisters.EAX); // new CPUx86.Move { DestinationReg = CPUx86.Registers.EDX, SourceValue = aElementSize }; - // new CPUx86.Multiply{DestinationReg=CPUx86.Registers.EDX}; + // XS.Multiply(XSRegisters.EDX); // new CPUx86.Add { DestinationReg = CPUx86.Registers.EAX, SourceValue = (uint)(ObjectImpl.FieldDataOffset + 4) }; - // new CPUx86.Pop { DestinationReg = CPUx86.Registers.EDX }; + // XS.Pop(XSRegisters.EDX); // new CPUx86.Add { DestinationReg = CPUx86.Registers.EDX, SourceReg = CPUx86.Registers.EAX }; - // new CPUx86.Push { DestinationReg = CPUx86.Registers.EDX }; + // XS.Push(XSRegisters.EDX); // } // // public override void DoAssemble() { diff --git a/source/Cosmos.IL2CPU/IL/Ldind_I.cs b/source/Cosmos.IL2CPU/IL/Ldind_I.cs index 08e84bba78..a48193893a 100644 --- a/source/Cosmos.IL2CPU/IL/Ldind_I.cs +++ b/source/Cosmos.IL2CPU/IL/Ldind_I.cs @@ -30,7 +30,7 @@ public override void Execute( MethodInfo aMethod, ILOpCode aOpCode ) // : base(aReader, aMethodInfo) { // } // public override void DoAssemble() { - // new CPUx86.Pop { DestinationReg = CPUx86.Registers.EAX }; + // XS.Pop(XSRegisters.EAX); // new CPUx86.Push { DestinationReg = CPUx86.Registers.EAX, DestinationIsIndirect = true }; // } // } diff --git a/source/Cosmos.IL2CPU/IL/Ldind_R4.cs b/source/Cosmos.IL2CPU/IL/Ldind_R4.cs index 07b8d68ad1..287c1abb7d 100644 --- a/source/Cosmos.IL2CPU/IL/Ldind_R4.cs +++ b/source/Cosmos.IL2CPU/IL/Ldind_R4.cs @@ -32,7 +32,7 @@ public override void Execute( MethodInfo aMethod, ILOpCode aOpCode ) // } // public override void DoAssemble() { // Assembler.Stack.Pop(); - // new CPUx86.Pop { DestinationReg = CPUx86.Registers.EAX }; + // XS.Pop(XSRegisters.EAX); // new CPUx86.Push { DestinationReg = CPUx86.Registers.EAX, DestinationIsIndirect=true, Size=32 }; // Assembler.Stack.Push(new StackContent(4, typeof(Single))); // } diff --git a/source/Cosmos.IL2CPU/IL/Ldind_R8.cs b/source/Cosmos.IL2CPU/IL/Ldind_R8.cs index 13e1e1b793..9120a5107a 100644 --- a/source/Cosmos.IL2CPU/IL/Ldind_R8.cs +++ b/source/Cosmos.IL2CPU/IL/Ldind_R8.cs @@ -32,7 +32,7 @@ public override void Execute( MethodInfo aMethod, ILOpCode aOpCode ) // : base(aReader, aMethodInfo) { // } // public override void DoAssemble() { - // new CPUx86.Pop{DestinationReg=CPUx86.Registers.EAX}; + // XS.Pop(XSRegisters.EAX); // Assembler.Stack.Pop(); // new CPUx86.Push { DestinationReg = CPUx86.Registers.EAX, DestinationIsIndirect = true, DestinationDisplacement = 4 }; // new CPUx86.Push { DestinationReg = CPUx86.Registers.EAX, DestinationIsIndirect = true}; diff --git a/source/Cosmos.IL2CPU/IL/Ldind_Ref.cs b/source/Cosmos.IL2CPU/IL/Ldind_Ref.cs index b2f1d83972..9b1de14d28 100644 --- a/source/Cosmos.IL2CPU/IL/Ldind_Ref.cs +++ b/source/Cosmos.IL2CPU/IL/Ldind_Ref.cs @@ -32,7 +32,7 @@ public override void Execute( MethodInfo aMethod, ILOpCode aOpCode ) // : base(aReader, aMethodInfo) { // } // public override void DoAssemble() { - // new CPU.Pop { DestinationReg = CPU.Registers.EAX }; + // XS.Pop(XSRegisters.EAX); // new CPU.Push { DestinationReg = CPU.Registers.EAX, DestinationIsIndirect = true }; // } // } diff --git a/source/Cosmos.IL2CPU/IL/Ldlen.cs b/source/Cosmos.IL2CPU/IL/Ldlen.cs index 5949492e43..57b25c0337 100644 --- a/source/Cosmos.IL2CPU/IL/Ldlen.cs +++ b/source/Cosmos.IL2CPU/IL/Ldlen.cs @@ -34,7 +34,7 @@ public override void Execute( MethodInfo aMethod, ILOpCode aOpCode ) // } // public override void DoAssemble() { // Assembler.Stack.Pop(); - // new CPUx86.Pop { DestinationReg = CPUx86.Registers.EAX }; + // XS.Pop(XSRegisters.EAX); // new CPUx86.Add{DestinationReg=CPUx86.Registers.EAX, SourceValue=8}; // new CPUx86.Push { DestinationReg = CPUx86.Registers.EAX, DestinationIsIndirect = true }; // Assembler.Stack.Push(new StackContent(4, typeof(uint))); diff --git a/source/Cosmos.IL2CPU/IL/Mul_Ovf.cs b/source/Cosmos.IL2CPU/IL/Mul_Ovf.cs index 43d1f4a305..cbeddc1858 100644 --- a/source/Cosmos.IL2CPU/IL/Mul_Ovf.cs +++ b/source/Cosmos.IL2CPU/IL/Mul_Ovf.cs @@ -119,7 +119,7 @@ public static void DoExecute(uint xStackContentSize, string aBaseLabel) } else { - new Assembler.x86.Pop { DestinationReg = RegistersEnum.EAX }; + XS.Pop(XSRegisters.EAX); new Multiply { DestinationReg = RegistersEnum.ESP, diff --git a/source/Cosmos.IL2CPU/IL/Shr.cs b/source/Cosmos.IL2CPU/IL/Shr.cs index 1267f68b9f..007b123142 100644 --- a/source/Cosmos.IL2CPU/IL/Shr.cs +++ b/source/Cosmos.IL2CPU/IL/Shr.cs @@ -72,12 +72,12 @@ public override void Execute( MethodInfo aMethod, ILOpCode aOpCode ) var xStackItem_Value = Assembler.Stack.Peek(); if( xStackItem_Value.Size <= 4 ) { - new CPUx86.Pop { DestinationReg = CPUx86.Registers.ECX }; // shift amount + XS.Pop(XSRegisters.ECX); // shift amount new CPUx86.ShiftRight { DestinationReg = CPUx86.Registers.ESP, DestinationIsIndirect = true, SourceReg = CPUx86.Registers.CL }; } else if( xStackItem_Value.Size <= 8 ) { - new CPUx86.Pop { DestinationReg = CPUx86.Registers.ECX }; // shift amount + XS.Pop(XSRegisters.ECX); // shift amount // [ESP] is high part // [ESP + 4] is low part new CPUx86.Move { DestinationReg = CPUx86.Registers.EAX, SourceReg = CPUx86.Registers.ESP, SourceIsIndirect = true, SourceDisplacement = 4 }; diff --git a/source/Cosmos.IL2CPU/IL/Starg.cs b/source/Cosmos.IL2CPU/IL/Starg.cs index b9a578772f..620b6cb065 100644 --- a/source/Cosmos.IL2CPU/IL/Starg.cs +++ b/source/Cosmos.IL2CPU/IL/Starg.cs @@ -81,7 +81,7 @@ public override void Execute( MethodInfo aMethod, ILOpCode aOpCode ) // throw new Exception("No Address Specified!"); // } // for (int i = (mAddresses.Length - 1); i >= 0; i -= 1) { - // new CPUx86.Pop{DestinationReg=CPUx86.Registers.EAX}; + // XS.Pop(XSRegisters.EAX); // new CPUx86.Move { DestinationReg = CPUx86.Registers.EBP, DestinationIsIndirect = true, DestinationDisplacement = mAddresses[i], SourceReg = CPUx86.Registers.EAX }; // } // Assembler.Stack.Pop(); diff --git a/source/Cosmos.IL2CPU/IL/Stloc.cs b/source/Cosmos.IL2CPU/IL/Stloc.cs index ebf36008fb..5656047969 100644 --- a/source/Cosmos.IL2CPU/IL/Stloc.cs +++ b/source/Cosmos.IL2CPU/IL/Stloc.cs @@ -58,7 +58,7 @@ public override void Execute(MethodInfo aMethod, ILOpCode aOpCode) // new CPUx86.Call { DestinationLabel = MethodInfoLabelGenerator.GenerateLabelName(GCImplementationRefs.DecRefCountRef) }; // } // foreach (int i in mLocal.VirtualAddresses.Reverse()) { - // new CPUx86.Pop { DestinationReg = CPUx86.Registers.EAX }; ; + // XS.Pop(XSRegisters.EAX); ; // new CPUx86.Move { DestinationReg = CPUx86.Registers.EBP, DestinationIsIndirect = true, DestinationDisplacement = i, SourceReg = CPUx86.Registers.EAX }; // } // // no need to inc again, items on the transient stack are also counted diff --git a/source/Cosmos.IL2CPU/IL/Stsfld.cs b/source/Cosmos.IL2CPU/IL/Stsfld.cs index 86bf2853a6..f02fb3a1de 100644 --- a/source/Cosmos.IL2CPU/IL/Stsfld.cs +++ b/source/Cosmos.IL2CPU/IL/Stsfld.cs @@ -136,18 +136,18 @@ public override void Execute( MethodInfo aMethod, ILOpCode aOpCode ) // } // for (int i = 0; i < (xSize / 4); i++) // { - // new CPUx86.Pop { DestinationReg = CPUx86.Registers.EAX }; + // XS.Pop(XSRegisters.EAX); // new CPUx86.Move { DestinationRef = Cosmos.Assembler.ElementReference.New(mDataName, i * 4), DestinationIsIndirect = true, SourceReg = CPUx86.Registers.EAX }; // } // switch (xSize % 4) // { // case 1: { - // new CPUx86.Pop { DestinationReg = CPUx86.Registers.EAX }; + // XS.Pop(XSRegisters.EAX); // new CPUx86.Move { DestinationRef = Cosmos.Assembler.ElementReference.New(mDataName, (int)((xSize / 4) * 4)), DestinationIsIndirect = true, SourceReg = CPUx86.Registers.AL }; // break; // } // case 2: { - // new CPUx86.Pop { DestinationReg = CPUx86.Registers.EAX }; + // XS.Pop(XSRegisters.EAX); // new CPUx86.Move { DestinationRef = Cosmos.Assembler.ElementReference.New(mDataName, (int)((xSize / 4) * 4)), DestinationIsIndirect = true, SourceReg = CPUx86.Registers.AX }; // break; // } diff --git a/source/Cosmos.IL2CPU/IL/Switch.cs b/source/Cosmos.IL2CPU/IL/Switch.cs index edebf4acca..2821bedc85 100644 --- a/source/Cosmos.IL2CPU/IL/Switch.cs +++ b/source/Cosmos.IL2CPU/IL/Switch.cs @@ -46,7 +46,7 @@ public override void Execute( MethodInfo aMethod, ILOpCode aOpCode ) // } // // public override void DoAssemble() { - // new CPUx86.Pop { DestinationReg = CPUx86.Registers.EAX }; + // XS.Pop(XSRegisters.EAX); // for(int i = 0; i < mLabels.Length; i++){ // new CPUx86.Compare { DestinationReg = CPUx86.Registers.EAX, SourceValue =(uint)i }; // new CPUx86.ConditionalJump { Condition = CPUx86.ConditionalTestEnum.Equal, DestinationLabel = mLabels[i] }; diff --git a/source/Cosmos.IL2CPU/IL/Throw.cs b/source/Cosmos.IL2CPU/IL/Throw.cs index 5b2154e7ba..0f5d580d07 100644 --- a/source/Cosmos.IL2CPU/IL/Throw.cs +++ b/source/Cosmos.IL2CPU/IL/Throw.cs @@ -38,7 +38,7 @@ public override void Execute( MethodInfo aMethod, ILOpCode aOpCode ) // } // // public static void Assemble(Assembler.Assembler aAssembler, MethodInformation aMethodInfo, int aCurrentILOffset, string aExceptionOccurredLabel) { - // new CPUx86.Pop { DestinationReg = CPUx86.Registers.EAX }; + // XS.Pop(XSRegisters.EAX); // new CPUx86.Move { DestinationRef = CPU.ElementReference.New(CPU.DataMember.GetStaticFieldName(CPU.Assembler.CurrentExceptionRef)), DestinationIsIndirect = true, SourceReg = CPUx86.Registers.EAX }; // new CPUx86.Call { DestinationLabel = aExceptionOccurredLabel }; // new CPUx86.Move { DestinationReg = CPUx86.Registers.ECX, SourceValue = 3 }; diff --git a/source/Unused/Cosmos.Kernel.Plugs/Assemblers/GetAmountOfRAM.cs b/source/Unused/Cosmos.Kernel.Plugs/Assemblers/GetAmountOfRAM.cs index ed89616d17..671568a98c 100644 --- a/source/Unused/Cosmos.Kernel.Plugs/Assemblers/GetAmountOfRAM.cs +++ b/source/Unused/Cosmos.Kernel.Plugs/Assemblers/GetAmountOfRAM.cs @@ -1,4 +1,4 @@ -using System; +using System; using Cosmos.IL2CPU.Plugs; using Assembler = Cosmos.Assembler; using CPUx86 = Cosmos.Assembler.x86; @@ -10,9 +10,9 @@ public override void AssembleNew(Cosmos.Assembler.Assembler aAssembler, object a new CPUx86.Mov { DestinationReg = CPUx86.Registers.EAX, SourceRef = CPUAll.ElementReference.New("MultiBootInfo_Memory_High"), SourceIsIndirect = true }; new CPUx86.Xor { DestinationReg = CPUx86.Registers.EDX, SourceReg = CPUx86.Registers.EDX }; new CPUx86.Mov { DestinationReg = CPUx86.Registers.ECX, SourceValue = 1024 }; - new CPUx86.Divide { DestinationReg = CPUx86.Registers.ECX }; + XS.Divide(XSRegisters.ECX); new CPUx86.Add { DestinationReg = CPUx86.Registers.EAX, SourceValue = 1 }; - new CPUx86.Push { DestinationReg = CPUx86.Registers.EAX }; + XS.Push(XSRegisters.EAX); } } diff --git a/source/Unused/Cosmos.Kernel.Plugs/Assemblers/GetCurrentESP.cs b/source/Unused/Cosmos.Kernel.Plugs/Assemblers/GetCurrentESP.cs index d66ece78fd..e4ad099352 100644 --- a/source/Unused/Cosmos.Kernel.Plugs/Assemblers/GetCurrentESP.cs +++ b/source/Unused/Cosmos.Kernel.Plugs/Assemblers/GetCurrentESP.cs @@ -1,4 +1,4 @@ -using System; +using System; using System.Collections.Generic; using Cosmos.IL2CPU.Plugs; using CPUx86 = Cosmos.Assembler.x86; @@ -6,9 +6,7 @@ namespace Cosmos.Kernel.Plugs.Assemblers { public class GetCurrentESP: AssemblerMethod { public override void AssembleNew(Cosmos.Assembler.Assembler aAssembler, object aMethodInfo) { - new CPUx86.Push { - DestinationReg = CPUx86.Registers.ESP - }; + XS.Push(XSRegisters.ESP); } } } diff --git a/source/Unused/Cosmos.Sys.Plugs/Assemblers/GetVbeModeAssembler.cs b/source/Unused/Cosmos.Sys.Plugs/Assemblers/GetVbeModeAssembler.cs index dc2e05e798..3be95fd779 100644 --- a/source/Unused/Cosmos.Sys.Plugs/Assemblers/GetVbeModeAssembler.cs +++ b/source/Unused/Cosmos.Sys.Plugs/Assemblers/GetVbeModeAssembler.cs @@ -1,4 +1,4 @@ -using System; +using System; using System.Collections.Generic; using System.Linq; using System.Text; @@ -14,7 +14,7 @@ public override void AssembleNew(Cosmos.Assembler.Assembler aAssembler, object a { new Xor { DestinationReg = Registers.EAX, SourceReg = Registers.EAX }; new Mov { DestinationReg = Registers.AX, SourceRef = Cosmos.Assembler.ElementReference.New("MultibootGraphicsRuntime_VbeMode"), SourceIsIndirect = true }; - new Push { DestinationReg = Registers.EAX }; + XS.Push(XSRegisters.EAX); } } } \ No newline at end of file diff --git a/source/Unused/Cosmos.Sys.Plugs/Assemblers/Reboot.cs b/source/Unused/Cosmos.Sys.Plugs/Assemblers/Reboot.cs index 500ca913b1..1b643e53f9 100644 --- a/source/Unused/Cosmos.Sys.Plugs/Assemblers/Reboot.cs +++ b/source/Unused/Cosmos.Sys.Plugs/Assemblers/Reboot.cs @@ -1,4 +1,4 @@ -using Cosmos.IL2CPU.Plugs; +using Cosmos.IL2CPU.Plugs; using Assembler=Cosmos.Assembler; using CPUAll = Cosmos.Assembler; using CPUx86 = Cosmos.Assembler.x86; @@ -16,9 +16,7 @@ public override void AssembleNew(Cosmos.Assembler.Assembler aAssembler, object a SourceValue = 0x64, DestinationReg = CPUx86.Registers.DX }; - new CPUx86.IN { - DestinationReg = CPUx86.Registers.AL - }; + XS.InFromDX(XSRegisters.AL); new CPUx86.Test { DestinationReg = CPUx86.Registers.AL, SourceValue = 2 @@ -35,17 +33,13 @@ public override void AssembleNew(Cosmos.Assembler.Assembler aAssembler, object a DestinationReg = CPUx86.Registers.DX, SourceValue = 0x64 }; - new CPUx86.Out { - DestinationReg = CPUx86.Registers.AL - }; + XS.OutToDX(XSRegisters.AL); new CPUAll.Label(".clearBuffer"); new CPUx86.Mov { SourceValue = 0x64, DestinationReg = CPUx86.Registers.DX }; - new CPUx86.IN { - DestinationReg = CPUx86.Registers.AL - }; + XS.InFromDX(XSRegisters.AL); new CPUx86.Test { DestinationReg = CPUx86.Registers.AL, SourceValue = 2 @@ -62,9 +56,7 @@ public override void AssembleNew(Cosmos.Assembler.Assembler aAssembler, object a DestinationReg = CPUx86.Registers.DX, SourceValue = 0x60 }; - new CPUx86.Out { - DestinationReg = CPUx86.Registers.AL - }; + XS.OutToDX(XSRegisters.AL); new CPUAll.Label(".loop");//failed... halt new CPUx86.Halt(); new CPUx86.Jump {