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");
AL.Compare(4);
JumpIf(Flags.Equal, "DebugStub_Break");
Jump("DebugStub_Exit");
}
Return();
protected void TraceOff() {
Label = "DebugStub_TraceOff";
Memory["DebugTraceMode", 32] = 0;
Jump("DebugStub_Exit");
}
Return();
protected void TraceOn() {
Label = "DebugStub_TraceOn";
Memory["DebugTraceMode", 32] = 1;
Jump("DebugStub_Exit");
}
Return();
Label = "DebugStub_Step";
Memory["DebugTraceMode", 32] = 4;
Return();
protected void Break() {
Label = "DebugStub_Break";
Memory["DebugTraceMode", 32] = 4;
Call("DebugPoint_WaitCmd");
Jump("DebugPoint_ProcessCmd");
}
protected void Step() {
Label = "DebugStub_Step";
Memory["DebugTraceMode", 32] = 4;
Jump("DebugStub_Exit");
}
protected void SendTrace() {
Label = "SendTrace";
AL = Memory[EBP + 3];
@ -97,21 +89,23 @@ namespace Indy.IL2CPU.Assembler.X86 {
Return();
}
public void Main(UInt16 aComAddr) {
mComAddr = aComAddr;
mComStatusAddr = (UInt16)(aComAddr + 5);
// Assembler.GetIdentifier
protected void Emit() {
ProcessCmd();
TraceOff();
TraceOn();
Break();
Step();
SendTrace();
WriteByteToDebugger();
WaitCmd();
DebugSuspend();
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");
//"DebugStatus dd 0");
@ -124,28 +118,25 @@ namespace Indy.IL2CPU.Assembler.X86 {
// Check DebugTraceMode
EAX = Memory["DebugTraceMode"];
//TODO: Change this to support CallIf(AX == 0, "SendTrace");
AL.Compare(0);
JumpIf(Flags.Equal, "DebugPoint_NoTrace");
Call("SendTrace");
CallIf(Flags.NotEqual, "SendTrace");
EAX = Memory["DebugTraceMode"];
AL.Compare(4);
JumpIf(Flags.NotEqual, "DebugPoint_NoTrace");
Call("DebugPoint_WaitCmd");
Jump("DebugPoint_ProcessCmd");
Label = "DebugPoint_NoTrace";
//EAX = Memory["DebugTraceMode"];
//AL.Compare(4);
//JumpIf(Flags.NotEqual, "DebugPoint_NoBreak");
// Call("DebugStub_Break");
// Jump("DebugStub_Exit");
//Label = "DebugPoint_NoBreak";
// Is there a new incoming command?
Label = "DebugPoint_CheckCmd";
DX = mComStatusAddr;
AL = Port[DX];
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";
PopAll32();
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) {
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) {
new X86.Jump(aLabel);
}

View file

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