mirror of
https://github.com/danbulant/Cosmos
synced 2026-06-08 01:02:25 +00:00
This commit is contained in:
parent
b543ab5ee9
commit
ef031a2039
7 changed files with 273 additions and 263 deletions
|
|
@ -157,18 +157,16 @@ namespace Cosmos.Compiler.DebugStub {
|
||||||
|
|
||||||
// now ECX contains size of data (count)
|
// now ECX contains size of data (count)
|
||||||
// EAX contains relative to EBP
|
// EAX contains relative to EBP
|
||||||
Label = "DebugStub_SendMethodContext2";
|
|
||||||
ESI = Memory[DebugStub.CallerEBP.Name, 32];
|
ESI = Memory[DebugStub.CallerEBP.Name, 32];
|
||||||
ESI.Add(EAX);
|
ESI.Add(EAX);
|
||||||
|
|
||||||
Label = "DebugStub_SendMethodContext_SendByte";
|
Label = ".SendByte";
|
||||||
new Compare { DestinationReg = Registers.ECX, SourceValue = 0 };
|
ECX.Compare(0);
|
||||||
JumpIf(Flags.Equal, "DebugStub_SendMethodContext_After_SendByte");
|
JumpIf(Flags.Equal, ".AfterSendByte");
|
||||||
Call<WriteByteToComPort>();
|
Call<WriteByteToComPort>();
|
||||||
new Dec { DestinationReg = Registers.ECX };
|
ECX--;
|
||||||
Jump("DebugStub_SendMethodContext_SendByte");
|
Jump(".SendByte");
|
||||||
|
Label = ".AfterSendByte";
|
||||||
Label = "DebugStub_SendMethodContext_After_SendByte";
|
|
||||||
|
|
||||||
PopAll();
|
PopAll();
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -36,23 +36,22 @@ namespace Cosmos.Compiler.XSharp {
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void Move(uint aAddress) {
|
protected void Move(uint aAddress) {
|
||||||
new Move { DestinationReg = GetId(), SourceValue = aAddress, Size=Registers.GetSize(GetId())};
|
new Move { DestinationReg = GetId(), SourceValue = aAddress, Size = Registers.GetSize(GetId()) };
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void Move(MemoryAction aAction) {
|
protected void Move(MemoryAction aAction) {
|
||||||
new Move { DestinationReg = GetId(), SourceReg = aAction.Register, SourceDisplacement = aAction.Displacement, SourceIsIndirect = aAction.IsIndirect, SourceRef = aAction.Reference, Size = Registers.GetSize(GetId()) };
|
new Move { DestinationReg = GetId(), SourceReg = aAction.Register, SourceDisplacement = aAction.Displacement, SourceIsIndirect = aAction.IsIndirect, SourceRef = aAction.Reference, Size = Registers.GetSize(GetId()) };
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void Move(RegistersEnum aRegister)
|
protected void Move(RegistersEnum aRegister) {
|
||||||
{
|
|
||||||
new Move { DestinationReg = GetId(), SourceReg = aRegister, Size = Registers.GetSize(GetId()) };
|
new Move { DestinationReg = GetId(), SourceReg = aRegister, Size = Registers.GetSize(GetId()) };
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void Move(ElementReference aReference) {
|
protected void Move(ElementReference aReference) {
|
||||||
new Move { DestinationReg = GetId(), SourceRef = aReference, Size = Registers.GetSize(GetId())};
|
new Move { DestinationReg = GetId(), SourceRef = aReference, Size = Registers.GetSize(GetId()) };
|
||||||
}
|
}
|
||||||
|
|
||||||
public bool isPort(){
|
public bool isPort() {
|
||||||
if (GetId().Equals(Registers.AX) || GetId().Equals(Registers.AL) || GetId().Equals(Registers.EAX)) {
|
if (GetId().Equals(Registers.AX) || GetId().Equals(Registers.AL) || GetId().Equals(Registers.EAX)) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -7,6 +7,7 @@ using Cosmos.Compiler.Assembler.X86;
|
||||||
|
|
||||||
namespace Cosmos.Compiler.XSharp {
|
namespace Cosmos.Compiler.XSharp {
|
||||||
public class Register32 : Register {
|
public class Register32 : Register {
|
||||||
|
|
||||||
public Register32() {
|
public Register32() {
|
||||||
mBitSize = 32;
|
mBitSize = 32;
|
||||||
}
|
}
|
||||||
|
|
@ -15,7 +16,7 @@ namespace Cosmos.Compiler.XSharp {
|
||||||
// 1- C# overloads specifically by exact class and does not inherit in many cases
|
// 1- C# overloads specifically by exact class and does not inherit in many cases
|
||||||
// 2- x86 does not support all operations on all registers
|
// 2- x86 does not support all operations on all registers
|
||||||
|
|
||||||
public static AddressIndirect operator+ (Register32 aBaseRegister, Int32 aDisplacement) {
|
public static AddressIndirect operator +(Register32 aBaseRegister, Int32 aDisplacement) {
|
||||||
return new AddressIndirect(aBaseRegister, aDisplacement);
|
return new AddressIndirect(aBaseRegister, aDisplacement);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -7,26 +7,21 @@ using Cosmos.Compiler.Assembler.X86;
|
||||||
|
|
||||||
namespace Cosmos.Compiler.XSharp {
|
namespace Cosmos.Compiler.XSharp {
|
||||||
public class RegisterEAX : Register32 {
|
public class RegisterEAX : Register32 {
|
||||||
public const string Name = "EAX";
|
|
||||||
public static readonly RegisterEAX Instance = new RegisterEAX();
|
public static readonly RegisterEAX Instance = new RegisterEAX();
|
||||||
|
|
||||||
public override string ToString() {
|
public static RegisterEAX operator ++(RegisterEAX aRegister) {
|
||||||
return Name;
|
|
||||||
}
|
|
||||||
|
|
||||||
public static RegisterEAX operator++ (RegisterEAX aRegister) {
|
|
||||||
new Inc { DestinationReg = aRegister.GetId() };
|
new Inc { DestinationReg = aRegister.GetId() };
|
||||||
return aRegister;
|
return aRegister;
|
||||||
}
|
}
|
||||||
public static RegisterEAX operator-- (RegisterEAX aRegister) {
|
public static RegisterEAX operator --(RegisterEAX aRegister) {
|
||||||
new Dec { DestinationReg = aRegister.GetId() };
|
new Dec { DestinationReg = aRegister.GetId() };
|
||||||
return aRegister;
|
return aRegister;
|
||||||
}
|
}
|
||||||
public static RegisterEAX operator<< (RegisterEAX aRegister, int aCount) {
|
public static RegisterEAX operator <<(RegisterEAX aRegister, int aCount) {
|
||||||
new ShiftLeft { DestinationReg = aRegister.GetId(), SourceValue = (uint)aCount };
|
new ShiftLeft { DestinationReg = aRegister.GetId(), SourceValue = (uint)aCount };
|
||||||
return aRegister;
|
return aRegister;
|
||||||
}
|
}
|
||||||
public static RegisterEAX operator>> (RegisterEAX aRegister, int aCount) {
|
public static RegisterEAX operator >>(RegisterEAX aRegister, int aCount) {
|
||||||
new ShiftRight { DestinationReg = aRegister.GetId(), SourceValue = (uint)aCount };
|
new ShiftRight { DestinationReg = aRegister.GetId(), SourceValue = (uint)aCount };
|
||||||
return aRegister;
|
return aRegister;
|
||||||
}
|
}
|
||||||
|
|
@ -56,8 +51,7 @@ namespace Cosmos.Compiler.XSharp {
|
||||||
return Instance;
|
return Instance;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static implicit operator RegisterEAX(RegisterESI aReg)
|
public static implicit operator RegisterEAX(RegisterESI aReg) {
|
||||||
{
|
|
||||||
Instance.Move(aReg.GetId());
|
Instance.Move(aReg.GetId());
|
||||||
return Instance;
|
return Instance;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -3,11 +3,29 @@ using System.Collections.Generic;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using System.Text;
|
using System.Text;
|
||||||
using Cosmos.Compiler.Assembler;
|
using Cosmos.Compiler.Assembler;
|
||||||
|
using Cosmos.Compiler.Assembler.X86;
|
||||||
|
|
||||||
namespace Cosmos.Compiler.XSharp {
|
namespace Cosmos.Compiler.XSharp {
|
||||||
public class RegisterECX : Register32 {
|
public class RegisterECX : Register32 {
|
||||||
public static readonly RegisterECX Instance = new RegisterECX();
|
public static readonly RegisterECX Instance = new RegisterECX();
|
||||||
|
|
||||||
|
public static RegisterECX operator ++(RegisterECX aRegister) {
|
||||||
|
new Inc { DestinationReg = aRegister.GetId() };
|
||||||
|
return aRegister;
|
||||||
|
}
|
||||||
|
public static RegisterECX operator --(RegisterECX aRegister) {
|
||||||
|
new Dec { DestinationReg = aRegister.GetId() };
|
||||||
|
return aRegister;
|
||||||
|
}
|
||||||
|
public static RegisterECX operator <<(RegisterECX aRegister, int aCount) {
|
||||||
|
new ShiftLeft { DestinationReg = aRegister.GetId(), SourceValue = (uint)aCount };
|
||||||
|
return aRegister;
|
||||||
|
}
|
||||||
|
public static RegisterECX operator >>(RegisterECX aRegister, int aCount) {
|
||||||
|
new ShiftRight { DestinationReg = aRegister.GetId(), SourceValue = (uint)aCount };
|
||||||
|
return aRegister;
|
||||||
|
}
|
||||||
|
|
||||||
public static implicit operator RegisterECX(ElementReference aReference) {
|
public static implicit operator RegisterECX(ElementReference aReference) {
|
||||||
Instance.Move(aReference);
|
Instance.Move(aReference);
|
||||||
return Instance;
|
return Instance;
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue