mirror of
https://github.com/danbulant/Cosmos
synced 2026-05-19 12:30:32 +00:00
139 lines
6.4 KiB
C#
139 lines
6.4 KiB
C#
using System;
|
|
using System.Linq;
|
|
using Cosmos.Assembler;
|
|
using Cosmos.Assembler.x86;
|
|
|
|
namespace Cosmos.Debug.DebugStub {
|
|
public class Serial : Cosmos.Assembler.Code {
|
|
|
|
public Serial(Assembler.Assembler aAssembler) : base(aAssembler) {}
|
|
|
|
public override void Assemble() {
|
|
mAssembler.DataMembers.Add(new DataMember("DebugStub_ComAddr", 0x03F8));
|
|
new LiteralAssemblerCode("DebugStub_InitSerial:");
|
|
new LiteralAssemblerCode("Mov DX, [DebugStub_ComAddr]");
|
|
new LiteralAssemblerCode("Mov BX, DX");
|
|
new LiteralAssemblerCode("Add DX, 1");
|
|
new LiteralAssemblerCode("Mov AL, 0");
|
|
new LiteralAssemblerCode("Out DX, AL");
|
|
new LiteralAssemblerCode("Mov DX, BX");
|
|
new LiteralAssemblerCode("Add DX, 3");
|
|
new LiteralAssemblerCode("Mov AL, 0x80");
|
|
new LiteralAssemblerCode("Out DX, AL");
|
|
new LiteralAssemblerCode("Mov DX, BX");
|
|
new LiteralAssemblerCode("Mov AL, 0x01");
|
|
new LiteralAssemblerCode("Out DX, AL");
|
|
new LiteralAssemblerCode("Mov DX, BX");
|
|
new LiteralAssemblerCode("Add DX, 1");
|
|
new LiteralAssemblerCode("Mov AL, 0x00");
|
|
new LiteralAssemblerCode("Out DX, AL");
|
|
new LiteralAssemblerCode("Mov DX, BX");
|
|
new LiteralAssemblerCode("Add DX, 3");
|
|
new LiteralAssemblerCode("Mov AL, 0x03");
|
|
new LiteralAssemblerCode("Out DX, AL");
|
|
new LiteralAssemblerCode("Mov DX, BX");
|
|
new LiteralAssemblerCode("Add DX, 2");
|
|
new LiteralAssemblerCode("Mov AL, 0xC7");
|
|
new LiteralAssemblerCode("Out DX, AL");
|
|
new LiteralAssemblerCode("Mov DX, BX");
|
|
new LiteralAssemblerCode("Add DX, 4");
|
|
new LiteralAssemblerCode("Mov AL, 0x03");
|
|
new LiteralAssemblerCode("Out DX, AL");
|
|
new LiteralAssemblerCode("DebugStub_InitSerial_Exit:");
|
|
new LiteralAssemblerCode("Ret");
|
|
new LiteralAssemblerCode("DebugStub_ComReadAL:");
|
|
new LiteralAssemblerCode("Mov DX, [DebugStub_ComAddr]");
|
|
new LiteralAssemblerCode("Add DX, 5");
|
|
new LiteralAssemblerCode("DebugStub_ComReadAL_Wait:");
|
|
new LiteralAssemblerCode("In AL, DX");
|
|
new LiteralAssemblerCode("Test AL, 0x01");
|
|
new LiteralAssemblerCode("JZ DebugStub_ComReadAL_Wait");
|
|
new LiteralAssemblerCode("Mov DX, [DebugStub_ComAddr]");
|
|
new LiteralAssemblerCode("In AL, DX");
|
|
new LiteralAssemblerCode("DebugStub_ComReadAL_Exit:");
|
|
new LiteralAssemblerCode("Ret");
|
|
new LiteralAssemblerCode("DebugStub_ComReadEAX:");
|
|
new LiteralAssemblerCode("Call DebugStub_ComReadAL");
|
|
new LiteralAssemblerCode("ROR EAX, 8");
|
|
new LiteralAssemblerCode("Call DebugStub_ComReadAL");
|
|
new LiteralAssemblerCode("ROR EAX, 8");
|
|
new LiteralAssemblerCode("Call DebugStub_ComReadAL");
|
|
new LiteralAssemblerCode("ROR EAX, 8");
|
|
new LiteralAssemblerCode("Call DebugStub_ComReadAL");
|
|
new LiteralAssemblerCode("ROR EAX, 8");
|
|
new LiteralAssemblerCode("DebugStub_ComReadEAX_Exit:");
|
|
new LiteralAssemblerCode("Ret");
|
|
new LiteralAssemblerCode("DebugStub_ComRead8:");
|
|
new LiteralAssemblerCode("Call DebugStub_ComReadAL");
|
|
new LiteralAssemblerCode("Mov [EDI + 0], AL");
|
|
new LiteralAssemblerCode("Add EDI, 1");
|
|
new LiteralAssemblerCode("DebugStub_ComRead8_Exit:");
|
|
new LiteralAssemblerCode("Ret");
|
|
new LiteralAssemblerCode("DebugStub_ComRead16:");
|
|
new LiteralAssemblerCode("Call DebugStub_ComRead8");
|
|
new LiteralAssemblerCode("Call DebugStub_ComRead8");
|
|
new LiteralAssemblerCode("DebugStub_ComRead16_Exit:");
|
|
new LiteralAssemblerCode("Ret");
|
|
new LiteralAssemblerCode("DebugStub_ComRead32:");
|
|
new LiteralAssemblerCode("Call DebugStub_ComRead8");
|
|
new LiteralAssemblerCode("Call DebugStub_ComRead8");
|
|
new LiteralAssemblerCode("Call DebugStub_ComRead8");
|
|
new LiteralAssemblerCode("Call DebugStub_ComRead8");
|
|
new LiteralAssemblerCode("DebugStub_ComRead32_Exit:");
|
|
new LiteralAssemblerCode("Ret");
|
|
new LiteralAssemblerCode("DebugStub_ComWriteAL:");
|
|
new LiteralAssemblerCode("Push EAX");
|
|
new LiteralAssemblerCode("Mov ESI, ESP");
|
|
new LiteralAssemblerCode("Call DebugStub_ComWrite8");
|
|
new LiteralAssemblerCode("Pop EAX");
|
|
new LiteralAssemblerCode("DebugStub_ComWriteAL_Exit:");
|
|
new LiteralAssemblerCode("Ret");
|
|
new LiteralAssemblerCode("DebugStub_ComWriteAX:");
|
|
new LiteralAssemblerCode("Push EAX");
|
|
new LiteralAssemblerCode("Mov ESI, ESP");
|
|
new LiteralAssemblerCode("Call DebugStub_ComWrite16");
|
|
new LiteralAssemblerCode("Pop EAX");
|
|
new LiteralAssemblerCode("DebugStub_ComWriteAX_Exit:");
|
|
new LiteralAssemblerCode("Ret");
|
|
new LiteralAssemblerCode("DebugStub_ComWriteEAX:");
|
|
new LiteralAssemblerCode("Push EAX");
|
|
new LiteralAssemblerCode("Mov ESI, ESP");
|
|
new LiteralAssemblerCode("Call DebugStub_ComWrite32");
|
|
new LiteralAssemblerCode("Pop EAX");
|
|
new LiteralAssemblerCode("DebugStub_ComWriteEAX_Exit:");
|
|
new LiteralAssemblerCode("Ret");
|
|
new LiteralAssemblerCode("DebugStub_ComWrite8:");
|
|
new LiteralAssemblerCode("Mov DX, [DebugStub_ComAddr]");
|
|
new LiteralAssemblerCode("Add DX, 5");
|
|
new LiteralAssemblerCode("DebugStub_ComWrite8_Wait:");
|
|
new LiteralAssemblerCode("In AL, DX");
|
|
new LiteralAssemblerCode("Test AL, 0x20");
|
|
new LiteralAssemblerCode("JZ DebugStub_ComWrite8_Wait");
|
|
new LiteralAssemblerCode("Mov DX, 0x03F8");
|
|
new LiteralAssemblerCode("Mov AL, [ESI + 0]");
|
|
new LiteralAssemblerCode("Out DX, AL");
|
|
new LiteralAssemblerCode("Inc ESI");
|
|
new LiteralAssemblerCode("DebugStub_ComWrite8_Exit:");
|
|
new LiteralAssemblerCode("Ret");
|
|
new LiteralAssemblerCode("DebugStub_ComWrite16:");
|
|
new LiteralAssemblerCode("Call DebugStub_ComWrite8");
|
|
new LiteralAssemblerCode("Call DebugStub_ComWrite8");
|
|
new LiteralAssemblerCode("DebugStub_ComWrite16_Exit:");
|
|
new LiteralAssemblerCode("Ret");
|
|
new LiteralAssemblerCode("DebugStub_ComWrite32:");
|
|
new LiteralAssemblerCode("Call DebugStub_ComWrite8");
|
|
new LiteralAssemblerCode("Call DebugStub_ComWrite8");
|
|
new LiteralAssemblerCode("Call DebugStub_ComWrite8");
|
|
new LiteralAssemblerCode("Call DebugStub_ComWrite8");
|
|
new LiteralAssemblerCode("DebugStub_ComWrite32_Exit:");
|
|
new LiteralAssemblerCode("Ret");
|
|
new LiteralAssemblerCode("DebugStub_ComWriteX:");
|
|
new LiteralAssemblerCode("DebugStub_ComWriteX_More:");
|
|
new LiteralAssemblerCode("Call DebugStub_ComWrite8");
|
|
new LiteralAssemblerCode("Dec ECX");
|
|
new LiteralAssemblerCode("JNZ DebugStub_ComWriteX_More");
|
|
new LiteralAssemblerCode("DebugStub_ComWriteX_Exit:");
|
|
new LiteralAssemblerCode("Ret");
|
|
}
|
|
}
|
|
}
|