mirror of
https://github.com/danbulant/Cosmos
synced 2026-05-20 21:08:51 +00:00
Some more changes, nothing functionally changed.
This commit is contained in:
parent
a7953f9631
commit
e29f612a52
34 changed files with 247 additions and 87 deletions
|
|
@ -74,7 +74,8 @@ namespace HelloWorld {
|
|||
public static void UseArray() {
|
||||
int[] values = new int[] { 1, 2, 3, 4 };
|
||||
int total = values[0] + values[1] + values[2] + values[3];
|
||||
|
||||
values[0] = 10;
|
||||
total = total + values[0] + values[1] + values[2] + values[3];
|
||||
}
|
||||
|
||||
public static void DoWriteLines() {
|
||||
|
|
|
|||
|
|
@ -6,5 +6,7 @@ class ConsoleDrv
|
|||
{
|
||||
int[] xTestValues = new int[] {1, 2, 3, 4};
|
||||
int xSum = xTestValues[0] + xTestValues[1] + xTestValues[2] + xTestValues[3];
|
||||
xTestValues[0] = 10;
|
||||
xSum = xSum + xTestValues[0] + xTestValues[1] + xTestValues[2] + xTestValues[3];
|
||||
}
|
||||
}
|
||||
Binary file not shown.
|
|
@ -57,7 +57,9 @@
|
|||
<Compile Include="JumpAlways.cs" />
|
||||
<Compile Include="JumpIfEquals.cs" />
|
||||
<Compile Include="JumpIfGreater.cs" />
|
||||
<Compile Include="JumpIfGreaterOrEquals.cs" />
|
||||
<Compile Include="JumpIfLess.cs" />
|
||||
<Compile Include="JumpIfLessOrEqual.cs" />
|
||||
<Compile Include="JumpIfNotEquals.cs" />
|
||||
<Compile Include="JumpIfZero.cs" />
|
||||
<Compile Include="Move.cs" />
|
||||
|
|
|
|||
18
source/Indy.IL2CPU.Assembler.X86/JumpIfGreaterOrEquals.cs
Normal file
18
source/Indy.IL2CPU.Assembler.X86/JumpIfGreaterOrEquals.cs
Normal file
|
|
@ -0,0 +1,18 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
|
||||
namespace Indy.IL2CPU.Assembler.X86 {
|
||||
[OpCode(0xFFFFFFFF, "jbe")]
|
||||
public class JumpIfGreaterOrEquals: Instruction {
|
||||
public readonly string Address;
|
||||
public JumpIfGreaterOrEquals(string aAddress) {
|
||||
Address = aAddress;
|
||||
}
|
||||
|
||||
public override string ToString() {
|
||||
return "jbe " + Address;
|
||||
}
|
||||
}
|
||||
}
|
||||
20
source/Indy.IL2CPU.Assembler.X86/JumpIfLessOrEqual.cs
Normal file
20
source/Indy.IL2CPU.Assembler.X86/JumpIfLessOrEqual.cs
Normal file
|
|
@ -0,0 +1,20 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
|
||||
namespace Indy.IL2CPU.Assembler.X86 {
|
||||
/// <summary>
|
||||
/// Represents the JLE opcode
|
||||
/// </summary>
|
||||
[OpCode(0xFFFFFFFF, "jle")]
|
||||
public class JumpIfLessOrEqual: Instruction {
|
||||
public readonly string Address;
|
||||
public JumpIfLessOrEqual(string aAddress) {
|
||||
Address = aAddress;
|
||||
}
|
||||
public override string ToString() {
|
||||
return "jle " + Address;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -26,12 +26,8 @@ namespace Indy.IL2CPU.IL.X86 {
|
|||
Assembler.Add(new CPU.Label(LabelTrue));
|
||||
Assembler.Add(new CPUx86.Add("esp", "4"));
|
||||
Assembler.Add(new CPUx86.JumpAlways(TargetLabel));
|
||||
// Assembler.Add(new CPUx86.Pop("eax"));
|
||||
// Assembler.Add(new CPUx86.Move("[esp]", "eax"));
|
||||
Assembler.Add(new CPU.Label(LabelFalse));
|
||||
Assembler.Add(new CPUx86.Add("esp", "4"));
|
||||
// Assembler.Add(new CPUx86.Pop("eax"));
|
||||
// Assembler.Add(new CPUx86.Move("[esp]", "eax"));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -2,16 +2,32 @@ using System;
|
|||
using System.IO;
|
||||
using Mono.Cecil;
|
||||
using Mono.Cecil.Cil;
|
||||
using CPU = Indy.IL2CPU.Assembler.X86;
|
||||
using CPU = Indy.IL2CPU.Assembler;
|
||||
using CPUx86 = Indy.IL2CPU.Assembler.X86;
|
||||
|
||||
namespace Indy.IL2CPU.IL.X86 {
|
||||
[OpCode(Code.Bge)]
|
||||
public class Bge: Op {
|
||||
public readonly string TargetLabel;
|
||||
public readonly string CurInstructionLabel;
|
||||
public Bge(Mono.Cecil.Cil.Instruction aInstruction, MethodInformation aMethodInfo)
|
||||
: base(aInstruction, aMethodInfo) {
|
||||
TargetLabel = GetInstructionLabel((Instruction)aInstruction.Operand);
|
||||
CurInstructionLabel = GetInstructionLabel(aInstruction);
|
||||
}
|
||||
public override void DoAssemble() {
|
||||
throw new NotImplementedException("This file has been autogenerated and not been changed afterwards!");
|
||||
string BaseLabel = CurInstructionLabel + "__";
|
||||
string LabelTrue = BaseLabel + "True";
|
||||
string LabelFalse = BaseLabel + "False";
|
||||
Assembler.Add(new CPUx86.Pop("eax"));
|
||||
Assembler.Add(new CPUx86.Compare("eax", "[esp]"));
|
||||
Assembler.Add(new CPUx86.JumpIfGreaterOrEquals(LabelTrue));
|
||||
Assembler.Add(new CPUx86.JumpAlways(LabelFalse));
|
||||
Assembler.Add(new CPU.Label(LabelTrue));
|
||||
Assembler.Add(new CPUx86.Add("esp", "4"));
|
||||
Assembler.Add(new CPUx86.JumpAlways(TargetLabel));
|
||||
Assembler.Add(new CPU.Label(LabelFalse));
|
||||
Assembler.Add(new CPUx86.Add("esp", "4"));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -6,12 +6,9 @@ using CPU = Indy.IL2CPU.Assembler.X86;
|
|||
|
||||
namespace Indy.IL2CPU.IL.X86 {
|
||||
[OpCode(Code.Bge_S)]
|
||||
public class Bge_S: Op {
|
||||
public class Bge_S: Bge {
|
||||
public Bge_S(Mono.Cecil.Cil.Instruction aInstruction, MethodInformation aMethodInfo)
|
||||
: base(aInstruction, aMethodInfo) {
|
||||
}
|
||||
public override void DoAssemble() {
|
||||
throw new NotImplementedException("This file has been autogenerated and not been changed afterwards!");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -2,16 +2,32 @@ using System;
|
|||
using System.IO;
|
||||
using Mono.Cecil;
|
||||
using Mono.Cecil.Cil;
|
||||
using CPU = Indy.IL2CPU.Assembler.X86;
|
||||
using CPU = Indy.IL2CPU.Assembler;
|
||||
using CPUx86 = Indy.IL2CPU.Assembler.X86;
|
||||
|
||||
namespace Indy.IL2CPU.IL.X86 {
|
||||
[OpCode(Code.Bgt)]
|
||||
public class Bgt: Op {
|
||||
public readonly string TargetLabel;
|
||||
public readonly string CurInstructionLabel;
|
||||
public Bgt(Mono.Cecil.Cil.Instruction aInstruction, MethodInformation aMethodInfo)
|
||||
: base(aInstruction, aMethodInfo) {
|
||||
TargetLabel = GetInstructionLabel((Instruction)aInstruction.Operand);
|
||||
CurInstructionLabel = GetInstructionLabel(aInstruction);
|
||||
}
|
||||
public override void DoAssemble() {
|
||||
throw new NotImplementedException("This file has been autogenerated and not been changed afterwards!");
|
||||
string BaseLabel = CurInstructionLabel + "__";
|
||||
string LabelTrue = BaseLabel + "True";
|
||||
string LabelFalse = BaseLabel + "False";
|
||||
Assembler.Add(new CPUx86.Pop("eax"));
|
||||
Assembler.Add(new CPUx86.Compare("eax", "[esp]"));
|
||||
Assembler.Add(new CPUx86.JumpIfGreater(LabelTrue));
|
||||
Assembler.Add(new CPUx86.JumpAlways(LabelFalse));
|
||||
Assembler.Add(new CPU.Label(LabelTrue));
|
||||
Assembler.Add(new CPUx86.Add("esp", "4"));
|
||||
Assembler.Add(new CPUx86.JumpAlways(TargetLabel));
|
||||
Assembler.Add(new CPU.Label(LabelFalse));
|
||||
Assembler.Add(new CPUx86.Add("esp", "4"));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -6,12 +6,9 @@ using CPU = Indy.IL2CPU.Assembler.X86;
|
|||
|
||||
namespace Indy.IL2CPU.IL.X86 {
|
||||
[OpCode(Code.Bgt_S)]
|
||||
public class Bgt_S: Op {
|
||||
public class Bgt_S: Bgt {
|
||||
public Bgt_S(Mono.Cecil.Cil.Instruction aInstruction, MethodInformation aMethodInfo)
|
||||
: base(aInstruction, aMethodInfo) {
|
||||
}
|
||||
public override void DoAssemble() {
|
||||
throw new NotImplementedException("This file has been autogenerated and not been changed afterwards!");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -2,16 +2,32 @@ using System;
|
|||
using System.IO;
|
||||
using Mono.Cecil;
|
||||
using Mono.Cecil.Cil;
|
||||
using CPU = Indy.IL2CPU.Assembler.X86;
|
||||
using CPU = Indy.IL2CPU.Assembler;
|
||||
using CPUx86 = Indy.IL2CPU.Assembler.X86;
|
||||
|
||||
namespace Indy.IL2CPU.IL.X86 {
|
||||
[OpCode(Code.Ble)]
|
||||
public class Ble: Op {
|
||||
public readonly string TargetLabel;
|
||||
public readonly string CurInstructionLabel;
|
||||
public Ble(Mono.Cecil.Cil.Instruction aInstruction, MethodInformation aMethodInfo)
|
||||
: base(aInstruction, aMethodInfo) {
|
||||
TargetLabel = GetInstructionLabel((Instruction)aInstruction.Operand);
|
||||
CurInstructionLabel = GetInstructionLabel(aInstruction);
|
||||
}
|
||||
public override void DoAssemble() {
|
||||
throw new NotImplementedException("This file has been autogenerated and not been changed afterwards!");
|
||||
string BaseLabel = CurInstructionLabel + "__";
|
||||
string LabelTrue = BaseLabel + "True";
|
||||
string LabelFalse = BaseLabel + "False";
|
||||
Assembler.Add(new CPUx86.Pop("eax"));
|
||||
Assembler.Add(new CPUx86.Compare("eax", "[esp]"));
|
||||
Assembler.Add(new CPUx86.JumpIfLessOrEqual(LabelTrue));
|
||||
Assembler.Add(new CPUx86.JumpAlways(LabelFalse));
|
||||
Assembler.Add(new CPU.Label(LabelTrue));
|
||||
Assembler.Add(new CPUx86.Add("esp", "4"));
|
||||
Assembler.Add(new CPUx86.JumpAlways(TargetLabel));
|
||||
Assembler.Add(new CPU.Label(LabelFalse));
|
||||
Assembler.Add(new CPUx86.Add("esp", "4"));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -6,12 +6,9 @@ using CPU = Indy.IL2CPU.Assembler.X86;
|
|||
|
||||
namespace Indy.IL2CPU.IL.X86 {
|
||||
[OpCode(Code.Ble_S)]
|
||||
public class Ble_S: Op {
|
||||
public class Ble_S: Ble {
|
||||
public Ble_S(Mono.Cecil.Cil.Instruction aInstruction, MethodInformation aMethodInfo)
|
||||
: base(aInstruction, aMethodInfo) {
|
||||
}
|
||||
public override void DoAssemble() {
|
||||
throw new NotImplementedException("This file has been autogenerated and not been changed afterwards!");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -2,16 +2,32 @@ using System;
|
|||
using System.IO;
|
||||
using Mono.Cecil;
|
||||
using Mono.Cecil.Cil;
|
||||
using CPU = Indy.IL2CPU.Assembler.X86;
|
||||
using CPU = Indy.IL2CPU.Assembler;
|
||||
using CPUx86 = Indy.IL2CPU.Assembler.X86;
|
||||
|
||||
namespace Indy.IL2CPU.IL.X86 {
|
||||
[OpCode(Code.Blt)]
|
||||
public class Blt: Op {
|
||||
public readonly string TargetLabel;
|
||||
public readonly string CurInstructionLabel;
|
||||
public Blt(Mono.Cecil.Cil.Instruction aInstruction, MethodInformation aMethodInfo)
|
||||
: base(aInstruction, aMethodInfo) {
|
||||
TargetLabel = GetInstructionLabel((Instruction)aInstruction.Operand);
|
||||
CurInstructionLabel = GetInstructionLabel(aInstruction);
|
||||
}
|
||||
public override void DoAssemble() {
|
||||
throw new NotImplementedException("This file has been autogenerated and not been changed afterwards!");
|
||||
string BaseLabel = CurInstructionLabel + "__";
|
||||
string LabelTrue = BaseLabel + "True";
|
||||
string LabelFalse = BaseLabel + "False";
|
||||
Assembler.Add(new CPUx86.Pop("eax"));
|
||||
Assembler.Add(new CPUx86.Compare("eax", "[esp]"));
|
||||
Assembler.Add(new CPUx86.JumpIfLess(LabelTrue));
|
||||
Assembler.Add(new CPUx86.JumpAlways(LabelFalse));
|
||||
Assembler.Add(new CPU.Label(LabelTrue));
|
||||
Assembler.Add(new CPUx86.Add("esp", "4"));
|
||||
Assembler.Add(new CPUx86.JumpAlways(TargetLabel));
|
||||
Assembler.Add(new CPU.Label(LabelFalse));
|
||||
Assembler.Add(new CPUx86.Add("esp", "4"));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -6,12 +6,9 @@ using CPU = Indy.IL2CPU.Assembler.X86;
|
|||
|
||||
namespace Indy.IL2CPU.IL.X86 {
|
||||
[OpCode(Code.Blt_S)]
|
||||
public class Blt_S: Op {
|
||||
public class Blt_S: Blt {
|
||||
public Blt_S(Mono.Cecil.Cil.Instruction aInstruction, MethodInformation aMethodInfo)
|
||||
: base(aInstruction, aMethodInfo) {
|
||||
}
|
||||
public override void DoAssemble() {
|
||||
throw new NotImplementedException("This file has been autogenerated and not been changed afterwards!");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -2,16 +2,32 @@ using System;
|
|||
using System.IO;
|
||||
using Mono.Cecil;
|
||||
using Mono.Cecil.Cil;
|
||||
using CPU = Indy.IL2CPU.Assembler.X86;
|
||||
using CPU = Indy.IL2CPU.Assembler;
|
||||
using CPUx86 = Indy.IL2CPU.Assembler.X86;
|
||||
|
||||
namespace Indy.IL2CPU.IL.X86 {
|
||||
[OpCode(Code.Bne_Un)]
|
||||
public class Bne_Un: Op {
|
||||
public readonly string TargetLabel;
|
||||
public readonly string CurInstructionLabel;
|
||||
public Bne_Un(Mono.Cecil.Cil.Instruction aInstruction, MethodInformation aMethodInfo)
|
||||
: base(aInstruction, aMethodInfo) {
|
||||
TargetLabel = GetInstructionLabel((Instruction)aInstruction.Operand);
|
||||
CurInstructionLabel = GetInstructionLabel(aInstruction);
|
||||
}
|
||||
public override void DoAssemble() {
|
||||
throw new NotImplementedException("This file has been autogenerated and not been changed afterwards!");
|
||||
string BaseLabel = CurInstructionLabel + "__";
|
||||
string LabelTrue = BaseLabel + "True";
|
||||
string LabelFalse = BaseLabel + "False";
|
||||
Assembler.Add(new CPUx86.Pop("eax"));
|
||||
Assembler.Add(new CPUx86.Compare("eax", "[esp]"));
|
||||
Assembler.Add(new CPUx86.JumpIfEquals(LabelTrue));
|
||||
Assembler.Add(new CPUx86.JumpAlways(LabelFalse));
|
||||
Assembler.Add(new CPU.Label(LabelFalse));
|
||||
Assembler.Add(new CPUx86.Add("esp", "4"));
|
||||
Assembler.Add(new CPUx86.JumpAlways(TargetLabel));
|
||||
Assembler.Add(new CPU.Label(LabelTrue));
|
||||
Assembler.Add(new CPUx86.Add("esp", "4"));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -6,12 +6,9 @@ using CPU = Indy.IL2CPU.Assembler.X86;
|
|||
|
||||
namespace Indy.IL2CPU.IL.X86 {
|
||||
[OpCode(Code.Bne_Un_S)]
|
||||
public class Bne_Un_S: Op {
|
||||
public class Bne_Un_S: Bne_Un {
|
||||
public Bne_Un_S(Mono.Cecil.Cil.Instruction aInstruction, MethodInformation aMethodInfo)
|
||||
: base(aInstruction, aMethodInfo) {
|
||||
}
|
||||
public override void DoAssemble() {
|
||||
throw new NotImplementedException("This file has been autogenerated and not been changed afterwards!");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -7,11 +7,15 @@ using CPU = Indy.IL2CPU.Assembler.X86;
|
|||
namespace Indy.IL2CPU.IL.X86 {
|
||||
[OpCode(Code.Brfalse)]
|
||||
public class Brfalse: Op {
|
||||
public readonly string TargetLabel;
|
||||
public Brfalse(Mono.Cecil.Cil.Instruction aInstruction, MethodInformation aMethodInfo)
|
||||
: base(aInstruction, aMethodInfo) {
|
||||
TargetLabel = GetInstructionLabel((Instruction)aInstruction.Operand);
|
||||
}
|
||||
public override void DoAssemble() {
|
||||
throw new NotImplementedException("This file has been autogenerated and not been changed afterwards!");
|
||||
Assembler.Add(new CPU.Popd("eax"));
|
||||
Assembler.Add(new CPU.Compare("eax", "00h"));
|
||||
Assembler.Add(new CPU.JumpIfEquals(TargetLabel));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -6,12 +6,9 @@ using CPU = Indy.IL2CPU.Assembler.X86;
|
|||
|
||||
namespace Indy.IL2CPU.IL.X86 {
|
||||
[OpCode(Code.Brfalse_S)]
|
||||
public class Brfalse_S: Op {
|
||||
public class Brfalse_S: Brfalse {
|
||||
public Brfalse_S(Mono.Cecil.Cil.Instruction aInstruction, MethodInformation aMethodInfo)
|
||||
: base(aInstruction, aMethodInfo) {
|
||||
}
|
||||
public override void DoAssemble() {
|
||||
throw new NotImplementedException("This file has been autogenerated and not been changed afterwards!");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -11,7 +11,8 @@ namespace Indy.IL2CPU.IL.X86 {
|
|||
: base(aInstruction, aMethodInfo) {
|
||||
}
|
||||
public override void DoAssemble() {
|
||||
throw new NotImplementedException("This file has been autogenerated and not been changed afterwards!");
|
||||
// todo: WARNING: not implemented correctly!
|
||||
//throw new NotImplementedException("This file has been autogenerated and not been changed afterwards!");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -11,7 +11,8 @@ namespace Indy.IL2CPU.IL.X86 {
|
|||
: base(aInstruction, aMethodInfo) {
|
||||
}
|
||||
public override void DoAssemble() {
|
||||
throw new NotImplementedException("This file has been autogenerated and not been changed afterwards!");
|
||||
// todo: check for correctness
|
||||
//throw new NotImplementedException("This file has been autogenerated and not been changed afterwards!");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -11,7 +11,8 @@ namespace Indy.IL2CPU.IL.X86 {
|
|||
: base(aInstruction, aMethodInfo) {
|
||||
}
|
||||
public override void DoAssemble() {
|
||||
throw new NotImplementedException("This file has been autogenerated and not been changed afterwards!");
|
||||
// TODO: unimplemented
|
||||
//throw new NotImplementedException("This file has been autogenerated and not been changed afterwards!");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -2,16 +2,29 @@ using System;
|
|||
using System.IO;
|
||||
using Mono.Cecil;
|
||||
using Mono.Cecil.Cil;
|
||||
using CPU = Indy.IL2CPU.Assembler.X86;
|
||||
using CPU = Indy.IL2CPU.Assembler;
|
||||
using CPUx86 = Indy.IL2CPU.Assembler.X86;
|
||||
|
||||
namespace Indy.IL2CPU.IL.X86 {
|
||||
[OpCode(Code.Ldelem_Ref, false)]
|
||||
public class Ldelem_Ref: Op {
|
||||
public Ldelem_Ref(Mono.Cecil.Cil.Instruction aInstruction, MethodInformation aMethodInfo)
|
||||
public Ldelem_Ref(Instruction aInstruction, MethodInformation aMethodInfo)
|
||||
: base(aInstruction, aMethodInfo) {
|
||||
}
|
||||
|
||||
public static void Assemble(CPU.Assembler aAssembler) {
|
||||
aAssembler.Add(new CPUx86.Pop("eax"));
|
||||
aAssembler.Add(new CPUx86.Move("edx", "4"));
|
||||
aAssembler.Add(new CPUx86.Multiply("edx"));
|
||||
aAssembler.Add(new CPUx86.Add("eax", "0" + (ObjectImpl.FieldDataOffset + 4).ToString("X") + "h"));
|
||||
aAssembler.Add(new CPUx86.Pop("edx"));
|
||||
aAssembler.Add(new CPUx86.Add("edx", "eax"));
|
||||
aAssembler.Add(new CPUx86.Move("eax", "[edx]"));
|
||||
aAssembler.Add(new CPUx86.Pushd("eax"));
|
||||
}
|
||||
|
||||
public override void DoAssemble() {
|
||||
throw new NotImplementedException("This file has been autogenerated and not been changed afterwards!");
|
||||
Assemble(Assembler);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -2,16 +2,28 @@ using System;
|
|||
using System.IO;
|
||||
using Mono.Cecil;
|
||||
using Mono.Cecil.Cil;
|
||||
using CPU = Indy.IL2CPU.Assembler.X86;
|
||||
using CPU = Indy.IL2CPU.Assembler;
|
||||
using CPUx86 = Indy.IL2CPU.Assembler.X86;
|
||||
|
||||
namespace Indy.IL2CPU.IL.X86 {
|
||||
[OpCode(Code.Ldelema, false)]
|
||||
public class Ldelema: Op {
|
||||
public Ldelema(Mono.Cecil.Cil.Instruction aInstruction, MethodInformation aMethodInfo)
|
||||
public Ldelema(Instruction aInstruction, MethodInformation aMethodInfo)
|
||||
: base(aInstruction, aMethodInfo) {
|
||||
}
|
||||
|
||||
public static void Assemble(CPU.Assembler aAssembler) {
|
||||
aAssembler.Add(new CPUx86.Pop("eax"));
|
||||
aAssembler.Add(new CPUx86.Move("edx", "4"));
|
||||
aAssembler.Add(new CPUx86.Multiply("edx"));
|
||||
aAssembler.Add(new CPUx86.Add("eax", "0" + (ObjectImpl.FieldDataOffset + 4).ToString("X") + "h"));
|
||||
aAssembler.Add(new CPUx86.Pop("edx"));
|
||||
aAssembler.Add(new CPUx86.Add("edx", "eax"));
|
||||
aAssembler.Add(new CPUx86.Pushd("edx"));
|
||||
}
|
||||
|
||||
public override void DoAssemble() {
|
||||
throw new NotImplementedException("This file has been autogenerated and not been changed afterwards!");
|
||||
Assemble(Assembler);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -11,7 +11,7 @@ namespace Indy.IL2CPU.IL.X86 {
|
|||
: base(aInstruction, aMethodInfo) {
|
||||
}
|
||||
public override void DoAssemble() {
|
||||
throw new NotImplementedException("This file has been autogenerated and not been changed afterwards!");
|
||||
Pushd("0");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -11,7 +11,8 @@ namespace Indy.IL2CPU.IL.X86 {
|
|||
: base(aInstruction, aMethodInfo) {
|
||||
}
|
||||
public override void DoAssemble() {
|
||||
throw new NotImplementedException("This file has been autogenerated and not been changed afterwards!");
|
||||
// todo: implement correctly
|
||||
//throw new NotImplementedException("This file has been autogenerated and not been changed afterwards!");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -7,11 +7,16 @@ using CPU = Indy.IL2CPU.Assembler.X86;
|
|||
namespace Indy.IL2CPU.IL.X86 {
|
||||
[OpCode(Code.Ldsflda)]
|
||||
public class Ldsflda: Op {
|
||||
private readonly string mDataName;
|
||||
|
||||
public Ldsflda(Mono.Cecil.Cil.Instruction aInstruction, MethodInformation aMethodInfo)
|
||||
: base(aInstruction, aMethodInfo) {
|
||||
FieldReference xField = (FieldReference)aInstruction.Operand;
|
||||
DoQueueStaticField(xField.DeclaringType.Module.Assembly.Name.Name, xField.DeclaringType.FullName, xField.Name, out mDataName);
|
||||
}
|
||||
|
||||
public override void DoAssemble() {
|
||||
throw new NotImplementedException("This file has been autogenerated and not been changed afterwards!");
|
||||
Pushd(mDataName);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -6,12 +6,13 @@ using CPU = Indy.IL2CPU.Assembler.X86;
|
|||
|
||||
namespace Indy.IL2CPU.IL.X86 {
|
||||
[OpCode(Code.Leave)]
|
||||
public class Leave: Op {
|
||||
public Leave(Mono.Cecil.Cil.Instruction aInstruction, MethodInformation aMethodInfo)
|
||||
public class Leave: Op {public readonly string TargetLabel;
|
||||
public Leave(Mono.Cecil.Cil.Instruction aInstruction, MethodInformation aMethodInfo)
|
||||
: base(aInstruction, aMethodInfo) {
|
||||
TargetLabel = GetInstructionLabel((Instruction)aInstruction.Operand);
|
||||
}
|
||||
public override void DoAssemble() {
|
||||
throw new NotImplementedException("This file has been autogenerated and not been changed afterwards!");
|
||||
JumpAlways(TargetLabel);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -6,12 +6,9 @@ using CPU = Indy.IL2CPU.Assembler.X86;
|
|||
|
||||
namespace Indy.IL2CPU.IL.X86 {
|
||||
[OpCode(Code.Leave_S)]
|
||||
public class Leave_S: Op {
|
||||
public class Leave_S: Leave {
|
||||
public Leave_S(Mono.Cecil.Cil.Instruction aInstruction, MethodInformation aMethodInfo)
|
||||
: base(aInstruction, aMethodInfo) {
|
||||
}
|
||||
public override void DoAssemble() {
|
||||
throw new NotImplementedException("This file has been autogenerated and not been changed afterwards!");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -2,7 +2,8 @@ using System;
|
|||
using System.IO;
|
||||
using Mono.Cecil;
|
||||
using Mono.Cecil.Cil;
|
||||
using CPU = Indy.IL2CPU.Assembler.X86;
|
||||
using CPU = Indy.IL2CPU.Assembler;
|
||||
using CPUx86 = Indy.IL2CPU.Assembler.X86;
|
||||
|
||||
namespace Indy.IL2CPU.IL.X86 {
|
||||
[OpCode(Code.Stelem_Ref, false)]
|
||||
|
|
@ -10,8 +11,21 @@ namespace Indy.IL2CPU.IL.X86 {
|
|||
public Stelem_Ref(Mono.Cecil.Cil.Instruction aInstruction, MethodInformation aMethodInfo)
|
||||
: base(aInstruction, aMethodInfo) {
|
||||
}
|
||||
public static void Assemble(CPU.Assembler aAssembler) {
|
||||
// stack - 3 == the array
|
||||
// stack - 2 == the index
|
||||
// stack - 1 == the new value
|
||||
aAssembler.Add(new CPUx86.Pop("ecx")); // the new value;
|
||||
aAssembler.Add(new CPUx86.Pop("eax")); // the index
|
||||
aAssembler.Add(new CPUx86.Move("edx", "4"));
|
||||
aAssembler.Add(new CPUx86.Multiply("edx"));
|
||||
aAssembler.Add(new CPUx86.Add("eax", "0" + (ObjectImpl.FieldDataOffset + 4).ToString("X") + "h"));
|
||||
aAssembler.Add(new CPUx86.Pop("edx"));
|
||||
aAssembler.Add(new CPUx86.Add("edx", "eax"));
|
||||
aAssembler.Add(new CPUx86.Move("[edx]", "ecx"));
|
||||
}
|
||||
public override void DoAssemble() {
|
||||
throw new NotImplementedException("This file has been autogenerated and not been changed afterwards!");
|
||||
Assemble(Assembler);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -11,7 +11,8 @@ namespace Indy.IL2CPU.IL.X86 {
|
|||
: base(aInstruction, aMethodInfo) {
|
||||
}
|
||||
public override void DoAssemble() {
|
||||
throw new NotImplementedException("This file has been autogenerated and not been changed afterwards!");
|
||||
// TODO: unimplemented
|
||||
Assembler.Add(new CPU.Add("esp", "4"));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -50,29 +50,31 @@ namespace Indy.IL2CPU.IL.X86 {
|
|||
protected override void Assemble_System_Void___System_Runtime_CompilerServices_RuntimeHelpers_InitializeArray___System_Array__System_RuntimeFieldHandle___() {
|
||||
// Arguments:
|
||||
// Array aArray, RuntimeFieldHandle aFieldHandle
|
||||
Assembler.Add(new CPUx86.Pushd(MethodInfo.Arguments[0].VirtualAddress));
|
||||
Assembler.Add(new CPUx86.Pushd(MethodInfo.Arguments[1].VirtualAddress));
|
||||
Op x = new Call(Engine.GetMethodDefinition(Engine.GetTypeDefinition("", "Indy.IL2CPU.CustomImplementation.CompilerServices.RuntimeHelpers"), "InitializeArrayImpl", "System.Int32[]", "System.Int32[]"));
|
||||
x.Assembler = Assembler;
|
||||
x.Assemble();
|
||||
// Assembler.Add(new CPUx86.Move("eax", "0"));
|
||||
// Assembler.Add(new CPUx86.Move("edi", "[" + MethodInfo.Arguments[0].VirtualAddress + "]"));
|
||||
// Assembler.Add(new CPUx86.Move("esi", "[" + MethodInfo.Arguments[1].VirtualAddress + "]"));
|
||||
// Assembler.Add(new CPUx86.Move("ecx", "[esi]"));
|
||||
// Assembler.Add(new CPUx86.Add("dword esi", "12"));
|
||||
// Assembler.Add(new CPUx86.Add("dword edi", "12"));
|
||||
//
|
||||
// Assembler.Add(new CPU.Label(".StartLoop"));
|
||||
// Assembler.Add(new CPUx86.Move("edx", "[esi]"));
|
||||
// Assembler.Add(new CPUx86.Move("[edi]", "edx"));
|
||||
// Assembler.Add(new CPUx86.Add("eax", "4"));
|
||||
// Assembler.Add(new CPUx86.Add("dword esi", "4"));
|
||||
// Assembler.Add(new CPUx86.Add("dword edi", "4"));
|
||||
// Assembler.Add(new CPUx86.Compare("eax", "ecx"));
|
||||
// Assembler.Add(new CPUx86.JumpIfEquals(".EndLoop"));
|
||||
// Assembler.Add(new CPUx86.JumpAlways(".StartLoop"));
|
||||
//
|
||||
// Assembler.Add(new CPU.Label(".EndLoop"));
|
||||
// Assembler.Add(new CPUx86.Pushd(MethodInfo.Arguments[0].VirtualAddress));
|
||||
// Assembler.Add(new CPUx86.Pushd(MethodInfo.Arguments[1].VirtualAddress));
|
||||
// Op x = new Call(Engine.GetMethodDefinition(Engine.GetTypeDefinition("", "Indy.IL2CPU.CustomImplementation.CompilerServices.RuntimeHelpers"), "InitializeArrayImpl", "System.Int32[]", "System.Int32[]"));
|
||||
// x.Assembler = Assembler;
|
||||
// x.Assemble();
|
||||
Assembler.Add(new CPU.Literal(";In Pure ASM defined"));
|
||||
Assembler.Add(new CPUx86.Move("eax", "0"));
|
||||
Assembler.Add(new CPUx86.Move("edi", "[" + MethodInfo.Arguments[0].VirtualAddress + "]"));
|
||||
Assembler.Add(new CPUx86.Move("esi", "[" + MethodInfo.Arguments[1].VirtualAddress + "]"));
|
||||
Assembler.Add(new CPUx86.Add("dword esi", "8"));
|
||||
Assembler.Add(new CPUx86.Move("ecx", "[esi]"));
|
||||
Assembler.Add(new CPUx86.Add("dword esi", "4"));
|
||||
Assembler.Add(new CPUx86.Add("dword edi", "12"));
|
||||
|
||||
Assembler.Add(new CPU.Label(".StartLoop"));
|
||||
Assembler.Add(new CPUx86.Move("edx", "[esi]"));
|
||||
Assembler.Add(new CPUx86.Move("[edi]", "edx"));
|
||||
Assembler.Add(new CPUx86.Add("eax", "4"));
|
||||
Assembler.Add(new CPUx86.Add("dword esi", "4"));
|
||||
Assembler.Add(new CPUx86.Add("dword edi", "4"));
|
||||
Assembler.Add(new CPUx86.Compare("eax", "ecx"));
|
||||
Assembler.Add(new CPUx86.JumpIfEquals(".EndLoop"));
|
||||
Assembler.Add(new CPUx86.JumpAlways(".StartLoop"));
|
||||
|
||||
Assembler.Add(new CPU.Label(".EndLoop"));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -8,7 +8,7 @@ namespace Indy.IL2CPU.CustomImplementation.CompilerServices {
|
|||
//[DllImport("test.dll")]
|
||||
//public static extern void InitializeArray(Array aArray, RuntimeFieldHandle aFieldHandle);
|
||||
public static void InitializeArrayImpl(int[] aArray, int[] aFieldHandle) {
|
||||
for (int i = 0; i < aFieldHandle.Length; i++) {
|
||||
for (int i = 0; i < aArray.Length; i++) {
|
||||
aArray[i] = aFieldHandle[i];
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -142,6 +142,9 @@ namespace Indy.IL2CPU {
|
|||
if (mCurrent == null) {
|
||||
throw new Exception("No Current engine found!");
|
||||
}
|
||||
if(aRef.FullName.Contains("modreq")) {
|
||||
aRef = aRef.GetOriginalType();
|
||||
}
|
||||
if (aRef.FullName.EndsWith("[]")) {
|
||||
return GetTypeDefinition(aRef.Module.Assembly.Name.Name, aRef.FullName.Substring(0, aRef.FullName.Length - 2));
|
||||
}
|
||||
|
|
@ -172,7 +175,7 @@ namespace Indy.IL2CPU {
|
|||
mCurrent.OnDebugLog("Error: Unhandled scope: " + aRef.Scope == null ? "**NULL**" : aRef.Scope.GetType().FullName);
|
||||
}
|
||||
}
|
||||
throw new Exception("Could not find TypeDefinition! (" + aRef.FullName + ")");
|
||||
throw new Exception("Could not find TypeDefinition! (" + aRef.FullName + " in assembly " + aRef.Module.Assembly.Name.Name + ")");
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
|
@ -222,6 +225,9 @@ namespace Indy.IL2CPU {
|
|||
} else {
|
||||
if (xCurrentField.InitialValue != null && xCurrentField.InitialValue.Length > 0) {
|
||||
string xTheData = "";
|
||||
if(xCurrentField.InitialValue.Length>4) {
|
||||
xTheData = "0,0,0,0,2,0,0,0,";
|
||||
}
|
||||
foreach (byte x in BitConverter.GetBytes(xCurrentField.InitialValue.Length)) {
|
||||
xTheData += x + ",";
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue