This commit is contained in:
kudzu_cp 2011-07-17 05:01:14 +00:00
parent b74dd21e3c
commit bfa405335d
7 changed files with 47 additions and 14 deletions

View file

@ -284,8 +284,8 @@ namespace Cosmos.Compiler.Assembler {
// This is the new type of DataMember, eventually we can eliminate many of the
// code in DataMember (base)
public class DataMemberInt : DataMember {
public DataMemberInt(string aName) : base(aName) {
public class DataMember32 : DataMember {
public DataMember32(string aName) : base(aName) {
int[] xValue = { 0 };
UntypedDefaultValue = xValue.Cast<object>().ToArray();
}

View file

@ -316,7 +316,7 @@ namespace Cosmos.Compiler.DebugStub {
EAX = (uint)xCount;
Call<DebugStub.WriteAXToComPort>();
ESI = Memory["DebugEBP", 32];
ESI = Memory["DebugStub_OldEBP", 32];
ESI.Add(8); // Dont transmit EIP or old EBP
for (int i = 1; i <= xCount; i++) {
Call("WriteByteToComPort");
@ -331,7 +331,7 @@ namespace Cosmos.Compiler.DebugStub {
// Send size of bytes
ESI = Memory["DebugESP", 32];
EAX = Memory["DebugEBP", 32];
EAX = Memory["DebugStub_OldEBP", 32];
EAX.Sub(ESI);
Call<DebugStub.WriteAXToComPort>();
@ -340,7 +340,7 @@ namespace Cosmos.Compiler.DebugStub {
// Need to reload ESI, WriteAXToCompPort modifies it
ESI = Memory["DebugESP", 32];
Label = "DebugStub_SendStack_SendByte";
ESI.Compare(Memory["DebugEBP", 32]);
ESI.Compare(Memory["DebugStub_OldEBP", 32]);
JumpIf(Flags.Equal, "DebugStub_SendStack_Exit");
Call("WriteByteToComPort");
Jump("DebugStub_SendStack_SendByte");
@ -492,7 +492,7 @@ namespace Cosmos.Compiler.DebugStub {
Memory["DebugBreakOnNextTrace", 32].Compare(StepTrigger.Over);
JumpIf(Flags.NotEqual, "DebugStub_ExecutingStepOverAfter");
Label = "Debug__StepOver__";
EAX = Memory["DebugEBP", 32];
EAX = Memory["DebugStub_OldEBP", 32];
EAX.Compare(Memory["DebugBreakEBP", 32]);
// If EBP and start EBP arent equal, dont break
// 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);
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
JumpIf(Flags.Equal, "DebugStub_Executing_Normal");
CallIf(Flags.LessThanOrEqualTo, "DebugStub_Break");
@ -584,7 +584,7 @@ namespace Cosmos.Compiler.DebugStub {
JumpIf(Flags.NotEqual, "DebugStub_Break_StepOver_After");
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;
EAX = Memory["DebugEBP", 32];
EAX = Memory["DebugStub_OldEBP", 32];
Memory["DebugBreakEBP", 32] = EAX;
Jump("DebugStub_Break_Exit");
Label = "DebugStub_Break_StepOver_After";
@ -592,7 +592,7 @@ namespace Cosmos.Compiler.DebugStub {
AL.Compare(DsCommand.StepOut);
JumpIf(Flags.NotEqual, "DebugStub_Break_StepOut_After");
Memory["DebugBreakOnNextTrace", 32] = StepTrigger.Out;
EAX = Memory["DebugEBP", 32];
EAX = Memory["DebugStub_OldEBP", 32];
Memory["DebugBreakEBP", 32] = EAX;
Jump("DebugStub_Break_Exit");
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 override void Assemble() {
// 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
// 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
// Another reason to do it here is that soem day we may need to use

View file

@ -33,8 +33,6 @@ namespace Cosmos.Compiler.DebugStub {
new DataMember("DebugResumeLevel", 0),
// Last EIP value
new DataMember("DebugEIP", 0),
// Calling code's EBP value
new DataMember("DebugEBP", 0),
// Calling code's ESP value
new DataMember("DebugESP", 0),
// 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)
// EAX contains relative to EBP
Label = "DebugStub_SendMethodContext2";
ESI = Memory["DebugEBP", 32];
ESI = Memory["DebugStub_OldEBP", 32];
ESI.Add(EAX);
Label = "DebugStub_SendMethodContext_SendByte";

View file

@ -12,6 +12,7 @@ namespace Cosmos.Compiler.XSharp {
var xThisType = this.GetType();
var xAsm = Assembler.Assembler.CurrentInstance;
// Generate DataMembers
foreach (var xMember in xThisType.GetFields(BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic)) {
if (xMember.FieldType.IsSubclassOf(typeof(DataMember))) {
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()) {
if (xType.IsSubclassOf(typeof(CodeBlock))) {
var xCtor = xType.GetConstructor(new Type[0]);

View file

@ -70,6 +70,7 @@
<Compile Include="AddressDirect.cs" />
<Compile Include="AddressIndirect.cs" />
<Compile Include="CodeGroup.cs" />
<Compile Include="InteruptHandlerAttribute.cs" />
<Compile Include="Memory.cs" />
<Compile Include="MemoryAction.cs" />
<Compile Include="PortNumber.cs" />
@ -92,6 +93,7 @@
<Compile Include="RegisterESI.cs" />
<Compile Include="RegisterESP.cs" />
<Compile Include="CodeBlock.cs" />
<Compile Include="XSharpAttribute.cs" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\Cosmos.Compiler.Assembler.X86\Cosmos.Compiler.Assembler.X86.csproj">

View file

@ -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 {
}
}

View 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; }
}
}