Skip to content

Commit

Permalink
.
Browse files Browse the repository at this point in the history
  • Loading branch information
mterwoord committed Jun 16, 2016
1 parent be7b8a2 commit 2468981
Show file tree
Hide file tree
Showing 17 changed files with 43 additions and 67 deletions.
36 changes: 6 additions & 30 deletions Users/Orvid/OrvidTestOS/AsmMouse.cs
Original file line number Diff line number Diff line change
Expand Up @@ -143,11 +143,7 @@ public override void AssembleNew(object aAssembler, object aMethodInfo)
Size = 8
};

new Xor
{
DestinationReg = RegistersEnum.AH,
SourceReg = RegistersEnum.AH
};
XS.Xor(XSRegisters.AH, XSRegisters.RegistersEnum.AH);
}

XS.Label("mouse_read_exit");
Expand All @@ -168,11 +164,7 @@ public override void AssembleNew(object aAssembler, object aMethodInfo)

XS.Push(XSRegisters.EDX);

new Move
{
DestinationReg = RegistersEnum.BH,
SourceReg = RegistersEnum.AL
};
XS.Mov(XSRegisters.BH, XSRegisters.RegistersEnum.AL);

XS.Mov(XSRegisters.ECX, 0xffff);

Expand Down Expand Up @@ -236,11 +228,7 @@ public override void AssembleNew(object aAssembler, object aMethodInfo)

