Skip to content

Commit

Permalink
.
Browse files Browse the repository at this point in the history
  • Loading branch information
mterwoord committed Jun 15, 2016
1 parent 5803a95 commit 12d1ae5
Show file tree
Hide file tree
Showing 29 changed files with 84 additions and 133 deletions.
65 changes: 13 additions & 52 deletions Users/Orvid/OrvidTestOS/AsmMouse.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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
{
Expand Down Expand Up @@ -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
{
Expand Down Expand Up @@ -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
{
Expand All @@ -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
{
Expand All @@ -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();
}
Expand All @@ -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
{
Expand Down Expand Up @@ -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");
}
Expand All @@ -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();
}
Expand Down
24 changes: 12 additions & 12 deletions source/Cosmos.Core.Plugs/System/Assemblers/InvokeImplAssembler.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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??
Expand All @@ -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
Expand All @@ -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");

Expand All @@ -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) + "]");
Expand All @@ -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
Expand All @@ -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_");
Expand All @@ -278,15 +278,15 @@ 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" };
// ////may have to expand the return... idk
// //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();
Expand Down
6 changes: 3 additions & 3 deletions source/Cosmos.IL2CPU/IL/Brfalse.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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 };
Expand All @@ -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 };
// }
Expand Down
6 changes: 3 additions & 3 deletions source/Cosmos.IL2CPU/IL/Brtrue.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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 };
// }
Expand Down
2 changes: 1 addition & 1 deletion source/Cosmos.IL2CPU/IL/Castclass.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
12 changes: 6 additions & 6 deletions source/Cosmos.IL2CPU/IL/Cgt_Un.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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 };
Expand All @@ -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 };
Expand Down
6 changes: 3 additions & 3 deletions source/Cosmos.IL2CPU/IL/Conv_I.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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 );
Expand Down
8 changes: 4 additions & 4 deletions source/Cosmos.IL2CPU/IL/Conv_Ovf_I.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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 ) };
Expand Down Expand Up @@ -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 };
Expand Down
4 changes: 2 additions & 2 deletions source/Cosmos.IL2CPU/IL/Conv_Ovf_I_Un.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
Loading

0 comments on commit 12d1ae5

Please sign in to comment.