From d28e87baf888bc3725faffbfd24cbe3f0c3ca3d0 Mon Sep 17 00:00:00 2001
From: kudzu_cp <6d05c8c8ef5431987001abfdb2eadc9593ac9498>
Date: Sun, 27 Apr 2008 19:51:23 +0000
Subject: [PATCH]
---
source/Indy.IL2CPU.Assembler.X86/Assembler.cs | 17 +++++++-------
.../Indy.IL2CPU.Assembler.X86.csproj | 2 +-
source/Indy.IL2CPU.Assembler.X86/X/Address.cs | 8 +++++++
.../X/AddressDirect.cs | 23 +++++++++++++++++++
.../X/AddressNumeric.cs | 22 ------------------
.../Indy.IL2CPU.Assembler.X86/X/Register.cs | 4 ++++
.../Indy.IL2CPU.Assembler.X86/X/RegisterAL.cs | 4 ++--
.../X/RegisterEAX.cs | 5 ++++
.../X/RegisterEBP.cs | 7 ++++++
9 files changed, 59 insertions(+), 33 deletions(-)
create mode 100644 source/Indy.IL2CPU.Assembler.X86/X/AddressDirect.cs
delete mode 100644 source/Indy.IL2CPU.Assembler.X86/X/AddressNumeric.cs
diff --git a/source/Indy.IL2CPU.Assembler.X86/Assembler.cs b/source/Indy.IL2CPU.Assembler.X86/Assembler.cs
index 57e208dc8..d92ffcd5a 100644
--- a/source/Indy.IL2CPU.Assembler.X86/Assembler.cs
+++ b/source/Indy.IL2CPU.Assembler.X86/Assembler.cs
@@ -23,33 +23,34 @@ namespace Indy.IL2CPU.Assembler.X86 {
Label = "DebugWriteEIP";
AL = Memory[EBP + 3];
- new Push(Registers.EAX);
+ EAX.Push();
Call("WriteByteToComPort");
AL = Memory[EBP + 2];
- new Push(Registers.EAX);
+ EAX.Push();
Call("WriteByteToComPort");
AL = Memory[EBP + 1];
- new Push(Registers.EAX);
+ EAX.Push();
Call("WriteByteToComPort");
AL = Memory[EBP];
- new Push(Registers.EAX);
+ EAX.Push();
Call("WriteByteToComPort");
Return();
Label = "DebugPoint_WaitCmd";
DX = xComStatusAddr;
- new InByte(Registers.AL, Registers.DX);
+ AL = Port[DX];
AL.Test(0x01);
- new JumpIfZero("DebugPoint_WaitCmd");
+ JumpIfZero("DebugPoint_WaitCmd");
Jump("DebugPoint_ProcessCmd");
Label = "DebugPoint__";
PushAll32();
- new Move(Registers.EBP, Registers.ESP);
+ //new Move(Registers.EBP, Registers.ESP);
+ EBP = ESP;
new Add(Registers.EBP, 32);
// Check TraceMode
- new Move(Registers.EAX, "[TraceMode]");
+ EAX = Memory["TraceMode"];
new Compare(Registers.AX, 1);
JumpIfEqual("DebugPoint_NoTrace");
//
diff --git a/source/Indy.IL2CPU.Assembler.X86/Indy.IL2CPU.Assembler.X86.csproj b/source/Indy.IL2CPU.Assembler.X86/Indy.IL2CPU.Assembler.X86.csproj
index ed4a1a34f..298ec69c9 100644
--- a/source/Indy.IL2CPU.Assembler.X86/Indy.IL2CPU.Assembler.X86.csproj
+++ b/source/Indy.IL2CPU.Assembler.X86/Indy.IL2CPU.Assembler.X86.csproj
@@ -124,7 +124,7 @@
-
+
diff --git a/source/Indy.IL2CPU.Assembler.X86/X/Address.cs b/source/Indy.IL2CPU.Assembler.X86/X/Address.cs
index 8e3c3690e..81dac8528 100644
--- a/source/Indy.IL2CPU.Assembler.X86/X/Address.cs
+++ b/source/Indy.IL2CPU.Assembler.X86/X/Address.cs
@@ -10,5 +10,13 @@ namespace Indy.IL2CPU.Assembler.X86.X {
return new AddressIndirect(aRegister, 0);
}
+ public static implicit operator Address(UInt32 aAddress) {
+ return new AddressDirect(aAddress);
+ }
+
+ public static implicit operator Address(string aLabel) {
+ return new AddressDirect(aLabel);
+ }
+
}
}
diff --git a/source/Indy.IL2CPU.Assembler.X86/X/AddressDirect.cs b/source/Indy.IL2CPU.Assembler.X86/X/AddressDirect.cs
new file mode 100644
index 000000000..2ad4abf99
--- /dev/null
+++ b/source/Indy.IL2CPU.Assembler.X86/X/AddressDirect.cs
@@ -0,0 +1,23 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+
+namespace Indy.IL2CPU.Assembler.X86.X {
+ public class AddressDirect : Address {
+ protected readonly string mAddress;
+
+ public AddressDirect(UInt32 aAddress) {
+ mAddress = aAddress.ToString();
+ }
+
+ public AddressDirect(string aLabel) {
+ mAddress = "[" + aLabel + "]";
+ }
+
+ public override string ToString() {
+ return mAddress.ToString();
+ }
+
+ }
+}
diff --git a/source/Indy.IL2CPU.Assembler.X86/X/AddressNumeric.cs b/source/Indy.IL2CPU.Assembler.X86/X/AddressNumeric.cs
deleted file mode 100644
index a4ee1f8ba..000000000
--- a/source/Indy.IL2CPU.Assembler.X86/X/AddressNumeric.cs
+++ /dev/null
@@ -1,22 +0,0 @@
-using System;
-using System.Collections.Generic;
-using System.Linq;
-using System.Text;
-
-namespace Indy.IL2CPU.Assembler.X86.X {
- public class AddressNumeric : Address {
- protected UInt32 mAddress;
-
- public AddressNumeric(UInt32 aAddress) {
- mAddress = aAddress;
- }
-
- public override string ToString() {
- return mAddress.ToString();
- }
-
- public static implicit operator AddressNumeric(UInt32 aAddress) {
- return new AddressNumeric(aAddress);
- }
- }
-}
diff --git a/source/Indy.IL2CPU.Assembler.X86/X/Register.cs b/source/Indy.IL2CPU.Assembler.X86/X/Register.cs
index ee3c65d91..9709f711f 100644
--- a/source/Indy.IL2CPU.Assembler.X86/X/Register.cs
+++ b/source/Indy.IL2CPU.Assembler.X86/X/Register.cs
@@ -7,6 +7,10 @@ using X86 = Indy.IL2CPU.Assembler.X86;
namespace Indy.IL2CPU.Assembler.X86.X {
public abstract class Register {
+ public void Push() {
+ new Push(ToString());
+ }
+
protected void Move(string aValue) {
new X86.Move(ToString(), aValue);
}
diff --git a/source/Indy.IL2CPU.Assembler.X86/X/RegisterAL.cs b/source/Indy.IL2CPU.Assembler.X86/X/RegisterAL.cs
index 1bbcf888f..712b5df8f 100644
--- a/source/Indy.IL2CPU.Assembler.X86/X/RegisterAL.cs
+++ b/source/Indy.IL2CPU.Assembler.X86/X/RegisterAL.cs
@@ -22,12 +22,12 @@ namespace Indy.IL2CPU.Assembler.X86.X {
}
public static implicit operator RegisterAL(PortNumber aValue) {
- new X86.InByte("AL", aValue.ToString());
+ new X86.InByte(Name, aValue.ToString());
return Instance;
}
public static implicit operator RegisterAL(MemoryAction aAction) {
- new X86.Move("AL", aAction.ToString());
+ new X86.Move(Name, aAction.ToString());
return Instance;
}
diff --git a/source/Indy.IL2CPU.Assembler.X86/X/RegisterEAX.cs b/source/Indy.IL2CPU.Assembler.X86/X/RegisterEAX.cs
index 25ae4941e..8a410aaad 100644
--- a/source/Indy.IL2CPU.Assembler.X86/X/RegisterEAX.cs
+++ b/source/Indy.IL2CPU.Assembler.X86/X/RegisterEAX.cs
@@ -12,6 +12,11 @@ namespace Indy.IL2CPU.Assembler.X86.X {
return Name;
}
+ public static implicit operator RegisterEAX(MemoryAction aAction) {
+ Instance.Move(aAction.ToString());
+ return Instance;
+ }
+
public static implicit operator RegisterEAX(UInt32 aValue) {
Instance.Move(aValue.ToString());
return Instance;
diff --git a/source/Indy.IL2CPU.Assembler.X86/X/RegisterEBP.cs b/source/Indy.IL2CPU.Assembler.X86/X/RegisterEBP.cs
index 050f09600..a4e3b8f8c 100644
--- a/source/Indy.IL2CPU.Assembler.X86/X/RegisterEBP.cs
+++ b/source/Indy.IL2CPU.Assembler.X86/X/RegisterEBP.cs
@@ -16,5 +16,12 @@ namespace Indy.IL2CPU.Assembler.X86.X {
Instance.Move(aValue.ToString());
return Instance;
}
+
+ // TODO: Use Generics to add all the stuff that is common between all register
+ // but must exist on actual register type
+ public static implicit operator RegisterEBP(RegisterESP aValue) {
+ Instance.Move(aValue.ToString());
+ return Instance;
+ }
}
}