XS.Label("mouse_write_ok");
{
new Move
{
DestinationReg = RegistersEnum.AL,
SourceReg = RegistersEnum.BH
};
XS.Mov(XSRegisters.AL, XSRegisters.RegistersEnum.BH);

new Out2Port
{
Expand Down Expand Up @@ -310,11 +298,7 @@ public override void AssembleNew(object aAssembler, object aMethodInfo)

XS.Label("mouse_write_ok4");
{
new Xor
{
DestinationReg = RegistersEnum.AH,
SourceReg = RegistersEnum.AH
};
XS.Xor(XSRegisters.AH, XSRegisters.RegistersEnum.AH);
}

XS.Label("mouse_write_exit");
Expand Down Expand Up @@ -353,11 +337,7 @@ public override void AssembleNew(object aAssembler, object aMethodInfo)

XS.Label("mouse_cmd_send");
{
new Move
{
DestinationReg = RegistersEnum.AL,
SourceReg = RegistersEnum.BL
};
XS.Mov(XSRegisters.AL, XSRegisters.RegistersEnum.BL);
new Out2Port
{
#if DebugMouse
Expand Down Expand Up @@ -396,11 +376,7 @@ public override void AssembleNew(object aAssembler, object aMethodInfo)

XS.Label("mouse_cmd_ok");
{
new Xor
{
DestinationReg = RegistersEnum.AH,
SourceReg = RegistersEnum.AH
};
XS.Xor(XSRegisters.AH, XSRegisters.RegistersEnum.AH);
}

XS.Label("mouse_cmd_exit");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -193,10 +193,10 @@ public override void AssembleNew(Cosmos.Assembler.Assembler aAssembler, object a
// 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 };
// XS.Xor(XSRegisters.EDX, XSRegisters.CPUx86.Registers.EDX);
// ;//make sure edx is 0
// new CPU.Label(".BEGIN_OF_LOOP");
// new CPUx86.Compare { DestinationReg = CPUx86.Registers.EDX, SourceReg = CPUx86.Registers.EBX };//are we at the end of this list
// XS.Compare(XSRegisters.EDX, XSRegisters.CPUx86.Registers.EBX);//are we at the end of this list
// new CPUx86.ConditionalJump { Condition = CPUx86.ConditionalTestEnum.Equal, DestinationLabel = ".END_OF_INVOKE_" };//then we better stop
// //new CPUx86.Compare("edx", 0);
// //new CPUx86.JumpIfLessOrEqual(".noreturnYet");
Expand All @@ -206,7 +206,7 @@ public override void AssembleNew(Cosmos.Assembler.Assembler aAssembler, object a
// //new CPUx86.Pushd("0");
// new CPUx86.Pushad();
// new CPU.Comment("esi points to where we will copy the methods arguments from");
// new CPUx86.Move { DestinationReg = CPUx86.Registers.ESI, SourceReg = CPUx86.Registers.ESP };
// XS.Mov(XSRegisters.ESI, XSRegisters.CPUx86.Registers.ESP);
// new CPU.Comment("edi = ptr to delegate object");
// new CPUx86.Pushad();
// Ldarg.DoExecute(xAssembler, xMethodInfo, 0);
Expand All @@ -220,14 +220,14 @@ public override void AssembleNew(Cosmos.Assembler.Assembler aAssembler, object a
// new CPU.Label(".NO_THIS");

// new CPU.Comment("make space for us to copy the arguments too");
// new CPUx86.Sub { DestinationReg = CPUx86.Registers.ESP, SourceReg = CPUx86.Registers.EBX };
// XS.Sub(XSRegisters.ESP, XSRegisters.CPUx86.Registers.EBX);
// new CPU.Comment("move the current delegate to edi");
// XS.Mov(XSRegisters.EDI, XSRegisters.EAX, sourceIsIndirect: true);
// new CPU.Comment("move the methodptr from that delegate to the stack ");
// new CPUx86.Pushad();
// Ldarg.DoExecute(xAssembler, xMethodInfo, 0);
// Ldfld.DoExecute(xAssembler, xMethodInfo.MethodBase.DeclaringType, "System.IntPtr System.Delegate._methodPtr");
// new CPUx86.Move { DestinationReg = CPUx86.Registers.EDI, SourceReg = CPUx86.Registers.ESP };
// XS.Mov(XSRegisters.EDI, XSRegisters.CPUx86.Registers.ESP);

// new CPU.Comment("get above the saved methodptr");
// XS.Add(XSRegisters.EDI, 4);
Expand Down
16 changes: 8 additions & 8 deletions source/Cosmos.IL2CPU/CosmosAssembler.cs
Original file line number Diff line number Diff line change
Expand Up @@ -317,20 +317,20 @@ public void Initialize()
//WriteDebugVideo("Initializing SSE.");
//new Comment(this, "BEGIN - SSE Init");
//// CR4[bit 9]=1, CR4[bit 10]=1, CR0[bit 2]=0, CR0[bit 1]=1
//new Mov { DestinationReg = Registers.EAX, SourceReg = Registers.CR4 };
//XS.Mov(XSRegisters.EAX, XSRegisters.Registers.CR4);
//XS.Or(XSRegisters.EAX, 0x100);
//new Mov { DestinationReg = Registers.CR4, SourceReg = Registers.EAX };
//new Mov { DestinationReg = Registers.EAX, SourceReg = Registers.CR4 };
//XS.Mov(XSRegisters.CR4, XSRegisters.Registers.EAX);
//XS.Mov(XSRegisters.EAX, XSRegisters.Registers.CR4);
//XS.Or(XSRegisters.EAX, 0x200);
//new Mov { DestinationReg = Registers.CR4, SourceReg = Registers.EAX };
//new Mov { DestinationReg = Registers.EAX, SourceReg = Registers.CR0 };
//XS.Mov(XSRegisters.CR4, XSRegisters.Registers.EAX);
//XS.Mov(XSRegisters.EAX, XSRegisters.Registers.CR0);

//XS.And(XSRegisters.EAX, 0xfffffffd);
//new Mov { DestinationReg = Registers.CR0, SourceReg = Registers.EAX };
//new Mov { DestinationReg = Registers.EAX, SourceReg = Registers.CR0 };
//XS.Mov(XSRegisters.CR0, XSRegisters.Registers.EAX);
//XS.Mov(XSRegisters.EAX, XSRegisters.Registers.CR0);

//XS.And(XSRegisters.EAX, 1);
//new Mov { DestinationReg = Registers.CR0, SourceReg = Registers.EAX };
//XS.Mov(XSRegisters.CR0, XSRegisters.Registers.EAX);
//new Comment(this, "END - SSE Init");

if (mComPort > 0)
Expand Down
4 changes: 2 additions & 2 deletions source/Cosmos.IL2CPU/IL/Brfalse.cs
Original file line number Diff line number Diff line change
Expand Up @@ -50,9 +50,9 @@ public override void Execute( MethodInfo aMethod, ILOpCode aOpCode )
// {
// XS.Pop(XSRegisters.EAX);
// XS.Pop(XSRegisters.EBX);
// new CPUx86.Xor { DestinationReg = CPUx86.Registers.EAX, SourceReg = CPUx86.Registers.EAX };
// XS.Xor(XSRegisters.EAX, XSRegisters.CPUx86.Registers.EAX);
// XS.Jump(ConditionalTestEnum.NotZero, LabelFalse);
// new CPUx86.Xor { DestinationReg = CPUx86.Registers.EBX, SourceReg = CPUx86.Registers.EBX };
// XS.Xor(XSRegisters.EBX, XSRegisters.CPUx86.Registers.EBX);
// XS.Jump(ConditionalTestEnum.NotZero, LabelFalse);
// new CPUx86.Jump { DestinationLabel = TargetLabel };
// XS.Label(LabelFalse);
Expand Down
4 changes: 2 additions & 2 deletions source/Cosmos.IL2CPU/IL/Brtrue.cs
Original file line number Diff line number Diff line change
Expand Up @@ -40,9 +40,9 @@ public override void Execute( MethodInfo aMethod, ILOpCode aOpCode )
// {
// XS.Pop(XSRegisters.EAX);
// XS.Pop(XSRegisters.EBX);
// new CPUx86.Xor { DestinationReg = CPUx86.Registers.EAX, SourceReg = CPUx86.Registers.EAX };
// XS.Xor(XSRegisters.EAX, XSRegisters.CPUx86.Registers.EAX);
// XS.Jump(ConditionalTestEnum.NotZero, TargetLabel);
// new CPUx86.Xor { DestinationReg = CPUx86.Registers.EBX, SourceReg = CPUx86.Registers.EBX };
// XS.Xor(XSRegisters.EBX, XSRegisters.CPUx86.Registers.EBX);
// XS.Jump(ConditionalTestEnum.NotZero, TargetLabel);
// } else
// {
Expand Down
8 changes: 4 additions & 4 deletions source/Cosmos.IL2CPU/IL/Cgt_Un.cs
Original file line number Diff line number Diff line change
Expand Up @@ -151,18 +151,18 @@ public override void Execute( MethodInfo aMethod, ILOpCode aOpCode )
// string LabelFalse = BaseLabel + "False";
// if (xStackItem.Size > 4)
// {
// new CPUx86.Xor { DestinationReg = CPUx86.Registers.ESI, SourceReg = CPUx86.Registers.ESI};
// XS.Xor(XSRegisters.ESI, XSRegisters.CPUx86.Registers.ESI);
// XS.Add(XSRegisters.ESI, 1);
// new CPUx86.Xor { DestinationReg = CPUx86.Registers.EDI, SourceReg = CPUx86.Registers.EDI};
// XS.Xor(XSRegisters.EDI, XSRegisters.CPUx86.Registers.EDI);
// //esi = 1
// XS.Pop(XSRegisters.EAX);
// XS.Pop(XSRegisters.EDX);
// //value2: EDX:EAX
// 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 };
// XS.Sub(XSRegisters.EBX, XSRegisters.CPUx86.Registers.EAX);
// XS.SubWithCarry(XSRegisters.ECX, XSRegisters.CPUx86.Registers.EDX);
// //result = value1 - value2
// //new CPUx86.ConditionalMove(Condition.Above, "edi", "esi");
// //XS.Push(XSRegisters.EDI);
Expand Down
2 changes: 1 addition & 1 deletion source/Cosmos.IL2CPU/IL/Conv_I.cs
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ namespace Cosmos.IL2CPU.X86.IL
// if (xSource.IsFloat)
// {
// new CPUx86.SSE.MoveSS { SourceReg = CPUx86.Registers.ESP, DestinationReg = CPUx86.Registers.XMM0, SourceIsIndirect = true };
// new CPUx86.SSE.ConvertSS2SI { SourceReg = CPUx86.Registers.XMM0, DestinationReg = CPUx86.Registers.EAX };
// XS.ConvertSS2SI(XSRegisters.EAX, XSRegisters.CPUx86.Registers.XMM0);
// new CPUx86.Move { DestinationReg = CPUx86.Registers.ESP, SourceReg = CPUx86.Registers.EAX, DestinationIsIndirect = true };
// }
// else
Expand Down
4 changes: 2 additions & 2 deletions source/Cosmos.IL2CPU/IL/Conv_Ovf_I.cs
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ public override void Execute(MethodInfo aMethod, ILOpCode aOpCode)
// //all bits of EDX == sign (EAX)
// XS.Pop(XSRegisters.EBX);
// //must be equal to EDX
// new CPUx86.Xor { DestinationReg = CPUx86.Registers.EBX, SourceReg = CPUx86.Registers.EDX };
// XS.Xor(XSRegisters.EBX, XSRegisters.CPUx86.Registers.EDX);
// new CPUx86.ConditionalJump { Condition = CPUx86.ConditionalTestEnum.Zero, DestinationLabel = AssemblerNasm.TmpPosLabel( aMethod, aNextOpCode ) };
// //equals
// new CPUx86.Interrupt { DestinationValue = 4 };
Expand Down Expand Up @@ -103,7 +103,7 @@ public override void Execute(MethodInfo aMethod, ILOpCode aOpCode)
// //all bits of EDX == sign (EAX)
// XS.Pop(XSRegisters.EBX);
// //must be equal to EDX
// new CPUx86.Xor { DestinationReg = CPUx86.Registers.EBX, SourceReg = CPUx86.Registers.EDX };
// XS.Xor(XSRegisters.EBX, XSRegisters.CPUx86.Registers.EDX);
// XS.Jump(ConditionalTestEnum.Zero, NextInstructionLabel);
// //equals
// new CPUx86.Interrupt{DestinationValue=4};
Expand Down
2 changes: 1 addition & 1 deletion source/Cosmos.IL2CPU/IL/Conv_U.cs
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ namespace Cosmos.IL2CPU.X86.IL
// if (xSource.IsFloat)
// {
// new CPUx86.SSE.MoveSS { SourceReg = CPUx86.Registers.ESP, DestinationReg = CPUx86.Registers.XMM0, SourceIsIndirect = true };
// new CPUx86.SSE.ConvertSS2SI { SourceReg = CPUx86.Registers.XMM0, DestinationReg = CPUx86.Registers.EAX };
// XS.ConvertSS2SI(XSRegisters.EAX, XSRegisters.CPUx86.Registers.XMM0);
// new CPUx86.Move { DestinationReg = CPUx86.Registers.ESP, SourceReg = CPUx86.Registers.EAX, DestinationIsIndirect = true };
// }
// else
Expand Down
2 changes: 1 addition & 1 deletion source/Cosmos.IL2CPU/IL/Ldelema.cs
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ public override void Execute(MethodInfo aMethod, ILOpCode aOpCode)
// XS.Multiply(XSRegisters.EDX);
// new CPUx86.Add { DestinationReg = CPUx86.Registers.EAX, SourceValue = (uint)(ObjectImpl.FieldDataOffset + 4) };
// XS.Pop(XSRegisters.EDX);
// new CPUx86.Add { DestinationReg = CPUx86.Registers.EDX, SourceReg = CPUx86.Registers.EAX };
// XS.Add(XSRegisters.EDX, XSRegisters.CPUx86.Registers.EAX);
// XS.Push(XSRegisters.EDX);
// }
//
Expand Down
4 changes: 2 additions & 2 deletions source/Unused/Cosmos.Kernel.Plugs/Assemblers/DisablePSE.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,9 @@
namespace Cosmos.Kernel.Plugs.Assemblers {
public class ASMDisablePSE: AssemblerMethod {
public override void AssembleNew(Cosmos.Assembler.Assembler aAssembler, object aMethodInfo) {
new CPUx86.Mov { DestinationReg = CPUx86.Registers.EAX, SourceReg = CPUx86.Registers.CR4 };
XS.Mov(XSRegisters.EAX, XSRegisters.CPUx86.Registers.CR4);
XS.And(XSRegisters.EAX, 0xFFFFFFEF);
new CPUx86.Mov { DestinationReg = CPUx86.Registers.CR4, SourceReg = CPUx86.Registers.EAX };
XS.Mov(XSRegisters.CR4, XSRegisters.CPUx86.Registers.EAX);

}
}
Expand Down
4 changes: 2 additions & 2 deletions source/Unused/Cosmos.Kernel.Plugs/Assemblers/DisablePaging.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,9 @@
namespace Cosmos.Kernel.Plugs.Assemblers {
public class ASMDisablePaging: AssemblerMethod {
public override void AssembleNew(Cosmos.Assembler.Assembler aAssembler, object aMethodInfo) {
new CPUx86.Mov { DestinationReg = CPUx86.Registers.EAX, SourceReg = CPUx86.Registers.CR0 };
XS.Mov(XSRegisters.EAX, XSRegisters.CPUx86.Registers.CR0);
XS.And(XSRegisters.EAX, 0x7FFFFFFF);
new CPUx86.Mov { DestinationReg = CPUx86.Registers.CR0, SourceReg = CPUx86.Registers.EAX };
XS.Mov(XSRegisters.CR0, XSRegisters.CPUx86.Registers.EAX);
}
}
}
4 changes: 2 additions & 2 deletions source/Unused/Cosmos.Kernel.Plugs/Assemblers/EnablePSE.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,9 @@
namespace Cosmos.Kernel.Plugs.Assemblers {
public class ASMEnablePSE: AssemblerMethod {
public override void AssembleNew(Cosmos.Assembler.Assembler aAssembler, object aMethodInfo) {
new CPUx86.Mov { DestinationReg = CPUx86.Registers.EAX, SourceReg = CPUx86.Registers.CR4 };
XS.Mov(XSRegisters.EAX, XSRegisters.CPUx86.Registers.CR4);
XS.Or(XSRegisters.EAX, 0x00000010);
new CPUx86.Mov { DestinationReg = CPUx86.Registers.CR4, SourceReg = CPUx86.Registers.EAX };
XS.Mov(XSRegisters.CR4, XSRegisters.CPUx86.Registers.EAX);
}
}
}
4 changes: 2 additions & 2 deletions source/Unused/Cosmos.Kernel.Plugs/Assemblers/EnablePaging.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,9 @@ namespace Cosmos.Kernel.Plugs.Assemblers {
public class ASMEnablePaging: AssemblerMethod {

public override void AssembleNew(Cosmos.Assembler.Assembler aAssembler, object aMethodInfo) {
new CPUx86.Mov { DestinationReg = CPUx86.Registers.EAX, SourceReg = CPUx86.Registers.CR0 };
XS.Mov(XSRegisters.EAX, XSRegisters.CPUx86.Registers.CR0);
XS.Or(XSRegisters.EAX, 0x80000000);
new CPUx86.Mov { DestinationReg = CPUx86.Registers.CR0, SourceReg = CPUx86.Registers.EAX };
XS.Mov(XSRegisters.CR0, XSRegisters.CPUx86.Registers.EAX);
}

}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ namespace Cosmos.Kernel.Plugs.Assemblers {
public class GetAmountOfRAM: AssemblerMethod {
public override void AssembleNew(Cosmos.Assembler.Assembler aAssembler, object aMethodInfo) {
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 };
XS.Xor(XSRegisters.EDX, XSRegisters.CPUx86.Registers.EDX);
XS.Mov(XSRegisters.ECX, 1024);
XS.Divide(XSRegisters.ECX);
XS.Add(XSRegisters.EAX, 1);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ namespace Cosmos.Kernel.Plugs.Assemblers {
public class ASMSetPageDirectory: AssemblerMethod {
public override void AssembleNew(Cosmos.Assembler.Assembler aAssembler, object aMethodInfo) {
new CPUx86.Mov { DestinationReg = CPUx86.Registers.EAX, SourceReg = CPUx86.Registers.ESP, SourceIsIndirect = true, SourceDisplacement = 0x8 };
new CPUx86.Mov { DestinationReg = CPUx86.Registers.CR3, SourceReg = CPUx86.Registers.EAX };
XS.Mov(XSRegisters.CR3, XSRegisters.CPUx86.Registers.EAX);
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ public class GetVbeModeAssembler: AssemblerMethod
{
public override void AssembleNew(Cosmos.Assembler.Assembler aAssembler, object aMethodInfo)
{
new Xor { DestinationReg = Registers.EAX, SourceReg = Registers.EAX };
XS.Xor(XSRegisters.EAX, XSRegisters.Registers.EAX);
new Mov { DestinationReg = Registers.AX, SourceRef = Cosmos.Assembler.ElementReference.New("MultibootGraphicsRuntime_VbeMode"), SourceIsIndirect = true };
XS.Push(XSRegisters.EAX);
}
Expand Down

0 comments on commit 2468981

Please sign in to comment.