mirror of
https://github.com/danbulant/Cosmos
synced 2026-05-27 14:02:19 +00:00
X# work.
This commit is contained in:
parent
b74dd21e3c
commit
bfa405335d
7 changed files with 47 additions and 14 deletions
|
|
@ -284,8 +284,8 @@ namespace Cosmos.Compiler.Assembler {
|
||||||
|
|
||||||
// This is the new type of DataMember, eventually we can eliminate many of the
|
// This is the new type of DataMember, eventually we can eliminate many of the
|
||||||
// code in DataMember (base)
|
// code in DataMember (base)
|
||||||
public class DataMemberInt : DataMember {
|
public class DataMember32 : DataMember {
|
||||||
public DataMemberInt(string aName) : base(aName) {
|
public DataMember32(string aName) : base(aName) {
|
||||||
int[] xValue = { 0 };
|
int[] xValue = { 0 };
|
||||||
UntypedDefaultValue = xValue.Cast<object>().ToArray();
|
UntypedDefaultValue = xValue.Cast<object>().ToArray();
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -316,7 +316,7 @@ namespace Cosmos.Compiler.DebugStub {
|
||||||
EAX = (uint)xCount;
|
EAX = (uint)xCount;
|
||||||
Call<DebugStub.WriteAXToComPort>();
|
Call<DebugStub.WriteAXToComPort>();
|
||||||
|
|
||||||
ESI = Memory["DebugEBP", 32];
|
ESI = Memory["DebugStub_OldEBP", 32];
|
||||||
ESI.Add(8); // Dont transmit EIP or old EBP
|
ESI.Add(8); // Dont transmit EIP or old EBP
|
||||||
for (int i = 1; i <= xCount; i++) {
|
for (int i = 1; i <= xCount; i++) {
|
||||||
Call("WriteByteToComPort");
|
Call("WriteByteToComPort");
|
||||||
|
|
@ -331,7 +331,7 @@ namespace Cosmos.Compiler.DebugStub {
|
||||||
|
|
||||||
// Send size of bytes
|
// Send size of bytes
|
||||||
ESI = Memory["DebugESP", 32];
|
ESI = Memory["DebugESP", 32];
|
||||||
EAX = Memory["DebugEBP", 32];
|
EAX = Memory["DebugStub_OldEBP", 32];
|
||||||
EAX.Sub(ESI);
|
EAX.Sub(ESI);
|
||||||
Call<DebugStub.WriteAXToComPort>();
|
Call<DebugStub.WriteAXToComPort>();
|
||||||
|
|
||||||
|
|
@ -340,7 +340,7 @@ namespace Cosmos.Compiler.DebugStub {
|
||||||
// Need to reload ESI, WriteAXToCompPort modifies it
|
// Need to reload ESI, WriteAXToCompPort modifies it
|
||||||
ESI = Memory["DebugESP", 32];
|
ESI = Memory["DebugESP", 32];
|
||||||
Label = "DebugStub_SendStack_SendByte";
|
Label = "DebugStub_SendStack_SendByte";
|
||||||
ESI.Compare(Memory["DebugEBP", 32]);
|
ESI.Compare(Memory["DebugStub_OldEBP", 32]);
|
||||||
JumpIf(Flags.Equal, "DebugStub_SendStack_Exit");
|
JumpIf(Flags.Equal, "DebugStub_SendStack_Exit");
|
||||||
Call("WriteByteToComPort");
|
Call("WriteByteToComPort");
|
||||||
Jump("DebugStub_SendStack_SendByte");
|
Jump("DebugStub_SendStack_SendByte");
|
||||||
|
|
@ -492,7 +492,7 @@ namespace Cosmos.Compiler.DebugStub {
|
||||||
Memory["DebugBreakOnNextTrace", 32].Compare(StepTrigger.Over);
|
Memory["DebugBreakOnNextTrace", 32].Compare(StepTrigger.Over);
|
||||||
JumpIf(Flags.NotEqual, "DebugStub_ExecutingStepOverAfter");
|
JumpIf(Flags.NotEqual, "DebugStub_ExecutingStepOverAfter");
|
||||||
Label = "Debug__StepOver__";
|
Label = "Debug__StepOver__";
|
||||||
EAX = Memory["DebugEBP", 32];
|
EAX = Memory["DebugStub_OldEBP", 32];
|
||||||
EAX.Compare(Memory["DebugBreakEBP", 32]);
|
EAX.Compare(Memory["DebugBreakEBP", 32]);
|
||||||
// If EBP and start EBP arent equal, dont break
|
// If EBP and start EBP arent equal, dont break
|
||||||
// Dont use Equal because we aslo need to stop above if the user starts
|
// Dont use Equal because we aslo need to stop above if the user starts
|
||||||
|
|
@ -505,7 +505,7 @@ namespace Cosmos.Compiler.DebugStub {
|
||||||
Memory["DebugBreakOnNextTrace", 32].Compare(StepTrigger.Out);
|
Memory["DebugBreakOnNextTrace", 32].Compare(StepTrigger.Out);
|
||||||
JumpIf(Flags.NotEqual, "DebugStub_ExecutingStepOutAfter");
|
JumpIf(Flags.NotEqual, "DebugStub_ExecutingStepOutAfter");
|
||||||
|
|
||||||
EAX = Memory["DebugEBP", 32]; // TODO: X# Allow memory object instead of string, maybe the Datamember object itself. ie EAX = DebugEBP, and below inside Compare
|
EAX = Memory["DebugStub_OldEBP", 32]; // TODO: X# Allow memory object instead of string, maybe the Datamember object itself. ie EAX = DebugEBP, and below inside Compare
|
||||||
EAX.Compare(Memory["DebugBreakEBP", 32]); // TODO: X# JumpIf(EAX == Memory[...... or better yet if(EAX==Memory..., new Delegate { Jump.... Jump should be handled specially so we dont jump around jumps... TODO: Also allow Compare(EAX, 0), in fact force this new syntax
|
EAX.Compare(Memory["DebugBreakEBP", 32]); // TODO: X# JumpIf(EAX == Memory[...... or better yet if(EAX==Memory..., new Delegate { Jump.... Jump should be handled specially so we dont jump around jumps... TODO: Also allow Compare(EAX, 0), in fact force this new syntax
|
||||||
JumpIf(Flags.Equal, "DebugStub_Executing_Normal");
|
JumpIf(Flags.Equal, "DebugStub_Executing_Normal");
|
||||||
CallIf(Flags.LessThanOrEqualTo, "DebugStub_Break");
|
CallIf(Flags.LessThanOrEqualTo, "DebugStub_Break");
|
||||||
|
|
@ -584,7 +584,7 @@ namespace Cosmos.Compiler.DebugStub {
|
||||||
JumpIf(Flags.NotEqual, "DebugStub_Break_StepOver_After");
|
JumpIf(Flags.NotEqual, "DebugStub_Break_StepOver_After");
|
||||||
Memory["DebugBreakOnNextTrace", 32] = StepTrigger.Over;
|
Memory["DebugBreakOnNextTrace", 32] = StepTrigger.Over;
|
||||||
// TODO: Change this so ,32 is not necessary, can be implied by 32 bit register - ie Memory["DebugBreakEBP", 32] = EBP;
|
// TODO: Change this so ,32 is not necessary, can be implied by 32 bit register - ie Memory["DebugBreakEBP", 32] = EBP;
|
||||||
EAX = Memory["DebugEBP", 32];
|
EAX = Memory["DebugStub_OldEBP", 32];
|
||||||
Memory["DebugBreakEBP", 32] = EAX;
|
Memory["DebugBreakEBP", 32] = EAX;
|
||||||
Jump("DebugStub_Break_Exit");
|
Jump("DebugStub_Break_Exit");
|
||||||
Label = "DebugStub_Break_StepOver_After";
|
Label = "DebugStub_Break_StepOver_After";
|
||||||
|
|
@ -592,7 +592,7 @@ namespace Cosmos.Compiler.DebugStub {
|
||||||
AL.Compare(DsCommand.StepOut);
|
AL.Compare(DsCommand.StepOut);
|
||||||
JumpIf(Flags.NotEqual, "DebugStub_Break_StepOut_After");
|
JumpIf(Flags.NotEqual, "DebugStub_Break_StepOut_After");
|
||||||
Memory["DebugBreakOnNextTrace", 32] = StepTrigger.Out;
|
Memory["DebugBreakOnNextTrace", 32] = StepTrigger.Out;
|
||||||
EAX = Memory["DebugEBP", 32];
|
EAX = Memory["DebugStub_OldEBP", 32];
|
||||||
Memory["DebugBreakEBP", 32] = EAX;
|
Memory["DebugBreakEBP", 32] = EAX;
|
||||||
Jump("DebugStub_Break_Exit");
|
Jump("DebugStub_Break_Exit");
|
||||||
Label = "DebugStub_Break_StepOut_After";
|
Label = "DebugStub_Break_StepOut_After";
|
||||||
|
|
@ -605,7 +605,12 @@ namespace Cosmos.Compiler.DebugStub {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
protected DataMemberInt Test;
|
// Calling code's EBP value
|
||||||
|
protected DataMember32 OldEBP;
|
||||||
|
[XSharp]
|
||||||
|
public void Test() {
|
||||||
|
}
|
||||||
|
|
||||||
public class TracerEntry : CodeBlock {
|
public class TracerEntry : CodeBlock {
|
||||||
public override void Assemble() {
|
public override void Assemble() {
|
||||||
// Main entry point for the DebugStub which is executed at the
|
// Main entry point for the DebugStub which is executed at the
|
||||||
|
|
@ -613,7 +618,8 @@ namespace Cosmos.Compiler.DebugStub {
|
||||||
|
|
||||||
// EBP is restored by PopAll, but SendFrame uses it. Could
|
// EBP is restored by PopAll, but SendFrame uses it. Could
|
||||||
// get it from the PushAll data, but this is easier.
|
// get it from the PushAll data, but this is easier.
|
||||||
Memory["DebugEBP", 32] = EBP;
|
//Memory[OldEBP.Name, 32] = EBP;
|
||||||
|
Memory["DebugStub_OldEBP", 32] = EBP;
|
||||||
|
|
||||||
// Could also get ESP from PushAll but this is easier
|
// Could also get ESP from PushAll but this is easier
|
||||||
// Another reason to do it here is that soem day we may need to use
|
// Another reason to do it here is that soem day we may need to use
|
||||||
|
|
|
||||||
|
|
@ -33,8 +33,6 @@ namespace Cosmos.Compiler.DebugStub {
|
||||||
new DataMember("DebugResumeLevel", 0),
|
new DataMember("DebugResumeLevel", 0),
|
||||||
// Last EIP value
|
// Last EIP value
|
||||||
new DataMember("DebugEIP", 0),
|
new DataMember("DebugEIP", 0),
|
||||||
// Calling code's EBP value
|
|
||||||
new DataMember("DebugEBP", 0),
|
|
||||||
// Calling code's ESP value
|
// Calling code's ESP value
|
||||||
new DataMember("DebugESP", 0),
|
new DataMember("DebugESP", 0),
|
||||||
// Ptr to the push all data. It points to the "bottom" after a PushAll op.
|
// Ptr to the push all data. It points to the "bottom" after a PushAll op.
|
||||||
|
|
@ -125,7 +123,7 @@ namespace Cosmos.Compiler.DebugStub {
|
||||||
// now ECX contains size of data (count)
|
// now ECX contains size of data (count)
|
||||||
// EAX contains relative to EBP
|
// EAX contains relative to EBP
|
||||||
Label = "DebugStub_SendMethodContext2";
|
Label = "DebugStub_SendMethodContext2";
|
||||||
ESI = Memory["DebugEBP", 32];
|
ESI = Memory["DebugStub_OldEBP", 32];
|
||||||
ESI.Add(EAX);
|
ESI.Add(EAX);
|
||||||
|
|
||||||
Label = "DebugStub_SendMethodContext_SendByte";
|
Label = "DebugStub_SendMethodContext_SendByte";
|
||||||
|
|
|
||||||
|
|
@ -12,6 +12,7 @@ namespace Cosmos.Compiler.XSharp {
|
||||||
var xThisType = this.GetType();
|
var xThisType = this.GetType();
|
||||||
var xAsm = Assembler.Assembler.CurrentInstance;
|
var xAsm = Assembler.Assembler.CurrentInstance;
|
||||||
|
|
||||||
|
// Generate DataMembers
|
||||||
foreach (var xMember in xThisType.GetFields(BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic)) {
|
foreach (var xMember in xThisType.GetFields(BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic)) {
|
||||||
if (xMember.FieldType.IsSubclassOf(typeof(DataMember))) {
|
if (xMember.FieldType.IsSubclassOf(typeof(DataMember))) {
|
||||||
var xCtor = xMember.FieldType.GetConstructor(new Type[] { typeof(string) });
|
var xCtor = xMember.FieldType.GetConstructor(new Type[] { typeof(string) });
|
||||||
|
|
@ -21,6 +22,7 @@ namespace Cosmos.Compiler.XSharp {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Genereate code
|
||||||
foreach (var xType in xThisType.GetNestedTypes()) {
|
foreach (var xType in xThisType.GetNestedTypes()) {
|
||||||
if (xType.IsSubclassOf(typeof(CodeBlock))) {
|
if (xType.IsSubclassOf(typeof(CodeBlock))) {
|
||||||
var xCtor = xType.GetConstructor(new Type[0]);
|
var xCtor = xType.GetConstructor(new Type[0]);
|
||||||
|
|
|
||||||
|
|
@ -70,6 +70,7 @@
|
||||||
<Compile Include="AddressDirect.cs" />
|
<Compile Include="AddressDirect.cs" />
|
||||||
<Compile Include="AddressIndirect.cs" />
|
<Compile Include="AddressIndirect.cs" />
|
||||||
<Compile Include="CodeGroup.cs" />
|
<Compile Include="CodeGroup.cs" />
|
||||||
|
<Compile Include="InteruptHandlerAttribute.cs" />
|
||||||
<Compile Include="Memory.cs" />
|
<Compile Include="Memory.cs" />
|
||||||
<Compile Include="MemoryAction.cs" />
|
<Compile Include="MemoryAction.cs" />
|
||||||
<Compile Include="PortNumber.cs" />
|
<Compile Include="PortNumber.cs" />
|
||||||
|
|
@ -92,6 +93,7 @@
|
||||||
<Compile Include="RegisterESI.cs" />
|
<Compile Include="RegisterESI.cs" />
|
||||||
<Compile Include="RegisterESP.cs" />
|
<Compile Include="RegisterESP.cs" />
|
||||||
<Compile Include="CodeBlock.cs" />
|
<Compile Include="CodeBlock.cs" />
|
||||||
|
<Compile Include="XSharpAttribute.cs" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<ProjectReference Include="..\Cosmos.Compiler.Assembler.X86\Cosmos.Compiler.Assembler.X86.csproj">
|
<ProjectReference Include="..\Cosmos.Compiler.Assembler.X86\Cosmos.Compiler.Assembler.X86.csproj">
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,12 @@
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
|
||||||
|
namespace Cosmos.Compiler.XSharp {
|
||||||
|
|
||||||
|
[AttributeUsage(AttributeTargets.Method, AllowMultiple = false, Inherited = false)]
|
||||||
|
public class InteruptHandlerAttribute : Attribute {
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
13
source2/Compiler/Cosmos.Compiler.XSharp/XSharpAttribute.cs
Normal file
13
source2/Compiler/Cosmos.Compiler.XSharp/XSharpAttribute.cs
Normal file
|
|
@ -0,0 +1,13 @@
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
|
||||||
|
namespace Cosmos.Compiler.XSharp {
|
||||||
|
|
||||||
|
[AttributeUsage(AttributeTargets.Method, AllowMultiple = false, Inherited = false)]
|
||||||
|
public class XSharpAttribute : Attribute {
|
||||||
|
public bool InteruptHandler { get; set; }
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
Loading…
Reference in a new issue