This commit is contained in:
kudzu_cp 2012-07-10 18:53:48 +00:00
parent 48622a9f56
commit b32a756cd8
4 changed files with 180 additions and 129 deletions

View file

@ -34,52 +34,74 @@ namespace Cosmos.Debug.DebugStub {
new Comment("X#: }"); new Comment("X#: }");
new LiteralAssemblerCode("DebugStub_SendRegisters_Exit:"); new LiteralAssemblerCode("DebugStub_SendRegisters_Exit:");
new LiteralAssemblerCode("Ret"); new LiteralAssemblerCode("Ret");
new LiteralAssemblerCode("; procedure SendFrame2 {"); new Comment("X#: procedure SendFrame2 {");
new LiteralAssemblerCode("; AL = (int)Ds2Vs.Frame"); new LiteralAssemblerCode("DebugStub_SendFrame2:");
new LiteralAssemblerCode("; Call(\"DebugStub_ComWriteAL\")"); new Comment("X#: AL = #Ds2Vs_Frame");
new LiteralAssemblerCode("Mov AL, DebugStub_Const_Ds2Vs_Frame");
new Comment("X#: ComWriteAL()");
new LiteralAssemblerCode("Call DebugStub_ComWriteAL");
new Comment("X#: EAX = 32");
new LiteralAssemblerCode("Mov EAX, 32");
new Comment("X#: ComWriteAX()");
new LiteralAssemblerCode("Call DebugStub_ComWriteAX");
new Comment("X#: ESI = .CallerEBP");
new LiteralAssemblerCode("Mov ESI, [DebugStub_CallerEBP]");
new LiteralAssemblerCode("; Dont transmit EIP or old EBP");
new Comment("X#: ESI + 8");
new LiteralAssemblerCode("Add ESI, 8");
new Comment("X#: ECX = 32");
new LiteralAssemblerCode("Mov ECX, 32");
new Comment("X#: ComWriteX()");
new LiteralAssemblerCode("Call DebugStub_ComWriteX");
new Comment("X#: }");
new LiteralAssemblerCode("DebugStub_SendFrame2_Exit:");
new LiteralAssemblerCode("Ret");
new Comment("X#: procedure SendStack2 {");
new LiteralAssemblerCode("DebugStub_SendStack2:");
new Comment("X#: AL = #Ds2Vs_Stack");
new LiteralAssemblerCode("Mov AL, DebugStub_Const_Ds2Vs_Stack");
new Comment("X#: ComWriteAL()");
new LiteralAssemblerCode("Call DebugStub_ComWriteAL");
new LiteralAssemblerCode("; Send size of bytes");
new Comment("X#: ESI = .CallerESP");
new LiteralAssemblerCode("Mov ESI, [DebugStub_CallerESP]");
new Comment("X#: EAX = .CallerEBP");
new LiteralAssemblerCode("Mov EAX, [DebugStub_CallerEBP]");
new Comment("X#: EAX - ESI");
new LiteralAssemblerCode("Sub EAX, ESI");
new Comment("X#: ComWriteAX()");
new LiteralAssemblerCode("Call DebugStub_ComWriteAX");
new LiteralAssemblerCode("; Send actual bytes");
new LiteralAssemblerCode("; "); new LiteralAssemblerCode("; ");
new LiteralAssemblerCode("; EAX = 32"); new LiteralAssemblerCode("; Need to reload ESI, WriteAXToCompPort modifies it");
new LiteralAssemblerCode("; Call(\"DebugStub_ComWriteAX\")"); new Comment("X#: ESI = .CallerESP");
new LiteralAssemblerCode("; "); new LiteralAssemblerCode("Mov ESI, [DebugStub_CallerESP]");
new LiteralAssemblerCode("; ESI = CallerEBP.Value"); new Comment("X#: SendByte:");
new LiteralAssemblerCode("; ESI.Add(8) // Dont transmit EIP or old EBP"); new LiteralAssemblerCode("DebugStub_SendStack2_SendByte:");
new LiteralAssemblerCode("; ECX = 32"); new LiteralAssemblerCode("; if ESI = CallerEBP exit");
new LiteralAssemblerCode("; Call(\"DebugStub_ComWriteX\")"); new Comment("X#: ComWrite8()");
new LiteralAssemblerCode("; }"); new LiteralAssemblerCode("Call DebugStub_ComWrite8");
new LiteralAssemblerCode("; procedure SendStack2 {"); new Comment("X#: goto SendByte");
new LiteralAssemblerCode("; AL = (int)Ds2Vs.Stack"); new LiteralAssemblerCode("Jp DebugStub_SendStack2_SendByte");
new LiteralAssemblerCode("; Call(\"DebugStub_ComWriteAL\")"); new Comment("X#: }");
new LiteralAssemblerCode("; "); new LiteralAssemblerCode("DebugStub_SendStack2_Exit:");
new LiteralAssemblerCode("; // Send size of bytes"); new LiteralAssemblerCode("Ret");
new LiteralAssemblerCode("; ESI = CallerESP.Value"); new Comment("X#: procedure SendMethodContext2 {");
new LiteralAssemblerCode("; EAX = CallerEBP.Value"); new LiteralAssemblerCode("DebugStub_SendMethodContext2:");
new LiteralAssemblerCode("; EAX.Sub(ESI)");
new LiteralAssemblerCode("; Call(\"DebugStub_ComWriteAX\")");
new LiteralAssemblerCode("; ");
new LiteralAssemblerCode("; // Send actual bytes");
new LiteralAssemblerCode("; //");
new LiteralAssemblerCode("; // Need to reload ESI, WriteAXToCompPort modifies it");
new LiteralAssemblerCode("; ESI = CallerESP.Value");
new LiteralAssemblerCode("; Label = \".SendByte\"");
new LiteralAssemblerCode("; ESI.Compare(CallerEBP.Value)");
new LiteralAssemblerCode("; JumpIf(Flags.Equal, \".Exit\")");
new LiteralAssemblerCode("; Call(\"DebugStub_ComWrite8\")");
new LiteralAssemblerCode("; Jump(\".SendByte\")");
new LiteralAssemblerCode("; }");
new LiteralAssemblerCode("; procedure SendMethodContext2 {");
new LiteralAssemblerCode("; // sends a stack value"); new LiteralAssemblerCode("; // sends a stack value");
new LiteralAssemblerCode("; // Serial Params:"); new LiteralAssemblerCode("; // Serial Params:");
new LiteralAssemblerCode("; // 1: x32 - offset relative to EBP"); new LiteralAssemblerCode("; // 1: x32 - offset relative to EBP");
new LiteralAssemblerCode("; // 2: x32 - size of data to send"); new LiteralAssemblerCode("; // 2: x32 - size of data to send");
new LiteralAssemblerCode("; [XSharp(PreserveStack = true)]"); new LiteralAssemblerCode("; [XSharp(PreserveStack = true)]");
new LiteralAssemblerCode("; AL = (int)Ds2Vs.MethodContext"); new LiteralAssemblerCode("; AL = Ds2Vs_MethodContext");
new LiteralAssemblerCode("; Call(\"DebugStub_ComWriteAL\")"); new Comment("X#: ComWriteAL()");
new LiteralAssemblerCode("Call DebugStub_ComWriteAL");
new LiteralAssemblerCode("; "); new LiteralAssemblerCode("; ");
new LiteralAssemblerCode("; // offset relative to ebp"); new LiteralAssemblerCode("; // offset relative to ebp");
new LiteralAssemblerCode("; // size of data to send"); new LiteralAssemblerCode("; // size of data to send");
new LiteralAssemblerCode("; Call(\"DebugStub_ComReadEAX\")"); new LiteralAssemblerCode("; Call(\"DebugStub_ComReadEAX()");
new LiteralAssemblerCode("; ECX = EAX"); new LiteralAssemblerCode("; ECX = EAX");
new LiteralAssemblerCode("; Call(\"DebugStub_ComReadEAX\")"); new LiteralAssemblerCode("; Call(\"DebugStub_ComReadEAX()");
new LiteralAssemblerCode("; "); new LiteralAssemblerCode("; ");
new LiteralAssemblerCode("; // now ECX contains size of data (count)"); new LiteralAssemblerCode("; // now ECX contains size of data (count)");
new LiteralAssemblerCode("; // EAX contains relative to EBP"); new LiteralAssemblerCode("; // EAX contains relative to EBP");
@ -89,24 +111,29 @@ namespace Cosmos.Debug.DebugStub {
new LiteralAssemblerCode("; Label = \".SendByte\""); new LiteralAssemblerCode("; Label = \".SendByte\"");
new LiteralAssemblerCode("; ECX.Compare(0)"); new LiteralAssemblerCode("; ECX.Compare(0)");
new LiteralAssemblerCode("; JumpIf(Flags.Equal, \".AfterSendByte\")"); new LiteralAssemblerCode("; JumpIf(Flags.Equal, \".AfterSendByte\")");
new LiteralAssemblerCode("; Call(\"DebugStub_ComWrite8\")"); new Comment("X#: ComWrite8()");
new LiteralAssemblerCode("Call DebugStub_ComWrite8");
new LiteralAssemblerCode("; ECX--"); new LiteralAssemblerCode("; ECX--");
new LiteralAssemblerCode("; Jump(\".SendByte\")"); new LiteralAssemblerCode("; Jump(\".SendByte\")");
new LiteralAssemblerCode("; Label = \".AfterSendByte\""); new LiteralAssemblerCode("; Label = \".AfterSendByte\"");
new LiteralAssemblerCode("; }"); new Comment("X#: }");
new LiteralAssemblerCode("; procedure SendMemory2 {"); new LiteralAssemblerCode("DebugStub_SendMethodContext2_Exit:");
new LiteralAssemblerCode("Ret");
new Comment("X#: procedure SendMemory2 {");
new LiteralAssemblerCode("DebugStub_SendMemory2:");
new LiteralAssemblerCode("; // sends a stack value"); new LiteralAssemblerCode("; // sends a stack value");
new LiteralAssemblerCode("; // Serial Params:"); new LiteralAssemblerCode("; // Serial Params:");
new LiteralAssemblerCode("; // 1: x32 - offset relative to EBP"); new LiteralAssemblerCode("; // 1: x32 - offset relative to EBP");
new LiteralAssemblerCode("; // 2: x32 - size of data to send"); new LiteralAssemblerCode("; // 2: x32 - size of data to send");
new LiteralAssemblerCode("; [XSharp(PreserveStack = true)]"); new LiteralAssemblerCode("; [XSharp(PreserveStack = true)]");
new LiteralAssemblerCode("; procedure"); new LiteralAssemblerCode("; procedure");
new LiteralAssemblerCode("; Call(\"DebugStub_ComReadEAX\")"); new LiteralAssemblerCode("; Call(\"DebugStub_ComReadEAX()");
new LiteralAssemblerCode("; ECX = EAX"); new LiteralAssemblerCode("; ECX = EAX");
new LiteralAssemblerCode("; AL = (int)Ds2Vs.MemoryData"); new LiteralAssemblerCode("; AL = Ds2Vs_MemoryData");
new LiteralAssemblerCode("; Call(\"DebugStub_ComWriteAL\")"); new Comment("X#: ComWriteAL()");
new LiteralAssemblerCode("Call DebugStub_ComWriteAL");
new LiteralAssemblerCode("; "); new LiteralAssemblerCode("; ");
new LiteralAssemblerCode("; Call(\"DebugStub_ComReadEAX\")"); new LiteralAssemblerCode("; Call(\"DebugStub_ComReadEAX()");
new LiteralAssemblerCode("; ESI = EAX"); new LiteralAssemblerCode("; ESI = EAX");
new LiteralAssemblerCode("; "); new LiteralAssemblerCode("; ");
new LiteralAssemblerCode("; // now ECX contains size of data (count)"); new LiteralAssemblerCode("; // now ECX contains size of data (count)");
@ -115,68 +142,85 @@ namespace Cosmos.Debug.DebugStub {
new LiteralAssemblerCode("; Label = \"DebugStub_SendMemory_SendByte\""); new LiteralAssemblerCode("; Label = \"DebugStub_SendMemory_SendByte\"");
new LiteralAssemblerCode("; new Compare { DestinationReg = Registers.ECX, SourceValue = 0 }"); new LiteralAssemblerCode("; new Compare { DestinationReg = Registers.ECX, SourceValue = 0 }");
new LiteralAssemblerCode("; JumpIf(Flags.Equal, \"DebugStub_SendMemory_After_SendByte\")"); new LiteralAssemblerCode("; JumpIf(Flags.Equal, \"DebugStub_SendMemory_After_SendByte\")");
new LiteralAssemblerCode("; Call(\"DebugStub_ComWrite8\")"); new Comment("X#: ComWrite8()");
new LiteralAssemblerCode("Call DebugStub_ComWrite8");
new LiteralAssemblerCode("; ECX--"); new LiteralAssemblerCode("; ECX--");
new LiteralAssemblerCode("; Jump(\"DebugStub_SendMemory_SendByte\")"); new LiteralAssemblerCode("; Jump(\"DebugStub_SendMemory_SendByte\")");
new LiteralAssemblerCode("; "); new LiteralAssemblerCode("; ");
new LiteralAssemblerCode("; Label = \"DebugStub_SendMemory_After_SendByte\""); new LiteralAssemblerCode("; Label = \"DebugStub_SendMemory_After_SendByte\"");
new LiteralAssemblerCode("; }"); new LiteralAssemblerCode("; }");
new LiteralAssemblerCode("; }"); new Comment("X#: }");
new LiteralAssemblerCode("; procedure SendTrace2 {"); new LiteralAssemblerCode("DebugStub_SendMemory2_Exit:");
new LiteralAssemblerCode("Ret");
new Comment("X#: procedure SendTrace2 {");
new LiteralAssemblerCode("DebugStub_SendTrace2:");
new LiteralAssemblerCode("; // Modifies: EAX, ESI"); new LiteralAssemblerCode("; // Modifies: EAX, ESI");
new LiteralAssemblerCode("; DebugStatus.Value.Compare(Status.Run)"); new LiteralAssemblerCode("; DebugStatus.Value.Compare(Status.Run)");
new LiteralAssemblerCode("; JumpIf(Flags.Equal, \".Normal\")"); new LiteralAssemblerCode("; JumpIf(Flags.Equal, \".Normal\")");
new LiteralAssemblerCode("; AL = (int)Ds2Vs.BreakPoint"); new LiteralAssemblerCode("; AL = Ds2Vs_BreakPoint");
new LiteralAssemblerCode("; Jump(\".Type\")"); new LiteralAssemblerCode("; Jump(\".Type\")");
new LiteralAssemblerCode("; "); new LiteralAssemblerCode("; ");
new LiteralAssemblerCode("; Label = \".Normal\""); new LiteralAssemblerCode("; Label = \".Normal\"");
new LiteralAssemblerCode("; AL = (int)Ds2Vs.TracePoint"); new LiteralAssemblerCode("; AL = Ds2Vs_TracePoint");
new LiteralAssemblerCode("; "); new LiteralAssemblerCode("; ");
new LiteralAssemblerCode("; Label = \".Type\""); new LiteralAssemblerCode("; Label = \".Type\"");
new LiteralAssemblerCode("; Call(\"DebugStub_ComWriteAL\")"); new Comment("X#: ComWriteAL()");
new LiteralAssemblerCode("Call DebugStub_ComWriteAL");
new LiteralAssemblerCode("; "); new LiteralAssemblerCode("; ");
new LiteralAssemblerCode("; // Send Calling EIP."); new LiteralAssemblerCode("; // Send Calling EIP.");
new LiteralAssemblerCode("; ESI = CallerEIP.Address"); new LiteralAssemblerCode("; ESI = CallerEIP.Address");
new LiteralAssemblerCode("; DebugStub_ComWrite32()"); new LiteralAssemblerCode("; DebugStub_ComWrite32()");
new LiteralAssemblerCode("; }"); new Comment("X#: }");
new LiteralAssemblerCode("; procedure SendText2 {"); new LiteralAssemblerCode("DebugStub_SendTrace2_Exit:");
new LiteralAssemblerCode("Ret");
new Comment("X#: procedure SendText2 {");
new LiteralAssemblerCode("DebugStub_SendText2:");
new LiteralAssemblerCode("; // Input: Stack"); new LiteralAssemblerCode("; // Input: Stack");
new LiteralAssemblerCode("; // Output: None"); new LiteralAssemblerCode("; // Output: None");
new LiteralAssemblerCode("; // Modifies: EAX, ECX, EDX, ESI"); new LiteralAssemblerCode("; // Modifies: EAX, ECX, EDX, ESI");
new LiteralAssemblerCode("; // Write the type"); new LiteralAssemblerCode("; // Write the type");
new LiteralAssemblerCode("; AL = (int)Ds2Vs.Message"); new LiteralAssemblerCode("; AL = Ds2Vs_Message");
new LiteralAssemblerCode("; Call(\"DebugStub_ComWriteAL\")"); new Comment("X#: ComWriteAL()");
new LiteralAssemblerCode("Call DebugStub_ComWriteAL");
new LiteralAssemblerCode("; "); new LiteralAssemblerCode("; ");
new LiteralAssemblerCode("; // Write Length"); new LiteralAssemblerCode("; // Write Length");
new LiteralAssemblerCode("; ESI = EBP"); new LiteralAssemblerCode("; ESI = EBP");
new LiteralAssemblerCode("; ESI = ESI + 12"); new LiteralAssemblerCode("; ESI = ESI + 12");
new LiteralAssemblerCode("; ECX = ESI[0]"); new LiteralAssemblerCode("; ECX = ESI[0]");
new LiteralAssemblerCode("; Call(\"DebugStub_ComWrite16\")"); new Comment("X#: ComWrite16()");
new LiteralAssemblerCode("Call DebugStub_ComWrite16");
new LiteralAssemblerCode("; "); new LiteralAssemblerCode("; ");
new LiteralAssemblerCode("; // Address of string"); new LiteralAssemblerCode("; // Address of string");
new LiteralAssemblerCode("; ESI = EBP[8]"); new LiteralAssemblerCode("; ESI = EBP[8]");
new LiteralAssemblerCode("; Label = \".WriteChar\""); new LiteralAssemblerCode("; Label = \".WriteChar\"");
new LiteralAssemblerCode("; ECX.Compare(0)"); new LiteralAssemblerCode("; ECX.Compare(0)");
new LiteralAssemblerCode("; JumpIf(Flags.Equal, \".Exit\")"); new LiteralAssemblerCode("; JumpIf(Flags.Equal, \".Exit\")");
new LiteralAssemblerCode("; Call(\"DebugStub_ComWrite8\")"); new Comment("X#: ComWrite8()");
new LiteralAssemblerCode("Call DebugStub_ComWrite8");
new LiteralAssemblerCode("; ECX--"); new LiteralAssemblerCode("; ECX--");
new LiteralAssemblerCode("; // We are storing as 16 bits, but for now I will transmit 8 bits"); new LiteralAssemblerCode("; // We are storing as 16 bits, but for now I will transmit 8 bits");
new LiteralAssemblerCode("; // So we inc again to skip the 0"); new LiteralAssemblerCode("; // So we inc again to skip the 0");
new LiteralAssemblerCode("; ESI++"); new LiteralAssemblerCode("; ESI++");
new LiteralAssemblerCode("; Jump(\".WriteChar\")"); new LiteralAssemblerCode("; Jump(\".WriteChar\")");
new LiteralAssemblerCode("; }"); new Comment("X#: }");
new LiteralAssemblerCode("; procedure SendPtr2 {"); new LiteralAssemblerCode("DebugStub_SendText2_Exit:");
new LiteralAssemblerCode("Ret");
new Comment("X#: procedure SendPtr2 {");
new LiteralAssemblerCode("DebugStub_SendPtr2:");
new LiteralAssemblerCode("; // Input: Stack"); new LiteralAssemblerCode("; // Input: Stack");
new LiteralAssemblerCode("; // Output: None"); new LiteralAssemblerCode("; // Output: None");
new LiteralAssemblerCode("; // Modifies: EAX, ECX, EDX, ESI"); new LiteralAssemblerCode("; // Modifies: EAX, ECX, EDX, ESI");
new LiteralAssemblerCode("; // Write the type"); new LiteralAssemblerCode("; // Write the type");
new LiteralAssemblerCode("; AL = (int)Ds2Vs.Pointer"); new LiteralAssemblerCode("; AL = Ds2Vs_Pointer");
new LiteralAssemblerCode("; Call(\"DebugStub_ComWriteAL\")"); new Comment("X#: ComWriteAL()");
new LiteralAssemblerCode("Call DebugStub_ComWriteAL");
new LiteralAssemblerCode("; "); new LiteralAssemblerCode("; ");
new LiteralAssemblerCode("; // pointer value"); new LiteralAssemblerCode("; // pointer value");
new LiteralAssemblerCode("; ESI = EBP[8]"); new LiteralAssemblerCode("; ESI = EBP[8]");
new LiteralAssemblerCode("; DebugStub_ComWrite32()"); new LiteralAssemblerCode("; DebugStub_ComWrite32()");
new LiteralAssemblerCode("; }"); new Comment("X#: }");
new LiteralAssemblerCode("DebugStub_SendPtr2_Exit:");
new LiteralAssemblerCode("Ret");
} }
} }
} }

