Cosmos/source2/Compiler/Cosmos.Compiler.DebugStub/Old/ComPort.cs
kudzu_cp 3b73bb7140
2012-07-08 04:25:50 +00:00

69 lines
2.1 KiB
C#

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Cosmos.Assembler;
using Cosmos.Assembler.x86;
using Cosmos.Debug.Consts;
using Cosmos.Assembler.XSharp;
namespace Cosmos.Debug.DebugStub {
public partial class DebugStub : CodeGroup {
public abstract class Inlines : CodeBlock {
// INLINE
// Modifies: Stack, EDI, AL
// TODO: Modify X# to allow inlining better by using dynamic labels otherwise
// repeated use of an inline will fail with conflicting labels.
// TODO: Allow methods to emit a start label and return automatically
// and mark inlines so this does not happen.
//TODO: Allow inlining in X# wtih an attribute - or method like Call<>?
protected void ReadComPortX32toStack(int xCount) {
for (int i = 1; i <= xCount; i++) {
// Make room on the stack for the address
Push(0);
// ReadByteFromComPort writes to EDI, then increments
EDI = ESP;
// Read address to stack via EDI
Call("DebugStub_ComRead32");
}
}
protected void WriteBytesToComPort(int xCount) {
for (int i = 1; i <= xCount; i++) {
Call("DebugStub_ComWrite8");
}
}
}
public class ComWriteAX : Inlines {
// Input: AX
// Output: None
// Modifies: EDX, ESI
public override void Assemble() {
EAX.Push();
ESI = ESP;
Call("DebugStub_ComWrite16");
// Is a local var, cant use Return(4). X# issues the return.
// This also allow the function to preserve EAX.
EAX.Pop();
}
}
public class ComWriteEAX : Inlines {
// Input: EAX
// Output: None
// Modifies: EDX, ESI
public override void Assemble() {
EAX.Push();
ESI = ESP;
Call("DebugStub_ComWrite32");
// Is a local var, cant use Return(4). X# issues the return.
// This also allow the function to preserve EAX.
EAX.Pop();
}
}
}
}