mirror of
https://github.com/danbulant/Cosmos
synced 2026-06-06 16:22:40 +00:00
Int64:
[+] equality comparing [+] add operation Int32: [*] Fixed bge instruction
This commit is contained in:
parent
859c35a5e0
commit
4aa8fcce86
8 changed files with 109 additions and 32 deletions
|
|
@ -29,10 +29,10 @@ namespace TestSuite.Tests
|
||||||
Assert(5 - 2 == 3, "5 - 2 == 3");
|
Assert(5 - 2 == 3, "5 - 2 == 3");
|
||||||
Assert(2 + 5 * 2 == 12, "2 + 5 * 2 == 12");
|
Assert(2 + 5 * 2 == 12, "2 + 5 * 2 == 12");
|
||||||
Assert((2 + 5) * 2 == 14, "(2 + 5) * 2 == 14");
|
Assert((2 + 5) * 2 == 14, "(2 + 5) * 2 == 14");
|
||||||
//long al = 0x1FFFFFFFF;
|
long al = 0x1FFFFFFFF;
|
||||||
//long bl = 0x1FFFFFFFF;//1L;
|
long bl = 0x20;//1L;
|
||||||
////al += bl;
|
Assert(al != bl, "Int64 Inequality");
|
||||||
//Assert(al == bl, "Int64 Equality");
|
Assert(0x1FFFFFFFF + 0x01L == 0x200000000, "0x1FFFFFFFF + 0x01L == 0x200000000");
|
||||||
|
|
||||||
UInt32 a = 5;
|
UInt32 a = 5;
|
||||||
UInt32 b = 5;
|
UInt32 b = 5;
|
||||||
|
|
|
||||||
|
|
@ -60,6 +60,7 @@
|
||||||
<Compile Include="CmpXchg.cs" />
|
<Compile Include="CmpXchg.cs" />
|
||||||
<Compile Include="Compare.cs" />
|
<Compile Include="Compare.cs" />
|
||||||
<Compile Include="IDivide.cs" />
|
<Compile Include="IDivide.cs" />
|
||||||
|
<Compile Include="JumpIfNotZero.cs" />
|
||||||
<Compile Include="Stosw.cs" />
|
<Compile Include="Stosw.cs" />
|
||||||
<Compile Include="JumpNotCary.cs" />
|
<Compile Include="JumpNotCary.cs" />
|
||||||
<Compile Include="RepeatMovsb.cs" />
|
<Compile Include="RepeatMovsb.cs" />
|
||||||
|
|
|
||||||
23
source/Indy.IL2CPU.Assembler.X86/JumpIfNotZero.cs
Normal file
23
source/Indy.IL2CPU.Assembler.X86/JumpIfNotZero.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 JNZ opcode
|
||||||
|
/// </summary>
|
||||||
|
[OpCode(0xFFFFFFFF, "jnz")]
|
||||||
|
public class JumpIfNotZero : JumpBase
|
||||||
|
{
|
||||||
|
public JumpIfNotZero(string aAddress)
|
||||||
|
: base(aAddress)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
public override string ToString()
|
||||||
|
{
|
||||||
|
return "jnz " + Address;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -24,22 +24,22 @@ namespace Indy.IL2CPU.IL.X86 {
|
||||||
#warning Code checking: strange code seems to be generated. Read the following comments:
|
#warning Code checking: strange code seems to be generated. Read the following comments:
|
||||||
//JumpAlways right after JumpIfGreaterOrEquals to the same label
|
//JumpAlways right after JumpIfGreaterOrEquals to the same label
|
||||||
//my offer is:
|
//my offer is:
|
||||||
//new CPUx86.Pop(CPUx86.Registers.EAX);
|
|
||||||
//new CPUx86.Pop(CPUx86.Registers.EBX);
|
|
||||||
//new CPUx86.JumpIfGreaterOrEquals(LabelTrue);
|
|
||||||
//new CPUx86.JumpAlways(LabelFalse);
|
|
||||||
//new CPU.Label(LabelTrue);
|
|
||||||
//new CPU.JumpAlways(TargetLabel);
|
|
||||||
//new CPU.Label(LabelFalse);
|
|
||||||
new CPUx86.Pop(CPUx86.Registers.EAX);
|
new CPUx86.Pop(CPUx86.Registers.EAX);
|
||||||
new CPUx86.Compare(CPUx86.Registers.EAX, CPUx86.Registers.AtESP);
|
new CPUx86.Pop(CPUx86.Registers.EBX);
|
||||||
new CPUx86.JumpIfGreaterOrEquals(LabelTrue);
|
new CPUx86.JumpIfGreaterOrEquals(LabelTrue);
|
||||||
new CPUx86.JumpAlways(LabelTrue);
|
new CPUx86.JumpAlways(LabelFalse);
|
||||||
new CPU.Label(LabelTrue);
|
new CPU.Label(LabelTrue);
|
||||||
new CPUx86.Add(CPUx86.Registers.ESP, "4");
|
|
||||||
new CPUx86.JumpAlways(TargetLabel);
|
new CPUx86.JumpAlways(TargetLabel);
|
||||||
new CPU.Label(LabelFalse);
|
new CPU.Label(LabelFalse);
|
||||||
new CPUx86.Add(CPUx86.Registers.ESP, "4");
|
//new CPUx86.Pop(CPUx86.Registers.EAX);
|
||||||
|
//new CPUx86.Compare(CPUx86.Registers.EAX, CPUx86.Registers.AtESP);
|
||||||
|
//new CPUx86.JumpIfGreaterOrEquals(LabelTrue);
|
||||||
|
//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");
|
||||||
}
|
}
|
||||||
|
|
||||||
private void DoAssemble64Bit() {
|
private void DoAssemble64Bit() {
|
||||||
|
|
|
||||||
|
|
@ -39,19 +39,27 @@ namespace Indy.IL2CPU.IL.X86 {
|
||||||
string BaseLabel = CurInstructionLabel + "__";
|
string BaseLabel = CurInstructionLabel + "__";
|
||||||
string LabelTrue = BaseLabel + "True";
|
string LabelTrue = BaseLabel + "True";
|
||||||
string LabelFalse = BaseLabel + "False";
|
string LabelFalse = BaseLabel + "False";
|
||||||
|
|
||||||
new CPUx86.Pop(CPUx86.Registers.EAX);
|
new CPUx86.Pop(CPUx86.Registers.EAX);
|
||||||
new CPUx86.Add("esp", "4");
|
new CPUx86.Compare(CPUx86.Registers.EAX, "[esp + 4]");
|
||||||
new CPUx86.Compare(CPUx86.Registers.EAX, CPUx86.Registers.AtESP);
|
|
||||||
new CPUx86.JumpIfEquals(LabelTrue);
|
new CPUx86.Pop(CPUx86.Registers.EAX);
|
||||||
new CPUx86.JumpAlways(LabelFalse);
|
new CPUx86.JumpIfNotEquals(LabelFalse);
|
||||||
new CPU.Label(LabelTrue);
|
|
||||||
new CPUx86.Add(CPUx86.Registers.ESP, "4");
|
new CPUx86.Xor(CPUx86.Registers.EAX, "[esp + 4]");
|
||||||
new CPUx86.Add("esp", "4");
|
new CPUx86.JumpIfNotZero(LabelFalse);
|
||||||
|
|
||||||
|
//they are equal, eax == 0
|
||||||
|
new CPUx86.Add(CPUx86.Registers.ESP, "8");
|
||||||
|
new CPUx86.Add(CPUx86.Registers.EAX, "1");
|
||||||
|
new CPUx86.Push(CPUx86.Registers.EAX);
|
||||||
new CPUx86.JumpAlways(NextInstructionLabel);
|
new CPUx86.JumpAlways(NextInstructionLabel);
|
||||||
|
|
||||||
new CPU.Label(LabelFalse);
|
new CPU.Label(LabelFalse);
|
||||||
new CPUx86.Add(CPUx86.Registers.ESP, "4");
|
//eax = 0
|
||||||
new CPUx86.Add("esp", "4");
|
new CPUx86.Add(CPUx86.Registers.ESP, "8");
|
||||||
new CPUx86.Push("00h");
|
new CPUx86.Xor(CPUx86.Registers.EAX, CPUx86.Registers.EAX);
|
||||||
|
new CPUx86.Push(CPUx86.Registers.EAX);
|
||||||
new CPUx86.JumpAlways(NextInstructionLabel);
|
new CPUx86.JumpAlways(NextInstructionLabel);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
31
source/Tests/MathTest/LongArithmetics.cs
Normal file
31
source/Tests/MathTest/LongArithmetics.cs
Normal file
|
|
@ -0,0 +1,31 @@
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Text;
|
||||||
|
|
||||||
|
namespace MathTest
|
||||||
|
{
|
||||||
|
class LongArithmetics
|
||||||
|
{
|
||||||
|
public static void Test()
|
||||||
|
{
|
||||||
|
Console.WriteLine("+++LongArithmeticsTest+++");
|
||||||
|
|
||||||
|
Console.Write("carry test...");
|
||||||
|
long a = 0x1FFFFFFFFL;
|
||||||
|
long b = 1;
|
||||||
|
|
||||||
|
if (a + b != 0x200000000L)
|
||||||
|
{
|
||||||
|
Console.WriteLine("failed");
|
||||||
|
Console.Write("excepted: ");
|
||||||
|
Console.WriteLine((0x200000000L).ToString());
|
||||||
|
Console.Write("received: ");
|
||||||
|
Console.WriteLine((a + b).ToString());
|
||||||
|
} else
|
||||||
|
Console.WriteLine("passed");
|
||||||
|
|
||||||
|
|
||||||
|
Console.WriteLine("");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -3,7 +3,7 @@ using Cosmos.Build.Windows;
|
||||||
|
|
||||||
namespace MathTest
|
namespace MathTest
|
||||||
{
|
{
|
||||||
class Program
|
class MathTest
|
||||||
{
|
{
|
||||||
#region Cosmos Builder logic
|
#region Cosmos Builder logic
|
||||||
// Most users wont touch this. This will call the Cosmos Build tool
|
// Most users wont touch this. This will call the Cosmos Build tool
|
||||||
|
|
@ -18,8 +18,11 @@ namespace MathTest
|
||||||
// Main entry point of the kernel
|
// Main entry point of the kernel
|
||||||
public static void Init()
|
public static void Init()
|
||||||
{
|
{
|
||||||
//Cosmos.Kernel..CPU.Init();
|
Cosmos.Kernel.Boot.Default();
|
||||||
Console.WriteLine("Done booting");
|
Console.WriteLine("Done booting");
|
||||||
|
|
||||||
|
LongArithmetics.Test();
|
||||||
|
|
||||||
while (true)
|
while (true)
|
||||||
;
|
;
|
||||||
}
|
}
|
||||||
|
|
@ -36,14 +36,25 @@
|
||||||
<WarningLevel>4</WarningLevel>
|
<WarningLevel>4</WarningLevel>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<Reference Include="Cosmos.Build.Windows, Version=1.0.0.0, Culture=neutral, PublicKeyToken=5ae71220097cb983, processorArchitecture=MSIL" />
|
|
||||||
<Reference Include="Cosmos.Kernel, Version=1.0.0.0, Culture=neutral, PublicKeyToken=5ae71220097cb983, processorArchitecture=MSIL" />
|
|
||||||
<Reference Include="System" />
|
<Reference Include="System" />
|
||||||
|
<Reference Include="System.Data" />
|
||||||
|
<Reference Include="System.Xml" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<Compile Include="Program.cs" />
|
<Compile Include="LongArithmetics.cs" />
|
||||||
|
<Compile Include="MathTest.cs" />
|
||||||
<Compile Include="Properties\AssemblyInfo.cs" />
|
<Compile Include="Properties\AssemblyInfo.cs" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
<ItemGroup>
|
||||||
|
<ProjectReference Include="..\..\Cosmos.Build.Windows\Cosmos.Build.Windows.csproj">
|
||||||
|
<Project>{1F0EDE86-F6D4-4355-9A97-10E90457770C}</Project>
|
||||||
|
<Name>Cosmos.Build.Windows</Name>
|
||||||
|
</ProjectReference>
|
||||||
|
<ProjectReference Include="..\..\Cosmos\Cosmos.Kernel\Cosmos.Kernel.csproj">
|
||||||
|
<Project>{A1F83D9F-2D44-4264-A08B-416797123018}</Project>
|
||||||
|
<Name>Cosmos.Kernel</Name>
|
||||||
|
</ProjectReference>
|
||||||
|
</ItemGroup>
|
||||||
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
|
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
|
||||||
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
|
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
|
||||||
Other similar extension points exist, see Microsoft.Common.targets.
|
Other similar extension points exist, see Microsoft.Common.targets.
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue