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 feef7db commit f6f0bab
Show file tree
Hide file tree
Showing 37 changed files with 151 additions and 145 deletions.
54 changes: 27 additions & 27 deletions Users/Orvid/OrvidTestOS/AsmMouse.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
//#define ASMMouse
//#define ASMMouse

#if ASMMouse
//#define DebugMouse
Expand Down Expand Up @@ -119,7 +119,7 @@ public override void AssembleNew(object aAssembler, object aMethodInfo)
};

#region mouse_read
new Label("mouse_read");
XS.Label("mouse_read");
{
new Push
{
Expand All @@ -137,7 +137,7 @@ public override void AssembleNew(object aAssembler, object aMethodInfo)
SourceValue = 0xffff
};

new Label("mouse_read_loop");
XS.Label("mouse_read_loop");
{
new In2Port
{
Expand Down Expand Up @@ -175,7 +175,7 @@ public override void AssembleNew(object aAssembler, object aMethodInfo)
};
}

new Label("mouse_read_ready");
XS.Label("mouse_read_ready");
{
new Push
{
Expand All @@ -189,7 +189,7 @@ public override void AssembleNew(object aAssembler, object aMethodInfo)
};
}

new Label("mouse_read_delay");
XS.Label("mouse_read_delay");
{
new Loop
{
Expand All @@ -215,7 +215,7 @@ public override void AssembleNew(object aAssembler, object aMethodInfo)
};
}

new Label("mouse_read_exit");
XS.Label("mouse_read_exit");
{
new Pop
{
Expand All @@ -227,13 +227,13 @@ public override void AssembleNew(object aAssembler, object aMethodInfo)
DestinationReg = RegistersEnum.ECX
};

new Return();
XS.Return();
}
}
#endregion

#region mouse_write
new Label("mouse_write");
XS.Label("mouse_write");
{
new Push
{
Expand All @@ -257,7 +257,7 @@ public override void AssembleNew(object aAssembler, object aMethodInfo)
SourceValue = 0xffff
};

new Label("mouse_write_loop1");
XS.Label("mouse_write_loop1");
{
new In2Port
{
Expand Down Expand Up @@ -295,7 +295,7 @@ public override void AssembleNew(object aAssembler, object aMethodInfo)
};
}

new Label("mouse_write_ok1");
XS.Label("mouse_write_ok1");
{
new In2Port
{
Expand All @@ -311,7 +311,7 @@ public override void AssembleNew(object aAssembler, object aMethodInfo)
};
}

new Label("mouse_write_loop");
XS.Label("mouse_write_loop");
{
new In2Port
{
Expand Down Expand Up @@ -349,7 +349,7 @@ public override void AssembleNew(object aAssembler, object aMethodInfo)
};
}

new Label("mouse_write_ok");
XS.Label("mouse_write_ok");
{
new Move
{
Expand All @@ -371,7 +371,7 @@ public override void AssembleNew(object aAssembler, object aMethodInfo)
};
}

new Label("mouse_write_loop3");
XS.Label("mouse_write_loop3");
{
new In2Port
{
Expand Down Expand Up @@ -409,7 +409,7 @@ public override void AssembleNew(object aAssembler, object aMethodInfo)
};
}

new Label("mouse_write_ok3");
XS.Label("mouse_write_ok3");
{
new Move
{
Expand All @@ -418,7 +418,7 @@ public override void AssembleNew(object aAssembler, object aMethodInfo)
};
}

new Label("mouse_write_loop4");
XS.Label("mouse_write_loop4");
{
new Move
{
Expand All @@ -427,7 +427,7 @@ public override void AssembleNew(object aAssembler, object aMethodInfo)
};
}

new Label("mouse_write_loop5");
XS.Label("mouse_write_loop5");
{
new In2Port
{
Expand Down Expand Up @@ -465,7 +465,7 @@ public override void AssembleNew(object aAssembler, object aMethodInfo)
};
}

new Label("mouse_write_ok4");
XS.Label("mouse_write_ok4");
{
new Xor
{
Expand All @@ -474,7 +474,7 @@ public override void AssembleNew(object aAssembler, object aMethodInfo)
};
}

new Label("mouse_write_exit");
XS.Label("mouse_write_exit");
{
new Pop
{
Expand All @@ -486,13 +486,13 @@ public override void AssembleNew(object aAssembler, object aMethodInfo)
DestinationReg = RegistersEnum.ECX
};

new Return();
XS.Return();
}
}
#endregion

#region send_mouse_cmd
new Label("send_mouse_cmd");
XS.Label("send_mouse_cmd");
{

new Move
Expand All @@ -501,7 +501,7 @@ public override void AssembleNew(object aAssembler, object aMethodInfo)
SourceValue = 0xffff
};

