diff --git a/Docs/XSharp/index.html b/Docs/XSharp/index.html
index 4dbbf71f6..2b3055380 100644
--- a/Docs/XSharp/index.html
+++ b/Docs/XSharp/index.html
@@ -13,6 +13,14 @@
Can do reg = reg + 4 - define the + overload as a type that can then be
reimplicitly converted to a register, or whatever type goes inside Memory[x]
+
+ Make it so X# doesnt require the 32 and that it checks register size Memory[EBX,
+ 32] = ECX;
+
+ Register.cs - public void Push() { // TODO: This emits Push dword which
+ generates warnings about dword being ignored new Push { DestinationReg = GetId()
+ }; } |
+ AL.Push does not work at all.
X#milation would need to be implemented.
One of the goals of Cosmos is the need to write very little assembly, so only
diff --git a/source2/IL2PCU/Cosmos.IL2CPU.Debug/Enums.cs b/source2/IL2PCU/Cosmos.IL2CPU.Debug/Enums.cs
index 0db2e9ffc..cf4105a9a 100644
--- a/source2/IL2PCU/Cosmos.IL2CPU.Debug/Enums.cs
+++ b/source2/IL2PCU/Cosmos.IL2CPU.Debug/Enums.cs
@@ -23,11 +23,11 @@ namespace Cosmos.Compiler.Debug {
public enum Command : byte {
Noop = 0
, TraceOff = 1, TraceOn = 2
- // Break command is also for continuing from breakstate.
, Break = 3
- , Step = 4
- , BreakOnAddress = 5
- , BatchBegin = 6
- , BatchEnd = 7
+ , Continue = 4 // After a Break
+ , Step = 5
+ , BreakOnAddress = 6
+ , BatchBegin = 7
+ , BatchEnd = 8
}
}
diff --git a/source2/IL2PCU/Cosmos.IL2CPU.X86/X86/SpecialDebug/DebugStub.cs b/source2/IL2PCU/Cosmos.IL2CPU.X86/X86/SpecialDebug/DebugStub.cs
index 4846a31f2..fd0c86279 100644
--- a/source2/IL2PCU/Cosmos.IL2CPU.X86/X86/SpecialDebug/DebugStub.cs
+++ b/source2/IL2PCU/Cosmos.IL2CPU.X86/X86/SpecialDebug/DebugStub.cs
@@ -86,7 +86,6 @@ namespace Cosmos.IL2CPU.X86 {
EAX = EAX << 2;
EBX.Add(EAX);
- //TODO: Make it so X# doesnt require the 32 and that it checks register size
Memory[EBX, 32] = ECX;
PopAll32();
@@ -105,36 +104,27 @@ namespace Cosmos.IL2CPU.X86 {
// Wait for a command
Label = "DebugStub_WaitCmd";
- Call("ReadALFromComPort");
+ // Check for common commands
+ Call("DebugStub_ProcessCommand");
- AL.Compare((byte)Command.TraceOff);
- CallIf(Flags.Equal, "DebugStub_TraceOff", "DebugStub_WaitCmd");
- AL.Compare((byte)Command.TraceOn);
- CallIf(Flags.Equal, "DebugStub_TraceOn", "DebugStub_WaitCmd");
- AL.Compare((byte)Command.Break);
- // Break command is also the continue command
- // If received while in break, then it continues
- JumpIf(Flags.Equal, "DebugStub_Break_Exit");
- AL.Compare((byte)Command.Step);
- CallIf(Flags.Equal, "DebugStub_Step", "DebugStub_Break_Exit");
+ // Now check for commands that are only valid in break state
+ // or commands that require additional handling while in break
+ // state.
+
+ AL.Compare((byte)Command.Continue);
+ JumpIf(Flags.Equal, "DebugStub_Break_Exit");
+
+ AL.Compare((byte)Command.Step);
+ JumpIf(Flags.NotEqual, "DebugStub_Break_Step_After");
+ Memory["DebugBreakOnNextTrace", 32] = 1;
+ Jump("DebugStub_ProcessCmd_Exit");
+ Label = "DebugStub_Break_Step_After";
+ // Loop around and wait for another command
+ Jump("DebugStub_WaitCmd");
Label = "DebugStub_Break_Exit";
Memory["DebugStatus", 32] = (int)Status.Run;
Return();
-
- /////////////////////
-
- Label = "DebugStub_TraceOff";
- Memory["DebugTraceMode", 32] = (int)Tracing.Off;
- Return();
-
- Label = "DebugStub_TraceOn";
- Memory["DebugTraceMode", 32] = (int)Tracing.On;
- Return();
-
- Label = "DebugStub_Step";
- Memory["DebugBreakOnNextTrace", 32] = 1;
- Return();
}
// Modifies: EAX, ESI
@@ -379,6 +369,10 @@ namespace Cosmos.IL2CPU.X86 {
public void ProcessCommand() {
Label = "DebugStub_ProcessCommand";
Call("ReadALFromComPort");
+ // Some callers expect AL to be returned, so we preserve it
+ // in case any commands modify AL.
+ //TODO: But in ASM wont let us push AL, so we push EAX for now
+ EAX.Push();
AL.Compare((byte)Command.Noop);
JumpIf(Flags.Equal, "DebugStub_ProcessCmd_Exit");
@@ -408,6 +402,7 @@ namespace Cosmos.IL2CPU.X86 {
Label = "DebugStub_ProcessCmd_BreakOnAddress_After";
Label = "DebugStub_ProcessCmd_Exit";
+ EAX.Pop();
Return();
}
diff --git a/source2/IL2PCU/Cosmos.IL2CPU.X86/X86/X/AddressIndirect.cs b/source2/IL2PCU/Cosmos.IL2CPU.X86/X86/X/AddressIndirect.cs
index 05aa5c73d..01baa65cb 100644
--- a/source2/IL2PCU/Cosmos.IL2CPU.X86/X86/X/AddressIndirect.cs
+++ b/source2/IL2PCU/Cosmos.IL2CPU.X86/X86/X/AddressIndirect.cs
@@ -11,7 +11,7 @@ namespace Cosmos.IL2CPU.X86.X {
public readonly int Displacement;
public AddressIndirect(Register32 aBaseRegister, Int32 aDisplacement) {
- Register = Registers.GetRegister(aBaseRegister.GetName());
+ Register = Registers.GetRegister(aBaseRegister.Name);
Displacement = aDisplacement;
}
public AddressIndirect(uint aBaseAddress, int aDisplacement) {
diff --git a/source2/IL2PCU/Cosmos.IL2CPU.X86/X86/X/Register.cs b/source2/IL2PCU/Cosmos.IL2CPU.X86/X86/X/Register.cs
index b086a643c..d9ecfa097 100644
--- a/source2/IL2PCU/Cosmos.IL2CPU.X86/X86/X/Register.cs
+++ b/source2/IL2PCU/Cosmos.IL2CPU.X86/X86/X/Register.cs
@@ -6,11 +6,27 @@ using X86 = Cosmos.IL2CPU.X86;
namespace Cosmos.IL2CPU.X86.X {
public abstract class Register {
+ protected byte mBitSize;
+ public byte BitSize {
+ get { return mBitSize; }
+ }
+
+ public readonly string Name;
+
+ public Register() {
+ Name = GetType().Name.Substring(typeof(Register).Name.Length);
+ }
+
+ public override string ToString() {
+ return Name;
+ }
+
public RegistersEnum GetId() {
- return Registers.GetRegister(GetName()).Value;
+ return Registers.GetRegister(Name).Value;
}
public void Push() {
+ // TODO: This emits Push dword which generates warnings about dword being ignored
new Push { DestinationReg = GetId() };
}
@@ -35,12 +51,10 @@ namespace Cosmos.IL2CPU.X86.X {
new Move { DestinationReg = GetId(), SourceRef = aReference, Size = Registers.GetSize(GetId())};
}
- public string GetName() {
- return GetType().Name.Substring("Register".Length);
- }
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 false;
}
}
diff --git a/source2/IL2PCU/Cosmos.IL2CPU.X86/X86/X/Register08.cs b/source2/IL2PCU/Cosmos.IL2CPU.X86/X86/X/Register08.cs
index da311da6b..96d8d9b12 100644
--- a/source2/IL2PCU/Cosmos.IL2CPU.X86/X86/X/Register08.cs
+++ b/source2/IL2PCU/Cosmos.IL2CPU.X86/X86/X/Register08.cs
@@ -6,6 +6,10 @@ using X86 = Cosmos.IL2CPU.X86;
namespace Cosmos.IL2CPU.X86.X {
public class Register08 : Register {
+ public Register08() {
+ mBitSize = 8;
+ }
+
public void Compare(byte aValue) {
new Compare { DestinationReg = GetId(), SourceValue = aValue, Size = 8 };
}
diff --git a/source2/IL2PCU/Cosmos.IL2CPU.X86/X86/X/Register16.cs b/source2/IL2PCU/Cosmos.IL2CPU.X86/X86/X/Register16.cs
index 0715fc921..68f849e59 100644
--- a/source2/IL2PCU/Cosmos.IL2CPU.X86/X86/X/Register16.cs
+++ b/source2/IL2PCU/Cosmos.IL2CPU.X86/X86/X/Register16.cs
@@ -5,5 +5,9 @@ using System.Text;
namespace Cosmos.IL2CPU.X86.X {
public class Register16 : Register {
+ public Register16() {
+ mBitSize = 16;
+ }
+
}
}
diff --git a/source2/IL2PCU/Cosmos.IL2CPU.X86/X86/X/Register32.cs b/source2/IL2PCU/Cosmos.IL2CPU.X86/X86/X/Register32.cs
index 4ef106b91..7383c19b8 100644
--- a/source2/IL2PCU/Cosmos.IL2CPU.X86/X86/X/Register32.cs
+++ b/source2/IL2PCU/Cosmos.IL2CPU.X86/X86/X/Register32.cs
@@ -5,6 +5,9 @@ using System.Text;
namespace Cosmos.IL2CPU.X86.X {
public class Register32 : Register {
+ public Register32() {
+ mBitSize = 32;
+ }
// Not all overloads can go here.
// 1- C# overloads specifically by exact class and does not inherit in many cases
diff --git a/source2/IL2PCU/Cosmos.IL2CPU.X86/X86/X/RegisterAL.cs b/source2/IL2PCU/Cosmos.IL2CPU.X86/X86/X/RegisterAL.cs
index 6514470de..867bdb197 100644
--- a/source2/IL2PCU/Cosmos.IL2CPU.X86/X86/X/RegisterAL.cs
+++ b/source2/IL2PCU/Cosmos.IL2CPU.X86/X86/X/RegisterAL.cs
@@ -6,13 +6,8 @@ using X86 = Cosmos.IL2CPU.X86;
namespace Cosmos.IL2CPU.X86.X {
public class RegisterAL : Register08 {
- public const string Name = "AL";
public static readonly RegisterAL Instance = new RegisterAL();
- public override string ToString() {
- return Name;
- }
-
// TODO: Use an attribute to find the register name
// Also useful for Memory conversion - Can find attribute
// of descendant? or no?
diff --git a/source2/IL2PCU/Cosmos.IL2CPU.X86/X86/X/RegisterAX.cs b/source2/IL2PCU/Cosmos.IL2CPU.X86/X86/X/RegisterAX.cs
index d9305ce01..343e70ba8 100644
--- a/source2/IL2PCU/Cosmos.IL2CPU.X86/X86/X/RegisterAX.cs
+++ b/source2/IL2PCU/Cosmos.IL2CPU.X86/X86/X/RegisterAX.cs
@@ -5,13 +5,8 @@ using System.Text;
namespace Cosmos.IL2CPU.X86.X {
public class RegisterAX : Register16 {
- public const string Name = "AX";
public static readonly RegisterAX Instance = new RegisterAX();
- public override string ToString() {
- return Name;
- }
-
public static implicit operator RegisterAX(ElementReference aReference) {
Instance.Move(aReference);
return Instance;
diff --git a/source2/IL2PCU/Cosmos.IL2CPU.X86/X86/X/RegisterDX.cs b/source2/IL2PCU/Cosmos.IL2CPU.X86/X86/X/RegisterDX.cs
index cb00caf5f..ca4127755 100644
--- a/source2/IL2PCU/Cosmos.IL2CPU.X86/X86/X/RegisterDX.cs
+++ b/source2/IL2PCU/Cosmos.IL2CPU.X86/X86/X/RegisterDX.cs
@@ -5,13 +5,8 @@ using System.Text;
namespace Cosmos.IL2CPU.X86.X {
public class RegisterDX : Register16 {
- public const string Name = "DX";
public static readonly RegisterDX Instance = new RegisterDX();
- public override string ToString() {
- return Name;
- }
-
public static implicit operator RegisterDX(UInt16 aValue) {
Instance.Move(aValue);
return Instance;
diff --git a/source2/IL2PCU/Cosmos.IL2CPU.X86/X86/X/RegisterEBP.cs b/source2/IL2PCU/Cosmos.IL2CPU.X86/X86/X/RegisterEBP.cs
index 6193de726..e490ea17b 100644
--- a/source2/IL2PCU/Cosmos.IL2CPU.X86/X86/X/RegisterEBP.cs
+++ b/source2/IL2PCU/Cosmos.IL2CPU.X86/X86/X/RegisterEBP.cs
@@ -5,13 +5,8 @@ using System.Text;
namespace Cosmos.IL2CPU.X86.X {
public class RegisterEBP : Register32 {
- public const string Name = "EBP";
public static readonly RegisterEBP Instance = new RegisterEBP();
- public override string ToString() {
- return Name;
- }
-
public static implicit operator RegisterEBP(UInt32 aValue) {
Instance.Move(aValue);
return Instance;
diff --git a/source2/IL2PCU/Cosmos.IL2CPU.X86/X86/X/RegisterEBX.cs b/source2/IL2PCU/Cosmos.IL2CPU.X86/X86/X/RegisterEBX.cs
index 8632ac8ea..77fc003b1 100644
--- a/source2/IL2PCU/Cosmos.IL2CPU.X86/X86/X/RegisterEBX.cs
+++ b/source2/IL2PCU/Cosmos.IL2CPU.X86/X86/X/RegisterEBX.cs
@@ -5,13 +5,8 @@ using System.Text;
namespace Cosmos.IL2CPU.X86.X {
public class RegisterEBX : Register32 {
- public const string Name = "EBX";
public static readonly RegisterEBX Instance = new RegisterEBX();
- public override string ToString() {
- return Name;
- }
-
public static implicit operator RegisterEBX(ElementReference aReference) {
Instance.Move(aReference);
return Instance;
diff --git a/source2/IL2PCU/Cosmos.IL2CPU.X86/X86/X/RegisterECX.cs b/source2/IL2PCU/Cosmos.IL2CPU.X86/X86/X/RegisterECX.cs
index cc8f6d358..743584575 100644
--- a/source2/IL2PCU/Cosmos.IL2CPU.X86/X86/X/RegisterECX.cs
+++ b/source2/IL2PCU/Cosmos.IL2CPU.X86/X86/X/RegisterECX.cs
@@ -5,13 +5,8 @@ using System.Text;
namespace Cosmos.IL2CPU.X86.X {
public class RegisterECX : Register32 {
- public const string Name = "ECX";
public static readonly RegisterECX Instance = new RegisterECX();
- public override string ToString() {
- return Name;
- }
-
public static implicit operator RegisterECX(ElementReference aReference) {
Instance.Move(aReference);
return Instance;
diff --git a/source2/IL2PCU/Cosmos.IL2CPU.X86/X86/X/RegisterEDI.cs b/source2/IL2PCU/Cosmos.IL2CPU.X86/X86/X/RegisterEDI.cs
index 494193282..c51f4ba22 100644
--- a/source2/IL2PCU/Cosmos.IL2CPU.X86/X86/X/RegisterEDI.cs
+++ b/source2/IL2PCU/Cosmos.IL2CPU.X86/X86/X/RegisterEDI.cs
@@ -5,13 +5,8 @@ using System.Text;
namespace Cosmos.IL2CPU.X86.X {
public class RegisterEDI : Register32 {
- public const string Name = "EDI";
public static readonly RegisterEDI Instance = new RegisterEDI();
- public override string ToString() {
- return Name;
- }
-
public static RegisterEDI operator ++(RegisterEDI aRegister) {
new Inc { DestinationReg = aRegister.GetId() };
return aRegister;
diff --git a/source2/IL2PCU/Cosmos.IL2CPU.X86/X86/X/RegisterEDX.cs b/source2/IL2PCU/Cosmos.IL2CPU.X86/X86/X/RegisterEDX.cs
index 3e7e30dfc..d4f8ffed1 100644
--- a/source2/IL2PCU/Cosmos.IL2CPU.X86/X86/X/RegisterEDX.cs
+++ b/source2/IL2PCU/Cosmos.IL2CPU.X86/X86/X/RegisterEDX.cs
@@ -5,13 +5,8 @@ using System.Text;
namespace Cosmos.IL2CPU.X86.X {
public class RegisterEDX : Register32 {
- public const string Name = "EDX";
public static readonly RegisterEDX Instance = new RegisterEDX();
- public override string ToString() {
- return Name;
- }
-
public static implicit operator RegisterEDX(MemoryAction aAction) {
Instance.Move(aAction);
return Instance;
diff --git a/source2/IL2PCU/Cosmos.IL2CPU.X86/X86/X/RegisterESI.cs b/source2/IL2PCU/Cosmos.IL2CPU.X86/X86/X/RegisterESI.cs
index bbda66edc..758544cb3 100644
--- a/source2/IL2PCU/Cosmos.IL2CPU.X86/X86/X/RegisterESI.cs
+++ b/source2/IL2PCU/Cosmos.IL2CPU.X86/X86/X/RegisterESI.cs
@@ -5,13 +5,8 @@ using System.Text;
namespace Cosmos.IL2CPU.X86.X {
public class RegisterESI : Register32 {
- public const string Name = "ESI";
public static readonly RegisterESI Instance = new RegisterESI();
- public override string ToString() {
- return Name;
- }
-
public static implicit operator RegisterESI(ElementReference aReference) {
Instance.Move(aReference);
return Instance;
diff --git a/source2/IL2PCU/Cosmos.IL2CPU.X86/X86/X/RegisterESP.cs b/source2/IL2PCU/Cosmos.IL2CPU.X86/X86/X/RegisterESP.cs
index abc6c1c7f..6d35466b6 100644
--- a/source2/IL2PCU/Cosmos.IL2CPU.X86/X86/X/RegisterESP.cs
+++ b/source2/IL2PCU/Cosmos.IL2CPU.X86/X86/X/RegisterESP.cs
@@ -5,13 +5,8 @@ using System.Text;
namespace Cosmos.IL2CPU.X86.X {
public class RegisterESP : Register32 {
- public const string Name = "ESP";
public static readonly RegisterESP Instance = new RegisterESP();
- public override string ToString() {
- return Name;
- }
-
public static implicit operator RegisterESP(UInt32 aValue) {
Instance.Move(aValue);
return Instance;