View file

@ -16,54 +16,54 @@ procedure SendRegisters {
ComWrite32() ComWrite32()
} }
//procedure SendFrame2 { procedure SendFrame2 {
// AL = (int)Ds2Vs.Frame AL = #Ds2Vs_Frame
// Call("DebugStub_ComWriteAL") ComWriteAL()
//
// EAX = 32
// Call("DebugStub_ComWriteAX")
//
// ESI = CallerEBP.Value
// ESI.Add(8) // Dont transmit EIP or old EBP
// ECX = 32
// Call("DebugStub_ComWriteX")
//}
//procedure SendStack2 { EAX = 32
// AL = (int)Ds2Vs.Stack ComWriteAX()
// Call("DebugStub_ComWriteAL")
//
// // Send size of bytes
// ESI = CallerESP.Value
// EAX = CallerEBP.Value
// EAX.Sub(ESI)
// Call("DebugStub_ComWriteAX")
//
// // Send actual bytes
// //
// // Need to reload ESI, WriteAXToCompPort modifies it
// ESI = CallerESP.Value
// Label = ".SendByte"
// ESI.Compare(CallerEBP.Value)
// JumpIf(Flags.Equal, ".Exit")
// Call("DebugStub_ComWrite8")
// Jump(".SendByte")
//}
//procedure SendMethodContext2 { ESI = .CallerEBP
// Dont transmit EIP or old EBP
ESI + 8
ECX = 32
ComWriteX()
}
procedure SendStack2 {
AL = #Ds2Vs_Stack
ComWriteAL()
// Send size of bytes
ESI = .CallerESP
EAX = .CallerEBP
EAX - ESI
ComWriteAX()
// Send actual bytes
//
// Need to reload ESI, WriteAXToCompPort modifies it
ESI = .CallerESP
SendByte:
// if ESI = CallerEBP exit
ComWrite8()
goto SendByte
}
procedure SendMethodContext2 {
// // sends a stack value // // sends a stack value
// // Serial Params: // // Serial Params:
// // 1: x32 - offset relative to EBP // // 1: x32 - offset relative to EBP
// // 2: x32 - size of data to send // // 2: x32 - size of data to send
// [XSharp(PreserveStack = true)] // [XSharp(PreserveStack = true)]
// AL = (int)Ds2Vs.MethodContext // AL = Ds2Vs_MethodContext
// Call("DebugStub_ComWriteAL") ComWriteAL()
// //
// // offset relative to ebp // // offset relative to ebp
// // size of data to send // // size of data to send
// Call("DebugStub_ComReadEAX") // Call("DebugStub_ComReadEAX()
// ECX = EAX // ECX = EAX
// Call("DebugStub_ComReadEAX") // Call("DebugStub_ComReadEAX()
// //
// // now ECX contains size of data (count) // // now ECX contains size of data (count)
// // EAX contains relative to EBP // // EAX contains relative to EBP
@ -73,25 +73,25 @@ procedure SendRegisters {
// Label = ".SendByte" // Label = ".SendByte"
// ECX.Compare(0) // ECX.Compare(0)
// JumpIf(Flags.Equal, ".AfterSendByte") // JumpIf(Flags.Equal, ".AfterSendByte")
// Call("DebugStub_ComWrite8") ComWrite8()
// ECX-- // ECX--
// Jump(".SendByte") // Jump(".SendByte")
// Label = ".AfterSendByte" // Label = ".AfterSendByte"
//} }
//procedure SendMemory2 { procedure SendMemory2 {
// // sends a stack value // // sends a stack value
// // Serial Params: // // Serial Params:
// // 1: x32 - offset relative to EBP // // 1: x32 - offset relative to EBP
// // 2: x32 - size of data to send // // 2: x32 - size of data to send
// [XSharp(PreserveStack = true)] // [XSharp(PreserveStack = true)]
// procedure // procedure
// Call("DebugStub_ComReadEAX") // Call("DebugStub_ComReadEAX()
// ECX = EAX // ECX = EAX
// AL = (int)Ds2Vs.MemoryData // AL = Ds2Vs_MemoryData
// Call("DebugStub_ComWriteAL") ComWriteAL()
// //
// Call("DebugStub_ComReadEAX") // Call("DebugStub_ComReadEAX()
// ESI = EAX // ESI = EAX
// //
// // now ECX contains size of data (count) // // now ECX contains size of data (count)
@ -100,68 +100,68 @@ procedure SendRegisters {
// Label = "DebugStub_SendMemory_SendByte" // Label = "DebugStub_SendMemory_SendByte"
// new Compare { DestinationReg = Registers.ECX, SourceValue = 0 } // new Compare { DestinationReg = Registers.ECX, SourceValue = 0 }
// JumpIf(Flags.Equal, "DebugStub_SendMemory_After_SendByte") // JumpIf(Flags.Equal, "DebugStub_SendMemory_After_SendByte")
// Call("DebugStub_ComWrite8") ComWrite8()
// ECX-- // ECX--
// Jump("DebugStub_SendMemory_SendByte") // Jump("DebugStub_SendMemory_SendByte")
// //
// Label = "DebugStub_SendMemory_After_SendByte" // Label = "DebugStub_SendMemory_After_SendByte"
// } // }
//} }
//procedure SendTrace2 { procedure SendTrace2 {
// // Modifies: EAX, ESI // // Modifies: EAX, ESI
// DebugStatus.Value.Compare(Status.Run) // DebugStatus.Value.Compare(Status.Run)
// JumpIf(Flags.Equal, ".Normal") // JumpIf(Flags.Equal, ".Normal")
// AL = (int)Ds2Vs.BreakPoint // AL = Ds2Vs_BreakPoint
// Jump(".Type") // Jump(".Type")
// //
// Label = ".Normal" // Label = ".Normal"
// AL = (int)Ds2Vs.TracePoint // AL = Ds2Vs_TracePoint
// //
// Label = ".Type" // Label = ".Type"
// Call("DebugStub_ComWriteAL") ComWriteAL()
// //
// // Send Calling EIP. // // Send Calling EIP.
// ESI = CallerEIP.Address // ESI = CallerEIP.Address
// DebugStub_ComWrite32() // DebugStub_ComWrite32()
//} }
//procedure SendText2 { procedure SendText2 {
// // Input: Stack // // Input: Stack
// // Output: None // // Output: None
// // Modifies: EAX, ECX, EDX, ESI // // Modifies: EAX, ECX, EDX, ESI
// // Write the type // // Write the type
// AL = (int)Ds2Vs.Message // AL = Ds2Vs_Message
// Call("DebugStub_ComWriteAL") ComWriteAL()
// //
// // Write Length // // Write Length
// ESI = EBP // ESI = EBP
// ESI = ESI + 12 // ESI = ESI + 12
// ECX = ESI[0] // ECX = ESI[0]
// Call("DebugStub_ComWrite16") ComWrite16()
// //
// // Address of string // // Address of string
// ESI = EBP[8] // ESI = EBP[8]
// Label = ".WriteChar" // Label = ".WriteChar"
// ECX.Compare(0) // ECX.Compare(0)
// JumpIf(Flags.Equal, ".Exit") // JumpIf(Flags.Equal, ".Exit")
// Call("DebugStub_ComWrite8") ComWrite8()
// ECX-- // ECX--
// // We are storing as 16 bits, but for now I will transmit 8 bits // // We are storing as 16 bits, but for now I will transmit 8 bits
// // So we inc again to skip the 0 // // So we inc again to skip the 0
// ESI++ // ESI++
// Jump(".WriteChar") // Jump(".WriteChar")
//} }
//procedure SendPtr2 { procedure SendPtr2 {
// // Input: Stack // // Input: Stack
// // Output: None // // Output: None
// // Modifies: EAX, ECX, EDX, ESI // // Modifies: EAX, ECX, EDX, ESI
// // Write the type // // Write the type
// AL = (int)Ds2Vs.Pointer // AL = Ds2Vs_Pointer
// Call("DebugStub_ComWriteAL") ComWriteAL()
// //
// // pointer value // // pointer value
// ESI = EBP[8] // ESI = EBP[8]
// DebugStub_ComWrite32() // DebugStub_ComWrite32()
//} }

View file

@ -195,12 +195,12 @@ namespace Cosmos.Compiler.XSharp {
AddPattern(new string[] { AddPattern(new string[] {
//0 1 2 3 4 5 //0 1 2 3 4 5
"if _REG < 123 goto _ABC", "if _REG < 123 exit", "if _REG < 123 goto _ABC", "if _REG < 123 exit", "if _REG < _REG goto _ABC", "if _REG < _REG exit",
"if _REG > 123 goto _ABC", "if _REG > 123 exit", "if _REG > 123 goto _ABC", "if _REG > 123 exit", "if _REG > _REG goto _ABC", "if _REG > _REG exit",
"if _REG = 123 goto _ABC", "if _REG = 123 exit", "if _REG = 123 goto _ABC", "if _REG = 123 exit", "if _REG = _REG goto _ABC", "if _REG = _REG exit",
"if _REG != 123 goto _ABC", "if _REG != 123 exit", "if _REG != 123 goto _ABC", "if _REG != 123 exit", "if _REG != _REG goto _ABC", "if _REG != _REG exit",
"if _REG <= 123 goto _ABC", "if _REG <= 123 exit", "if _REG <= 123 goto _ABC", "if _REG <= 123 exit", "if _REG <= _REG goto _ABC", "if _REG <= _REG exit",
"if _REG >= 123 goto _ABC", "if _REG >= 123 exit" "if _REG >= 123 goto _ABC", "if _REG >= 123 exit", "if _REG >= _REG goto _ABC", "if _REG >= _REG exit"
}, },
delegate(TokenList aTokens, ref List<string> rCode) { delegate(TokenList aTokens, ref List<string> rCode) {
rCode.Add("Cmp {1}, {3}"); rCode.Add("Cmp {1}, {3}");
@ -340,8 +340,14 @@ namespace Cosmos.Compiler.XSharp {
}); });
// TODO: Allow asm to optimize these to Inc/Dec // TODO: Allow asm to optimize these to Inc/Dec
AddPattern("_REG + 1", "Add {0}, {2}"); AddPattern(new string[] {
AddPattern("_REG - 1", "Sub {0}, {2}"); "_REG + 1",
"_REG + _REG"
}, "Add {0}, {2}");
AddPattern(new string[] {
"_REG - 1",
"_REG - _REG"
}, "Sub {0}, {2}");
AddPattern("_REG++", "Inc {0}"); AddPattern("_REG++", "Inc {0}");
AddPattern("_REG--", "Dec {0}"); AddPattern("_REG--", "Dec {0}");

View file

@ -40,6 +40,7 @@ namespace XSharpCompilerTester {
Test("CmdAsmBreak.xs"); Test("CmdAsmBreak.xs");
Test("Main.xs"); Test("Main.xs");
Test("CmdProcess.xs"); Test("CmdProcess.xs");
Test("CmdSend.xs");
} }
} }
} }