new Label("mouse_cmd_wait");
XS.Label("mouse_cmd_wait");
{
new In2Port
{
Expand Down Expand Up @@ -529,7 +529,7 @@ public override void AssembleNew(object aAssembler, object aMethodInfo)
};
}

new Label("mouse_cmd_send");
XS.Label("mouse_cmd_send");
{
new Move
{
Expand All @@ -554,7 +554,7 @@ public override void AssembleNew(object aAssembler, object aMethodInfo)
};
}

new Label("mouse_cmd_accept");
XS.Label("mouse_cmd_accept");
{
new In2Port
{
Expand All @@ -578,7 +578,7 @@ public override void AssembleNew(object aAssembler, object aMethodInfo)
};
}

new Label("mouse_cmd_error");
XS.Label("mouse_cmd_error");
{
new Move
{
Expand All @@ -591,7 +591,7 @@ public override void AssembleNew(object aAssembler, object aMethodInfo)
};
}

new Label("mouse_cmd_ok");
XS.Label("mouse_cmd_ok");
{
new Xor
{
Expand All @@ -600,9 +600,9 @@ public override void AssembleNew(object aAssembler, object aMethodInfo)
};
}

new Label("mouse_cmd_exit");
XS.Label("mouse_cmd_exit");
{
new Return();
XS.Return();
}
}
#endregion
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
using System;
using System;

