mirror of
https://github.com/danbulant/Cosmos
synced 2026-05-22 05:48:37 +00:00
[*] Fixed error with bge.
[+] Bge_Un works with 64-bit values.
This commit is contained in:
parent
062a1f46b6
commit
539933db9c
6 changed files with 109 additions and 31 deletions
|
|
@ -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
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -60,7 +60,9 @@
|
|||
<Compile Include="CmpXchg.cs" />
|
||||
<Compile Include="Compare.cs" />
|
||||
<Compile Include="IDivide.cs" />
|
||||
<Compile Include="JumpIfBelowOrEqual.cs" />
|
||||
<Compile Include="JumpIfCarry.cs" />
|
||||
<Compile Include="JumpIfGreaterOrEqual.cs" />
|
||||
<Compile Include="JumpIfNotZero.cs" />
|
||||
<Compile Include="Stosw.cs" />
|
||||
<Compile Include="JumpNotCary.cs" />
|
||||
|
|
|
|||
23
source/Indy.IL2CPU.Assembler.X86/JumpIfBelowOrEqual.cs
Normal file
23
source/Indy.IL2CPU.Assembler.X86/JumpIfBelowOrEqual.cs
Normal file
|
|
@ -0,0 +1,23 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
|
||||
namespace Indy.IL2CPU.Assembler.X86
|
||||
{
|
||||
/// <summary>
|
||||
/// Represents the JBE opcode
|
||||
/// </summary>
|
||||
[OpCode(0xFFFFFFFF, "jbe")]
|
||||
public class JumpIfBelowOrEqual : JumpBase
|
||||
{
|
||||
public JumpIfBelowOrEqual(string aAddress)
|
||||
: base(aAddress)
|
||||
{
|
||||
}
|
||||
public override string ToString()
|
||||
{
|
||||
return "jbe " + Address;
|
||||
}
|
||||
}
|
||||
}
|
||||
23
source/Indy.IL2CPU.Assembler.X86/JumpIfGreaterOrEqual.cs
Normal file
23
source/Indy.IL2CPU.Assembler.X86/JumpIfGreaterOrEqual.cs
Normal file
|
|
@ -0,0 +1,23 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
|
||||
namespace Indy.IL2CPU.Assembler.X86
|
||||
{
|
||||
/// <summary>
|
||||
/// Represents the JGE opcode
|
||||
/// </summary>
|
||||
[OpCode(0xFFFFFFFF, "jge")]
|
||||
public class JumpIfGreaterOrEqual : JumpBase
|
||||
{
|
||||
public JumpIfGreaterOrEqual(string aAddress)
|
||||
: base(aAddress)
|
||||
{
|
||||
}
|
||||
public override string ToString()
|
||||
{
|
||||
return "jge " + Address;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -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() {
|
||||
|
|
|
|||
|
|
@ -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");
|
||||
}
|
||||
}
|
||||
}
|
||||
Loading…
Reference in a new issue