using System; using System.Linq; using Cosmos.Assembler; using Cosmos.Assembler.x86; namespace Cosmos.Debug.DebugStub { public class CmdSend : Cosmos.Assembler.Code { public CmdSend(Assembler.Assembler aAssembler) : base(aAssembler) {} public override void Assemble() { new LiteralAssemblerCode("DebugStub_SendRegisters:"); new LiteralAssemblerCode("Mov AL, DebugStub_Const_Ds2Vs_Registers"); new LiteralAssemblerCode("Call DebugStub_ComWriteAL"); new LiteralAssemblerCode("Mov ESI, [DebugStub_PushAllPtr]"); new LiteralAssemblerCode("Mov ECX, 32"); new LiteralAssemblerCode("Call DebugStub_ComWriteX"); new LiteralAssemblerCode("Mov ESI, DebugStub_CallerESP"); new LiteralAssemblerCode("Call DebugStub_ComWrite32"); new LiteralAssemblerCode("Mov ESI, DebugStub_CallerEIP"); new LiteralAssemblerCode("Call DebugStub_ComWrite32"); new LiteralAssemblerCode("DebugStub_SendRegisters_Exit:"); new LiteralAssemblerCode("Ret"); new LiteralAssemblerCode("DebugStub_SendFrame:"); new LiteralAssemblerCode("Mov AL, DebugStub_Const_Ds2Vs_Frame"); new LiteralAssemblerCode("Call DebugStub_ComWriteAL"); new LiteralAssemblerCode("Mov EAX, 32"); new LiteralAssemblerCode("Call DebugStub_ComWriteAX"); new LiteralAssemblerCode("Mov ESI, [DebugStub_CallerEBP]"); new LiteralAssemblerCode("Add ESI, 8"); new LiteralAssemblerCode("Mov ECX, 32"); new LiteralAssemblerCode("Call DebugStub_ComWriteX"); new LiteralAssemblerCode("DebugStub_SendFrame_Exit:"); new LiteralAssemblerCode("Ret"); new LiteralAssemblerCode("DebugStub_SendStack:"); new LiteralAssemblerCode("Mov AL, DebugStub_Const_Ds2Vs_Stack"); new LiteralAssemblerCode("Call DebugStub_ComWriteAL"); new LiteralAssemblerCode("Mov ESI, [DebugStub_CallerESP]"); new LiteralAssemblerCode("Mov EAX, [DebugStub_CallerEBP]"); new LiteralAssemblerCode("Sub EAX, ESI"); new LiteralAssemblerCode("Call DebugStub_ComWriteAX"); new LiteralAssemblerCode("Mov ESI, [DebugStub_CallerESP]"); new LiteralAssemblerCode("DebugStub_SendStack_Block1Begin:"); new LiteralAssemblerCode("Cmp ESI, [DebugStub_CallerEBP]"); new LiteralAssemblerCode("JE DebugStub_SendStack_Block1End"); new LiteralAssemblerCode("Call DebugStub_ComWrite8"); new LiteralAssemblerCode("jmp DebugStub_SendStack_Block1Begin"); new LiteralAssemblerCode("DebugStub_SendStack_Block1End:"); new LiteralAssemblerCode("DebugStub_SendStack_Exit:"); new LiteralAssemblerCode("Ret"); new LiteralAssemblerCode("DebugStub_SendMethodContext:"); new LiteralAssemblerCode("Pushad"); new LiteralAssemblerCode("Mov AL, DebugStub_Const_Ds2Vs_MethodContext"); new LiteralAssemblerCode("Call DebugStub_ComWriteAL"); new LiteralAssemblerCode("Call DebugStub_ComReadEAX"); new LiteralAssemblerCode("Mov ECX, EAX"); new LiteralAssemblerCode("Call DebugStub_ComReadEAX"); new LiteralAssemblerCode("Mov ESI, [DebugStub_CallerEBP]"); new LiteralAssemblerCode("Add ESI, EAX"); new LiteralAssemblerCode("DebugStub_SendMethodContext_Block2Begin:"); new LiteralAssemblerCode("Cmp ECX, 0"); new LiteralAssemblerCode("JE DebugStub_SendMethodContext_Block2End"); new LiteralAssemblerCode("Call DebugStub_ComWrite8"); new LiteralAssemblerCode("Dec ECX"); new LiteralAssemblerCode("jmp DebugStub_SendMethodContext_Block2Begin"); new LiteralAssemblerCode("DebugStub_SendMethodContext_Block2End:"); new LiteralAssemblerCode("DebugStub_SendMethodContext_Exit:"); new LiteralAssemblerCode("Popad"); new LiteralAssemblerCode("Ret"); new LiteralAssemblerCode("DebugStub_SendMemory:"); new LiteralAssemblerCode("Pushad"); new LiteralAssemblerCode("Call DebugStub_ComReadEAX"); new LiteralAssemblerCode("Mov ECX, EAX"); new LiteralAssemblerCode("Mov AL, DebugStub_Const_Ds2Vs_MemoryData"); new LiteralAssemblerCode("Call DebugStub_ComWriteAL"); new LiteralAssemblerCode("Call DebugStub_ComReadEAX"); new LiteralAssemblerCode("Mov ESI, EAX"); new LiteralAssemblerCode("DebugStub_SendMemory_Block3Begin:"); new LiteralAssemblerCode("Cmp ECX, 0"); new LiteralAssemblerCode("JE DebugStub_SendMemory_Block3End"); new LiteralAssemblerCode("Call DebugStub_ComWrite8"); new LiteralAssemblerCode("Dec ECX"); new LiteralAssemblerCode("jmp DebugStub_SendMemory_Block3Begin"); new LiteralAssemblerCode("DebugStub_SendMemory_Block3End:"); new LiteralAssemblerCode("DebugStub_SendMemory_Exit:"); new LiteralAssemblerCode("Popad"); new LiteralAssemblerCode("Ret"); new LiteralAssemblerCode("DebugStub_SendTrace:"); new LiteralAssemblerCode("Cmp dword [DebugStub_DebugStatus], DebugStub_Const_Status_Run"); new LiteralAssemblerCode("JE DebugStub_SendTrace_Normal"); new LiteralAssemblerCode("Mov AL, DebugStub_Const_Ds2Vs_BreakPoint"); new LiteralAssemblerCode("Jmp DebugStub_SendTrace_Type"); new LiteralAssemblerCode("DebugStub_SendTrace_Normal:"); new LiteralAssemblerCode("Mov AL, DebugStub_Const_Ds2Vs_TracePoint"); new LiteralAssemblerCode("DebugStub_SendTrace_Type:"); new LiteralAssemblerCode("Call DebugStub_ComWriteAL"); new LiteralAssemblerCode("Mov ESI, DebugStub_CallerEIP"); new LiteralAssemblerCode("Call DebugStub_ComWrite32"); new LiteralAssemblerCode("DebugStub_SendTrace_Exit:"); new LiteralAssemblerCode("Ret"); new LiteralAssemblerCode("DebugStub_SendText:"); new LiteralAssemblerCode("Mov AL, DebugStub_Const_Ds2Vs_Message"); new LiteralAssemblerCode("Call DebugStub_ComWriteAL"); new LiteralAssemblerCode("Mov ESI, EBP"); new LiteralAssemblerCode("Add ESI, 12"); new LiteralAssemblerCode("Mov ECX, [ESI + 0]"); new LiteralAssemblerCode("Call DebugStub_ComWrite16"); new LiteralAssemblerCode("Mov ESI, [EBP + 8]"); new LiteralAssemblerCode("DebugStub_SendText_WriteChar:"); new LiteralAssemblerCode("Cmp ECX, 0"); new LiteralAssemblerCode("JE DebugStub_SendText_Exit"); new LiteralAssemblerCode("Call DebugStub_ComWrite8"); new LiteralAssemblerCode("Dec ECX"); new LiteralAssemblerCode("Inc ESI"); new LiteralAssemblerCode("Jmp DebugStub_SendText_WriteChar"); new LiteralAssemblerCode("DebugStub_SendText_Exit:"); new LiteralAssemblerCode("Ret"); new LiteralAssemblerCode("DebugStub_SendPtr:"); new LiteralAssemblerCode("Mov AL, DebugStub_Const_Ds2Vs_Pointer"); new LiteralAssemblerCode("Call DebugStub_ComWriteAL"); new LiteralAssemblerCode("Mov ESI, [EBP + 8]"); new LiteralAssemblerCode("Call DebugStub_ComWrite32"); new LiteralAssemblerCode("DebugStub_SendPtr_Exit:"); new LiteralAssemblerCode("Ret"); } } }