using Cosmos.Assembler;
using Cosmos.IL2CPU.Plugs;
Expand Down Expand Up @@ -35,7 +35,7 @@ public override void AssembleNew(Cosmos.Assembler.Assembler aAssembler, object a
* ECX contains the argument size
*/
new CPUx86.ClearInterruptFlag();
new Label(".DEBUG");
XS.Label(".DEBUG");
//new CPU.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));
Expand All @@ -62,7 +62,7 @@ public override void AssembleNew(Cosmos.Assembler.Assembler aAssembler, object a
XS.Set(XSRegisters.OldToNewRegister(CPUx86.RegistersEnum.ECX), XSRegisters.OldToNewRegister(CPUx86.RegistersEnum.ECX), sourceDisplacement: Ldfld.GetFieldOffset(xMethodInfo.MethodBase.DeclaringType, "$$ArgSize$$"));//the size of the arguments to the method? + 12??? -- 12 is the size of the current call stack.. i think
XS.Xor(XSRegisters.OldToNewRegister(CPUx86.RegistersEnum.EDX), XSRegisters.OldToNewRegister(CPUx86.RegistersEnum.EDX));
;//make sure edx is 0
new Label(".BEGIN_OF_LOOP");
XS.Label(".BEGIN_OF_LOOP");
{
XS.Compare(XSRegisters.OldToNewRegister(CPUx86.RegistersEnum.EDX), XSRegisters.OldToNewRegister(CPUx86.RegistersEnum.EBX));//are we at the end of this list
new CPUx86.ConditionalJump { Condition = CPUx86.ConditionalTestEnum.GreaterThanOrEqualTo, DestinationLabel = ".END_OF_INVOKE_" };//then we better stop
Expand All @@ -78,7 +78,7 @@ public override void AssembleNew(Cosmos.Assembler.Assembler aAssembler, object a
new CPUx86.ConditionalJump { Condition = CPUx86.ConditionalTestEnum.Zero, DestinationLabel = ".NO_THIS" };
XS.Push(XSRegisters.OldToNewRegister(CPUx86.RegistersEnum.EDI));

new Label(".NO_THIS");
XS.Label(".NO_THIS");

XS.Comment("make space for us to copy the arguments too");
XS.Sub(XSRegisters.OldToNewRegister(CPUx86.RegistersEnum.ESP), XSRegisters.OldToNewRegister(CPUx86.RegistersEnum.ECX));
Expand All @@ -103,21 +103,21 @@ public override void AssembleNew(Cosmos.Assembler.Assembler aAssembler, object a
XS.Add(XSRegisters.OldToNewRegister(CPUx86.RegistersEnum.ESI), 8); // ebp+8 is first argument
new CPUx86.Movs { Size = 8, Prefixes = CPUx86.InstructionPrefixes.Repeat };
XS.Pop(XSRegisters.OldToNewRegister(CPUx86.RegistersEnum.EDI));
new Label(".BeforeCall");
XS.Label(".BeforeCall");
XS.Call(XSRegisters.EDI);
XS.Comment("store return -- return stored into edi after popad");
XS.Comment("edi = ptr to delegate object");
XS.Set(XSRegisters.OldToNewRegister(CPUx86.RegistersEnum.EDI), XSRegisters.OldToNewRegister(CPUx86.RegistersEnum.EBP), sourceDisplacement: Ldarg.GetArgumentDisplacement(xMethodInfo, 0));
XS.Comment("edi = ptr to delegate object should be a pointer to the delgates context ie (this) for the methods ");
new CPUx86.Mov { DestinationReg = CPUx86.RegistersEnum.EDI, SourceReg = CPUx86.RegistersEnum.EDI, SourceIsIndirect = true }; // dereference handle
XS.Set(XSRegisters.OldToNewRegister(CPUx86.RegistersEnum.EDI), XSRegisters.OldToNewRegister(CPUx86.RegistersEnum.EDI), sourceDisplacement: Ldfld.GetFieldOffset(xMethodInfo.MethodBase.DeclaringType, "System.Object System.Delegate._target"));//i really dont get the +12, MtW: that's for the object header
new Label(".noTHIStoPop");
XS.Label(".noTHIStoPop");
new CPUx86.Popad();
XS.Increment(XSRegisters.OldToNewRegister(CPUx86.RegistersEnum.EDX));
XS.Add(XSRegisters.OldToNewRegister(CPUx86.RegistersEnum.EAX), 4);
new CPUx86.Jump { DestinationLabel = ".BEGIN_OF_LOOP" };
}
new Label(".END_OF_INVOKE_");
XS.Label(".END_OF_INVOKE_");
XS.Comment("get the return value");
XS.Set(XSRegisters.OldToNewRegister(CPUx86.RegistersEnum.EDX), XSRegisters.OldToNewRegister(CPUx86.RegistersEnum.EBP), sourceDisplacement: Ldarg.GetArgumentDisplacement(xMethodInfo, 0));//addrof the delegate
new CPUx86.Mov { DestinationReg = CPUx86.RegistersEnum.EDX, SourceReg = CPUx86.RegistersEnum.EDX, SourceIsIndirect = true }; // dereference handle
Expand Down Expand Up @@ -150,11 +150,11 @@ public override void AssembleNew(Cosmos.Assembler.Assembler aAssembler, object a
// // param 1 is sender
// // param 2 is eventargs
// //Ldarg.Ldfld(aAssembler, aMethodInfo.TypeInfo, "System.Object System.Delegate._target");
// //new Label(".LoadMethodParams");
// //XS.Label(".LoadMethodParams");
// //for (int i = 1; i < aMethodInfo.Arguments.Length; i++) {
// // Ldarg.Ldarg(aAssembler, aMethodInfo.Arguments[i]);
// //}
// //new Label(".LoadMethodPointer");
// //XS.Label(".LoadMethodPointer");
// //Ldarg.Ldarg(aAssembler, aMethodInfo.Arguments[0]);
// //Ldarg.Ldfld(aAssembler, aMethodInfo.TypeInfo, "System.IntPtr System.Delegate._methodPtr");
// //new CPUx86.Pop("eax");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,10 @@
<Project>{61607F1E-58F9-41CF-972F-128384F3E115}</Project>
<Name>Cosmos.Debug.Kernel</Name>
</ProjectReference>
<ProjectReference Include="..\XSharp.Compiler\XSharp.Compiler.csproj">
<Project>{A281A1B1-C718-4BCB-A7BE-ED840A70449A}</Project>
<Name>XSharp.Compiler</Name>
</ProjectReference>
</ItemGroup>
<ItemGroup>
<None Include=".editorconfig" />
Expand Down
7 changes: 4 additions & 3 deletions source/Cosmos.Debug.Kernel.Plugs/DebuggerAsm.cs
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
using System;
using System;
using System.Collections.Generic;
using System.Text;
using Cosmos.IL2CPU.Plugs;
using Cosmos.Assembler;
using XSharp.Compiler;

namespace Cosmos.Debug.Kernel.Plugs
{
Expand Down Expand Up @@ -144,13 +145,13 @@ public class DebugDoSend : AssemblerMethod
public override void AssembleNew(Cosmos.Assembler.Assembler aAssembler, object aMethodInfo)
{
new LiteralAssemblerCode("%ifdef DEBUGSTUB");
new Label(".BeforeArgumentsPrepare");
XS.Label(".BeforeArgumentsPrepare");
new LiteralAssemblerCode("mov EBX, [EBP + 8]");
new LiteralAssemblerCode("mov EBX, [EBX]");
new LiteralAssemblerCode("push dword [EBX + 12]");
new LiteralAssemblerCode("add EBX, 16");
new LiteralAssemblerCode("push dword EBX");
new Label(".BeforeCall");
XS.Label(".BeforeCall");
new LiteralAssemblerCode("Call DebugStub_SendText");
new LiteralAssemblerCode("add ESP, 8");
new LiteralAssemblerCode("%endif");
Expand Down
Loading

0 comments on commit f6f0bab

Please sign in to comment.