diff --git a/source/Boot/TestSuite/Tests/MathTest.cs b/source/Boot/TestSuite/Tests/MathTest.cs
index cd18fbb71..b9a449ded 100644
--- a/source/Boot/TestSuite/Tests/MathTest.cs
+++ b/source/Boot/TestSuite/Tests/MathTest.cs
@@ -52,17 +52,42 @@ namespace TestSuite.Tests
#region bge
Console.ForegroundColor = ConsoleColor.Red;
if (0xFFFFFFF000000002L >= 0xFFFFFFF000000002L) Console.ForegroundColor = ConsoleColor.White;
- Console.Write("bge[e] ");
- Console.ForegroundColor = ConsoleColor.Red;
- if (!(0xFFFFFFF000000002L >= 0xFFFFFFFFFFFFFFFFL)) Console.ForegroundColor = ConsoleColor.White;
- Console.Write("bge[!] ");
+ Console.Write("bge[e-] ");
+
+ Console.ForegroundColor = ConsoleColor.White;
+ if (0xFFFFFFF000000002L >= 0xFFFFFFFFFFFFFFFFL) Console.ForegroundColor = ConsoleColor.Red;
+ Console.Write("bge[!-] ");
+
Console.ForegroundColor = ConsoleColor.Red;
if (0xFFFFFFFFFFFFFFFFL >= 0xFFFFFFF000000002L) Console.ForegroundColor = ConsoleColor.White;
- Console.Write("bge[g]");
+ Console.Write("bge[g-] ");
+
+ Console.ForegroundColor = ConsoleColor.Red;
+ if (0L >= -2L) Console.ForegroundColor = ConsoleColor.White;
+ Console.Write("bge[g0>=-]");
+
Console.WriteLine("");
- #endregion
+ #endregion bge
+ #region bge_un
+ Console.ForegroundColor = ConsoleColor.Red;
+ if (0xFFFFFFF000000002LU >= 0xFFFFFFF000000002LU) Console.ForegroundColor = ConsoleColor.White;
+ Console.Write("bge_un[e] ");
+ Console.ForegroundColor = ConsoleColor.White;
+ if (0xFFFFFFF000000002LU >= 0xFFFFFFFFFFFFFFFFLU) Console.ForegroundColor = ConsoleColor.Red;
+ Console.Write("bge_un[!] ");
+
+ Console.ForegroundColor = ConsoleColor.Red;
+ if (0xFFFFFFFFFFFFFFFFLU >= 0xFFFFFFF000000002LU) Console.ForegroundColor = ConsoleColor.White;
+ Console.Write("bge_un[g] ");
+
+ Console.ForegroundColor = ConsoleColor.White;
+ if (0x0000LU >= 0xFFFFFFF000000002LU) Console.ForegroundColor = ConsoleColor.Red;
+ Console.Write("bge_un[g0>=\"-\"]");
+
+ Console.WriteLine("");
+ #endregion bge_un
}
}
}
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 7937dcaa4..b4a870a16 100644
--- a/source/Indy.IL2CPU.Assembler.X86/Indy.IL2CPU.Assembler.X86.csproj
+++ b/source/Indy.IL2CPU.Assembler.X86/Indy.IL2CPU.Assembler.X86.csproj
@@ -60,7 +60,9 @@
+
+
diff --git a/source/Indy.IL2CPU.Assembler.X86/JumpIfBelowOrEqual.cs b/source/Indy.IL2CPU.Assembler.X86/JumpIfBelowOrEqual.cs
new file mode 100644
index 000000000..3bdc2f095
--- /dev/null
+++ b/source/Indy.IL2CPU.Assembler.X86/JumpIfBelowOrEqual.cs
@@ -0,0 +1,23 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+
+namespace Indy.IL2CPU.Assembler.X86
+{
+ ///
+ /// Represents the JBE opcode
+ ///
+ [OpCode(0xFFFFFFFF, "jbe")]
+ public class JumpIfBelowOrEqual : JumpBase
+ {
+ public JumpIfBelowOrEqual(string aAddress)
+ : base(aAddress)
+ {
+ }
+ public override string ToString()
+ {
+ return "jbe " + Address;
+ }
+ }
+}
\ No newline at end of file
diff --git a/source/Indy.IL2CPU.Assembler.X86/JumpIfGreaterOrEqual.cs b/source/Indy.IL2CPU.Assembler.X86/JumpIfGreaterOrEqual.cs
new file mode 100644
index 000000000..d44432a21
--- /dev/null
+++ b/source/Indy.IL2CPU.Assembler.X86/JumpIfGreaterOrEqual.cs
@@ -0,0 +1,23 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+
+namespace Indy.IL2CPU.Assembler.X86
+{
+ ///
+ /// Represents the JGE opcode
+ ///
+ [OpCode(0xFFFFFFFF, "jge")]
+ public class JumpIfGreaterOrEqual : JumpBase
+ {
+ public JumpIfGreaterOrEqual(string aAddress)
+ : base(aAddress)
+ {
+ }
+ public override string ToString()
+ {
+ return "jge " + Address;
+ }
+ }
+}
diff --git a/source/Indy.IL2CPU.IL.X86/Bge.cs b/source/Indy.IL2CPU.IL.X86/Bge.cs
index 1c58035e1..3f5d4d691 100644
--- a/source/Indy.IL2CPU.IL.X86/Bge.cs
+++ b/source/Indy.IL2CPU.IL.X86/Bge.cs
@@ -55,12 +55,11 @@ namespace Indy.IL2CPU.IL.X86 {
new CPUx86.Pop("ebx");
new CPUx86.Pop("ecx");
//value1: ECX:EBX
- new CPUx86.Sub("eax", "ebx");
- //lowers
- new CPUx86.SubWithCarry("edx", "ecx");
- //highs
+ new CPUx86.Sub("ebx", "eax");
+ new CPUx86.SubWithCarry("ecx", "edx");
+ //result = value2 - value1
//result is less then zero then value1 > value2
- new CPUx86.JumpIfLessOrEqual(TargetLabel);
+ new CPUx86.JumpIfGreaterOrEqual(TargetLabel);
}
public override void DoAssemble() {
diff --git a/source/Indy.IL2CPU.IL.X86/Bge_Un.cs b/source/Indy.IL2CPU.IL.X86/Bge_Un.cs
index 572a56238..d4660a07e 100644
--- a/source/Indy.IL2CPU.IL.X86/Bge_Un.cs
+++ b/source/Indy.IL2CPU.IL.X86/Bge_Un.cs
@@ -26,27 +26,33 @@ namespace Indy.IL2CPU.IL.X86 {
string BaseLabel = CurInstructionLabel + "__";
string LabelTrue = BaseLabel + "True";
string LabelFalse = BaseLabel + "False";
- new CPUx86.Pop(CPUx86.Registers.EAX);
- if (xSize > 4) {
- throw new NotImplementedException("long comprasion is not implemented");
- new CPUx86.Add("esp", "4");
+ if (xSize > 4)
+ {
+ //target label is then value1 >= value2
+ new CPUx86.Pop(CPUx86.Registers.EAX);
+ new CPUx86.Pop(CPUx86.Registers.EDX);
+ //value2: EDX:EAX
+ new CPUx86.Pop("ebx");
+ new CPUx86.Pop("ecx");
+ //value1: ECX:EBX
+ new CPUx86.Sub("eax", "ebx");
+ //lowers
+ new CPUx86.SubWithCarry("edx", "ecx");
+ //highs
+ //result is less then zero then value1 > value2
+ new CPUx86.JumpIfBelowOrEqual(TargetLabel);
+ }else
+ {
+ new CPUx86.Pop(CPUx86.Registers.EAX);
+ new CPUx86.Compare(CPUx86.Registers.EAX, CPUx86.Registers.AtESP);
+ new CPUx86.JumpIfGreaterOrEquals(LabelFalse);
+ new CPUx86.JumpAlways(LabelTrue);
+ new CPU.Label(LabelTrue);
+ new CPUx86.Add(CPUx86.Registers.ESP, "4");
+ new CPUx86.JumpAlways(TargetLabel);
+ new CPU.Label(LabelFalse);
+ new CPUx86.Add(CPUx86.Registers.ESP, "4");
}
- new CPUx86.Compare(CPUx86.Registers.EAX, CPUx86.Registers.AtESP);
- new CPUx86.JumpIfGreaterOrEquals(LabelFalse);
- new CPUx86.JumpAlways(LabelTrue);
- new CPU.Label(LabelTrue);
- if (xSize > 4) {
- throw new NotImplementedException("long comprasion is not implemented");
- new CPUx86.Add("esp", "4");
- }
- new CPUx86.Add(CPUx86.Registers.ESP, "4");
- new CPUx86.JumpAlways(TargetLabel);
- new CPU.Label(LabelFalse);
- if (xSize > 4) {
- throw new NotImplementedException("long comprasion is not implemented");
- new CPUx86.Add("esp", "4");
- }
- new CPUx86.Add(CPUx86.Registers.ESP, "4");
}
}
}
\ No newline at end of file