Tracing works, but stepping is broken currently.

This commit is contained in:
kudzu_cp 2008-04-28 15:27:14 +00:00
parent afcf944ff1
commit 9739ca604c
3 changed files with 50 additions and 37 deletions

View file

@ -20,34 +20,26 @@ namespace Indy.IL2CPU.Assembler.X86 {
JumpIf(Flags.Equal, "DebugStub_Step"); JumpIf(Flags.Equal, "DebugStub_Step");
AL.Compare(4); AL.Compare(4);
JumpIf(Flags.Equal, "DebugStub_Break"); JumpIf(Flags.Equal, "DebugStub_Break");
Jump("DebugStub_Exit"); Return();
}
protected void TraceOff() {
Label = "DebugStub_TraceOff"; Label = "DebugStub_TraceOff";
Memory["DebugTraceMode", 32] = 0; Memory["DebugTraceMode", 32] = 0;
Jump("DebugStub_Exit"); Return();
}
protected void TraceOn() {
Label = "DebugStub_TraceOn"; Label = "DebugStub_TraceOn";
Memory["DebugTraceMode", 32] = 1; Memory["DebugTraceMode", 32] = 1;
Jump("DebugStub_Exit"); Return();
}
Label = "DebugStub_Step";
Memory["DebugTraceMode", 32] = 4;
Return();
protected void Break() {
Label = "DebugStub_Break"; Label = "DebugStub_Break";
Memory["DebugTraceMode", 32] = 4; Memory["DebugTraceMode", 32] = 4;
Call("DebugPoint_WaitCmd"); Call("DebugPoint_WaitCmd");
Jump("DebugPoint_ProcessCmd"); Jump("DebugPoint_ProcessCmd");
} }
protected void Step() {
Label = "DebugStub_Step";
Memory["DebugTraceMode", 32] = 4;
Jump("DebugStub_Exit");
}
protected void SendTrace() { protected void SendTrace() {
Label = "SendTrace"; Label = "SendTrace";
AL = Memory[EBP + 3]; AL = Memory[EBP + 3];
@ -97,21 +89,23 @@ namespace Indy.IL2CPU.Assembler.X86 {
Return(); Return();
} }
public void Main(UInt16 aComAddr) { protected void Emit() {
mComAddr = aComAddr;
mComStatusAddr = (UInt16)(aComAddr + 5);
// Assembler.GetIdentifier
ProcessCmd(); ProcessCmd();
TraceOff();
TraceOn();
Break();
Step();
SendTrace(); SendTrace();
WriteByteToDebugger(); WriteByteToDebugger();
WaitCmd(); WaitCmd();
DebugSuspend(); DebugSuspend();
DebugResume(); DebugResume();
}
public void Main(UInt16 aComAddr) {
mComAddr = aComAddr;
mComStatusAddr = (UInt16)(aComAddr + 5);
Emit();
// For Unique Labels
// Assembler.GetIdentifier
// For System..Break
// public class BreakAssembler: AssemblerMethod
//"DebugTraceMode dd 1"); //"DebugTraceMode dd 1");
//"DebugStatus dd 0"); //"DebugStatus dd 0");
@ -124,28 +118,25 @@ namespace Indy.IL2CPU.Assembler.X86 {
// Check DebugTraceMode // Check DebugTraceMode
EAX = Memory["DebugTraceMode"]; EAX = Memory["DebugTraceMode"];
//TODO: Change this to support CallIf(AX == 0, "SendTrace");
AL.Compare(0); AL.Compare(0);
JumpIf(Flags.Equal, "DebugPoint_NoTrace"); CallIf(Flags.NotEqual, "SendTrace");
Call("SendTrace");
EAX = Memory["DebugTraceMode"]; //EAX = Memory["DebugTraceMode"];
AL.Compare(4); //AL.Compare(4);
JumpIf(Flags.NotEqual, "DebugPoint_NoTrace"); //JumpIf(Flags.NotEqual, "DebugPoint_NoBreak");
Call("DebugPoint_WaitCmd"); // Call("DebugStub_Break");
Jump("DebugPoint_ProcessCmd"); // Jump("DebugStub_Exit");
Label = "DebugPoint_NoTrace"; //Label = "DebugPoint_NoBreak";
// Is there a new incoming command? // Is there a new incoming command?
Label = "DebugPoint_CheckCmd"; Label = "DebugPoint_CheckCmd";
DX = mComStatusAddr; DX = mComStatusAddr;
AL = Port[DX]; AL = Port[DX];
AL.Test(0x01); AL.Test(0x01);
CallIf(Flags.NotZero, "DebugPoint_ProcessCmd");
//separate command structure, when in break Wait for unbreak only but process others
JumpIf(Flags.Zero, "DebugStub_Exit");
Jump("DebugPoint_ProcessCmd");
Label = "DebugStub_Exit"; Label = "DebugStub_Exit";
PopAll32(); PopAll32();
Return(); Return();
} }

View file

@ -28,10 +28,31 @@ namespace Indy.IL2CPU.Assembler.X86.X {
} }
} }
private uint mLabelCounter = 0;
public string NewLabel() {
mLabelCounter++;
return GetType().Name + mLabelCounter.ToString("X8").ToUpper();
}
public void Call(string aLabel) { public void Call(string aLabel) {
new X86.Call(aLabel); new X86.Call(aLabel);
} }
public void CallIf(Flags aFlags, string aLabel) {
// TODO: This is inefficient - lots of jumps
// Maybe make an invert function for Flags
var xLabelIf = NewLabel();
var xLabelExit = NewLabel();
JumpIf(aFlags, xLabelIf);
Jump(xLabelExit);
Label = xLabelIf;
Call(aLabel);
Label = xLabelExit;
}
public void Jump(string aLabel) { public void Jump(string aLabel) {
new X86.Jump(aLabel); new X86.Jump(aLabel);
} }

View file

@ -85,7 +85,8 @@ namespace Indy.IL2CPU.Assembler {
private uint mDataMemberCounter = 0; private uint mDataMemberCounter = 0;
public string GetIdentifier(string aPrefix) { public string GetIdentifier(string aPrefix) {
return aPrefix + mDataMemberCounter++.ToString("X8").ToUpper(); mDataMemberCounter++;
return aPrefix + mDataMemberCounter.ToString("X8").ToUpper();
} }
public Assembler(Func<string, string> aGetStreamForGroup) public Assembler(Func<string, string> aGetStreamForGroup)