Large diffs are not rendered by default.

Large diffs are not rendered by default.

@@ -70,8 +70,10 @@ private void LoadFirstOperandIntoRegister(InstructionNode node)
node.Operand1 = register;

var move = GetMove(register, operand);
var size = GetInstructionSize(operand.Type);

var newNode = new InstructionNode(move, register, operand);
newNode.Size = size;
node.Previous.Insert(newNode);
}

@@ -26,6 +26,8 @@ namespace Mosa.Platform.x86.Stages
/// </remarks>
public sealed class IRTransformationStage : BaseTransformationStage, IIRVisitor
{
private const int LargeAlignment = 16;

#region IIRVisitor

/// <summary>
@@ -53,9 +55,15 @@ void IIRVisitor.AddUnsigned(Context context)
void IIRVisitor.AddFloat(Context context)
{
if (context.Result.IsR4)
{
context.ReplaceInstructionOnly(X86.Addss);
context.Size = InstructionSize.Size32;
}
else
{
context.ReplaceInstructionOnly(X86.Addsd);
context.Size = InstructionSize.Size64;
}
}

/// <summary>
@@ -65,9 +73,15 @@ void IIRVisitor.AddFloat(Context context)
void IIRVisitor.DivFloat(Context context)
{
if (context.Result.IsR4)
{
context.ReplaceInstructionOnly(X86.Divss);
context.Size = InstructionSize.Size32;
}
else
{
context.ReplaceInstructionOnly(X86.Divsd);
context.Size = InstructionSize.Size64;
}
}

/// <summary>
@@ -135,13 +149,16 @@ void IIRVisitor.FloatCompare(Context context)
}

X86Instruction instruction = null;
InstructionSize size = InstructionSize.None;
if (left.IsR4)
{
instruction = X86.Ucomiss;
size = InstructionSize.Size32;
}
else
{
instruction = X86.Ucomisd;
size = InstructionSize.Size64;
}

switch (condition)
@@ -161,7 +178,7 @@ void IIRVisitor.FloatCompare(Context context)
Context nextBlock = Split(context);

context.SetInstruction(X86.Mov, result, Operand.CreateConstant(TypeSystem, 1));
context.AppendInstruction(instruction, null, left, right);
context.AppendInstruction(instruction, size, null, left, right);
context.AppendInstruction(X86.Branch, ConditionCode.Parity, newBlocks[1].Block);
context.AppendInstruction(X86.Jmp, newBlocks[0].Block);

@@ -187,7 +204,7 @@ void IIRVisitor.FloatCompare(Context context)
Context nextBlock = Split(context);

context.SetInstruction(X86.Mov, result, Operand.CreateConstant(TypeSystem, 1));
context.AppendInstruction(instruction, null, left, right);
context.AppendInstruction(instruction, size, null, left, right);
context.AppendInstruction(X86.Branch, ConditionCode.Parity, nextBlock.Block);
context.AppendInstruction(X86.Jmp, newBlocks[0].Block);

@@ -206,7 +223,7 @@ void IIRVisitor.FloatCompare(Context context)
// seta al

context.SetInstruction(X86.Mov, result, ConstantZero);
context.AppendInstruction(instruction, null, right, left);
context.AppendInstruction(instruction, size, null, right, left);
context.AppendInstruction(X86.Setcc, ConditionCode.UnsignedGreaterThan, result);
break;
}
@@ -218,7 +235,7 @@ void IIRVisitor.FloatCompare(Context context)
// seta al

context.SetInstruction(X86.Mov, result, ConstantZero);
context.AppendInstruction(instruction, null, left, right);
context.AppendInstruction(instruction, size, null, left, right);
context.AppendInstruction(X86.Setcc, ConditionCode.UnsignedGreaterThan, result);
break;
}
@@ -230,7 +247,7 @@ void IIRVisitor.FloatCompare(Context context)
// setae al

context.SetInstruction(X86.Mov, result, ConstantZero);
context.AppendInstruction(instruction, null, right, left);
context.AppendInstruction(instruction, size, null, right, left);
context.AppendInstruction(X86.Setcc, ConditionCode.UnsignedGreaterOrEqual, result);
break;
}
@@ -242,7 +259,7 @@ void IIRVisitor.FloatCompare(Context context)
// setae al

context.SetInstruction(X86.Mov, result, ConstantZero);
context.AppendInstruction(instruction, null, left, right);
context.AppendInstruction(instruction, size, null, left, right);
context.AppendInstruction(X86.Setcc, ConditionCode.UnsignedGreaterOrEqual, result);
break;
}
@@ -347,6 +364,7 @@ void IIRVisitor.CompoundLoad(Context context)
var type = context.Result.Type;
int typeSize = TypeLayout.GetTypeSize(type);
int alignedTypeSize = typeSize - (typeSize % NativeAlignment);
int largeAlignedTypeSize = typeSize - (typeSize % LargeAlignment);
Debug.Assert(typeSize > 0, context.Operand2.Name);

int offset = 0;
@@ -363,6 +381,7 @@ void IIRVisitor.CompoundLoad(Context context)
var srcReg = MethodCompiler.CreateVirtualRegister(dest.Type.TypeSystem.BuiltIn.I4);
var dstReg = MethodCompiler.CreateVirtualRegister(dest.Type.TypeSystem.BuiltIn.I4);
var tmp = MethodCompiler.CreateVirtualRegister(dest.Type.TypeSystem.BuiltIn.I4);
var tmpLarge = Operand.CreateCPURegister(MethodCompiler.TypeSystem.BuiltIn.Void, SSE2Register.XMM1);

context.SetInstruction(X86.Nop);
context.AppendInstruction(X86.Mov, srcReg, src);
@@ -373,7 +392,15 @@ void IIRVisitor.CompoundLoad(Context context)
context.AppendInstruction(X86.Add, srcReg, srcReg, offsetop);
}

for (int i = 0; i < alignedTypeSize; i += NativeAlignment)
for (int i = 0; i < largeAlignedTypeSize; i += LargeAlignment)
{
// Large Aligned moves allow 128bits to be copied at a time
var memSrc = Operand.CreateMemoryAddress(MethodCompiler.TypeSystem.BuiltIn.Void, srcReg, i + offset);
var memDest = Operand.CreateMemoryAddress(MethodCompiler.TypeSystem.BuiltIn.Void, dstReg, i);
context.AppendInstruction(X86.MovAPS, InstructionSize.Size128, tmpLarge, memSrc);
context.AppendInstruction(X86.MovAPS, InstructionSize.Size128, memDest, tmpLarge);
}
for (int i = largeAlignedTypeSize; i < alignedTypeSize; i += NativeAlignment)
{
context.AppendInstruction(X86.Mov, InstructionSize.Size32, tmp, Operand.CreateMemoryAddress(TypeSystem.BuiltIn.I4, srcReg, i + offset));
context.AppendInstruction(X86.Mov, InstructionSize.Size32, Operand.CreateMemoryAddress(TypeSystem.BuiltIn.I4, dstReg, i), tmp);
@@ -496,6 +523,7 @@ void IIRVisitor.Move(Context context)
Operand operand = context.Operand1;

X86Instruction instruction = X86.Mov;
InstructionSize size = InstructionSize.None;

if (result.IsR)
{
@@ -506,10 +534,12 @@ void IIRVisitor.Move(Context context)
if (result.IsR4)
{
instruction = X86.Movss;
size = InstructionSize.Size32;
}
else if (result.IsR8)
{
instruction = X86.Movsd;
size = InstructionSize.Size64;
}
}
else if (result.IsR8)
@@ -523,13 +553,15 @@ void IIRVisitor.Move(Context context)
}

context.ReplaceInstructionOnly(instruction);
context.Size = size;
}

void IIRVisitor.CompoundMove(Context context)
{
var type = context.Result.Type;
int typeSize = TypeLayout.GetTypeSize(type);
int alignedTypeSize = typeSize - (typeSize % NativeAlignment);
int largeAlignedTypeSize = typeSize - (typeSize % LargeAlignment);
Debug.Assert(typeSize > 0, MethodCompiler.Method.FullName);

var src = context.Operand1;
@@ -539,6 +571,7 @@ void IIRVisitor.CompoundMove(Context context)
var srcReg = MethodCompiler.CreateVirtualRegister(dest.Type.TypeSystem.BuiltIn.I4);
var dstReg = MethodCompiler.CreateVirtualRegister(dest.Type.TypeSystem.BuiltIn.I4);
var tmp = MethodCompiler.CreateVirtualRegister(dest.Type.TypeSystem.BuiltIn.I4);
var tmpLarge = Operand.CreateCPURegister(MethodCompiler.TypeSystem.BuiltIn.Void, SSE2Register.XMM1);

context.SetInstruction(X86.Nop);
if (src.IsSymbol)
@@ -551,7 +584,15 @@ void IIRVisitor.CompoundMove(Context context)
}
context.AppendInstruction(X86.Lea, dstReg, dest);

for (int i = 0; i < alignedTypeSize; i += NativeAlignment)
for (int i = 0; i < largeAlignedTypeSize; i += LargeAlignment)
{
// Large Aligned moves allow 128bits to be copied at a time
var memSrc = Operand.CreateMemoryAddress(MethodCompiler.TypeSystem.BuiltIn.Void, srcReg, i);
var memDest = Operand.CreateMemoryAddress(MethodCompiler.TypeSystem.BuiltIn.Void, dstReg, i);
context.AppendInstruction(X86.MovAPS, InstructionSize.Size128, tmpLarge, memSrc);
context.AppendInstruction(X86.MovAPS, InstructionSize.Size128, memDest, tmpLarge);
}
for (int i = largeAlignedTypeSize; i < alignedTypeSize; i += NativeAlignment)
{
context.AppendInstruction(X86.Mov, InstructionSize.Size32, tmp, Operand.CreateMemoryAddress(TypeSystem.BuiltIn.I4, srcReg, i));
context.AppendInstruction(X86.Mov, InstructionSize.Size32, Operand.CreateMemoryAddress(TypeSystem.BuiltIn.I4, dstReg, i), tmp);
@@ -698,6 +739,7 @@ void IIRVisitor.CompoundStore(Context context)
var type = context.Operand3.Type;
int typeSize = TypeLayout.GetTypeSize(type);
int alignedTypeSize = typeSize - (typeSize % NativeAlignment);
int largeAlignedTypeSize = typeSize - (typeSize % LargeAlignment);
Debug.Assert(typeSize > 0, MethodCompiler.Method.FullName);

int offset = 0;
@@ -714,6 +756,7 @@ void IIRVisitor.CompoundStore(Context context)
var srcReg = MethodCompiler.CreateVirtualRegister(dest.Type.TypeSystem.BuiltIn.I4);
var dstReg = MethodCompiler.CreateVirtualRegister(dest.Type.TypeSystem.BuiltIn.I4);
var tmp = MethodCompiler.CreateVirtualRegister(dest.Type.TypeSystem.BuiltIn.I4);
var tmpLarge = Operand.CreateCPURegister(MethodCompiler.TypeSystem.BuiltIn.Void, SSE2Register.XMM1);

context.SetInstruction(X86.Nop);
context.AppendInstruction(X86.Lea, srcReg, src);
@@ -724,7 +767,15 @@ void IIRVisitor.CompoundStore(Context context)
context.AppendInstruction(X86.Add, dstReg, dstReg, offsetop);
}

for (int i = 0; i < alignedTypeSize; i += NativeAlignment)
for (int i = 0; i < largeAlignedTypeSize; i += LargeAlignment)
{
// Large Aligned moves allow 128bits to be copied at a time
var memSrc = Operand.CreateMemoryAddress(MethodCompiler.TypeSystem.BuiltIn.Void, srcReg, i);
var memDest = Operand.CreateMemoryAddress(MethodCompiler.TypeSystem.BuiltIn.Void, dstReg, i + offset);
context.AppendInstruction(X86.MovAPS, InstructionSize.Size128, tmpLarge, memSrc);
context.AppendInstruction(X86.MovAPS, InstructionSize.Size128, memDest, tmpLarge);
}
for (int i = largeAlignedTypeSize; i < alignedTypeSize; i += NativeAlignment)
{
context.AppendInstruction(X86.Mov, InstructionSize.Size32, tmp, Operand.CreateMemoryAddress(TypeSystem.BuiltIn.I4, srcReg, i));
context.AppendInstruction(X86.Mov, InstructionSize.Size32, Operand.CreateMemoryAddress(TypeSystem.BuiltIn.I4, dstReg, i + offset), tmp);
@@ -743,9 +794,15 @@ void IIRVisitor.CompoundStore(Context context)
void IIRVisitor.MulFloat(Context context)
{
if (context.Result.IsR4)
{
context.ReplaceInstructionOnly(X86.Mulss);
context.Size = InstructionSize.Size32;
}
else
{
context.ReplaceInstructionOnly(X86.Mulsd);
context.Size = InstructionSize.Size64;
}
}

/// <summary>
@@ -755,9 +812,15 @@ void IIRVisitor.MulFloat(Context context)
void IIRVisitor.SubFloat(Context context)
{
if (context.Result.IsR4)
{
context.ReplaceInstructionOnly(X86.Subss);
context.Size = InstructionSize.Size32;
}
else
{
context.ReplaceInstructionOnly(X86.Subsd);
context.Size = InstructionSize.Size64;
}
}

/// <summary>
@@ -884,18 +947,30 @@ void IIRVisitor.RemUnsigned(Context context)
/// <param name="context">The context.</param>
void IIRVisitor.RemFloat(Context context)
{
Operand result = context.Result;
Operand operand1 = context.Operand1;
Operand operand2 = context.Operand2;
var result = context.Result;
var dividend = context.Operand1;
var divisor = context.Operand2;
var method = (result.IsR8) ? "RemR8" : "RemR4";

var type = TypeSystem.GetTypeByName("Mosa.Platform.Internal.x86", "Division");

Debug.Assert(type != null, "Cannot find type: Mosa.Platform.Internal.x86.Division type");

var mosaMethod = type.FindMethodByName(method);

Debug.Assert(method != null, "Cannot find method: " + method);

Operand xmm1 = AllocateVirtualRegister(TypeSystem.BuiltIn.R8);
Operand xmm2 = AllocateVirtualRegister(TypeSystem.BuiltIn.R8);
Operand xmm3 = AllocateVirtualRegister(TypeSystem.BuiltIn.R8);
context.ReplaceInstructionOnly(IRInstruction.Call);
context.SetOperand(0, Operand.CreateSymbolFromMethod(TypeSystem, mosaMethod));
context.Result = result;
context.Operand2 = dividend;
context.Operand3 = divisor;
context.OperandCount = 3;
context.ResultCount = 1;
context.InvokeMethod = mosaMethod;

context.SetInstruction(X86.Divsd, xmm1, operand1, operand2);
context.AppendInstruction(X86.Roundsd, xmm2, xmm1, Operand.CreateConstant(TypeSystem.BuiltIn.U1, 0x3));
context.AppendInstruction(X86.Mulsd, xmm3, operand2, xmm2);
context.AppendInstruction(X86.Subsd, result, operand1, xmm3);
// Since we are already in IR Transformation Stage we gotta call this now
CallingConvention.MakeCall(MethodCompiler, TypeLayout, context);
}

/// <summary>
@@ -1156,4 +1231,4 @@ void IIRVisitor.Flow(Context context)

#endregion IIRVisitor - Unused
}
}
}
@@ -55,7 +55,9 @@ private void CreateInterruptVectors()
ctx.AppendInstruction(X86.Push, null, Operand.CreateConstant(TypeSystem, 0));
ctx.AppendInstruction(X86.Push, null, Operand.CreateConstant(TypeSystem, i));
ctx.AppendInstruction(X86.Pushad);
ctx.AppendInstruction(X86.Push, null, esp);
ctx.AppendInstruction(X86.Call, null, interrupt);
ctx.AppendInstruction(X86.Pop, esp);
ctx.AppendInstruction(X86.Popad);
ctx.AppendInstruction(X86.Add, esp, esp, Operand.CreateConstant(TypeSystem, 8));
ctx.AppendInstruction(X86.Sti);
@@ -68,4 +70,4 @@ private void CreateInterruptVectors()

#endregion Internal
}
}
}
@@ -100,8 +100,8 @@ protected override void Run()

WriteMultibootHeader();

Linker.CreateSymbol(MultibootEAX, SectionKind.BSS, Architecture.NativeAlignment, Architecture.NativeIntegerSize);
Linker.CreateSymbol(MultibootEBX, SectionKind.BSS, Architecture.NativeAlignment, Architecture.NativeIntegerSize);
Linker.CreateSymbol(MultibootEAX, SectionKind.BSS, Architecture.NativeAlignment, Architecture.NativePointerSize);
Linker.CreateSymbol(MultibootEBX, SectionKind.BSS, Architecture.NativeAlignment, Architecture.NativePointerSize);

return;
}
@@ -112,6 +112,8 @@ protected override void Run()
var eax = Operand.CreateCPURegister(TypeSystem.BuiltIn.I4, GeneralPurposeRegister.EAX);
var ebx = Operand.CreateCPURegister(TypeSystem.BuiltIn.I4, GeneralPurposeRegister.EBX);
var ebp = Operand.CreateCPURegister(TypeSystem.BuiltIn.I4, GeneralPurposeRegister.EBP);
var multibootEax = Operand.CreateUnmanagedSymbolPointer(TypeSystem, MultibootEAX);
var multibootEbx = Operand.CreateUnmanagedSymbolPointer(TypeSystem, MultibootEBX);

var basicBlocks = new BasicBlocks();
var block = basicBlocks.CreateBlock();
@@ -122,8 +124,10 @@ protected override void Run()
var zero = Operand.CreateConstant(TypeSystem.BuiltIn.I4, 0);
ctx.AppendInstruction(X86.Mov, Operand.CreateMemoryAddress(TypeSystem.BuiltIn.I4, ebp, 0), zero);

ctx.AppendInstruction(X86.Mov, Operand.CreateUnmanagedSymbolPointer(TypeSystem, MultibootEAX), eax);
ctx.AppendInstruction(X86.Mov, Operand.CreateUnmanagedSymbolPointer(TypeSystem, MultibootEBX), ebx);
ctx.AppendInstruction(X86.Mov, ecx, multibootEax);
ctx.AppendInstruction(X86.Mov, Operand.CreateMemoryAddress(TypeSystem.BuiltIn.I4, ecx, 0), eax);
ctx.AppendInstruction(X86.Mov, ecx, multibootEbx);
ctx.AppendInstruction(X86.Mov, Operand.CreateMemoryAddress(TypeSystem.BuiltIn.I4, ecx, 0), ebx);

// call type initializer
var entryPoint = Operand.CreateSymbolFromMethod(TypeSystem, typeInitializerSchedulerStage.TypeInitializerMethod);
@@ -155,7 +159,7 @@ private void WriteMultibootHeader()
var writer = new BinaryWriter(stream, Encoding.ASCII);

// flags - multiboot flags
uint flags = HEADER_MB_FLAG_MEMORY_INFO_REQUIRED | HEADER_MB_FLAG_MODULES_PAGE_ALIGNED;
uint flags = HEADER_MB_FLAG_MEMORY_INFO_REQUIRED | HEADER_MB_FLAG_MODULES_PAGE_ALIGNED;// | HEADER_MB_FLAG_VIDEO_MODES_REQUIRED;

uint load_addr = 0;

@@ -0,0 +1,86 @@
/*
* (c) 2015 MOSA - The Managed Operating System Alliance
*
* Licensed under the terms of the New BSD License.
*
* Authors:
* Stefan Andres Charsley (charsleysa) <charsleysa@gmail.com>
*/

using Mosa.Compiler.Framework;
using Mosa.Compiler.Framework.Stages;
using Mosa.Compiler.Linker;
using Mosa.Compiler.MosaTypeSystem;
using System.IO;
using System.Text;
using System.Diagnostics;

namespace Mosa.Platform.x86.Stages
{
/// <summary>
/// Sets up SSE before any code that relies on SSE runs.
/// </summary>
public sealed class SSESetupStage : BaseCompilerStage
{
#region Constants

#endregion Constants

#region Data members

/// <summary>
/// The SSE setup method
/// </summary>
private MosaMethod setupMethod;

#endregion Data members

protected override void Run()
{
Debug.Assert(setupMethod == null, "SSE setup method already generated!");

setupMethod = Compiler.CreateLinkerMethod("SSEInit");

var eax = Operand.CreateCPURegister(TypeSystem.BuiltIn.U4, GeneralPurposeRegister.EAX);
var cr0 = Operand.CreateCPURegister(TypeSystem.BuiltIn.U4, ControlRegister.CR0);
var cr4 = Operand.CreateCPURegister(TypeSystem.BuiltIn.U4, ControlRegister.CR4);

var basicBlocks = new BasicBlocks();
var block = basicBlocks.CreateBlock();
basicBlocks.AddHeaderBlock(block);
var ctx = new Context(block);

/*
;enable SSE and the like
mov eax, cr0
and ax, 0xFFFB ;clear coprocessor emulation CR0.EM
or ax, 0x2 ;set coprocessor monitoring CR0.MP
mov cr0, eax
mov eax, cr4
or ax, 3 << 9 ;set CR4.OSFXSR and CR4.OSXMMEXCPT at the same time
mov cr4, eax
ret
*/

ctx.AppendInstruction(X86.MovCR, eax, cr0);
ctx.AppendInstruction(X86.And, eax, eax, Operand.CreateConstant(TypeSystem.BuiltIn.U4, 0xFFFB));
ctx.AppendInstruction(X86.Or, eax, eax, Operand.CreateConstant(TypeSystem.BuiltIn.U4, 0x2));
ctx.AppendInstruction(X86.MovCR, cr0, eax);

ctx.AppendInstruction(X86.MovCR, eax, cr4);
ctx.AppendInstruction(X86.Or, eax, eax, Operand.CreateConstant(TypeSystem.BuiltIn.U4, 0x600));
ctx.AppendInstruction(X86.MovCR, cr4, eax);

ctx.AppendInstruction(X86.Ret);

Compiler.CompileMethod(setupMethod, basicBlocks, 0);

var typeInitializerSchedulerStage = Compiler.PostCompilePipeline.FindFirst<TypeInitializerSchedulerStage>();
typeInitializerSchedulerStage.Schedule(setupMethod);
}

#region Internals

#endregion Internals
}
}

Large diffs are not rendered by default.

This file was deleted.

@@ -141,6 +141,11 @@ public static class X86
/// </summary>
public static readonly Xor Xor = new Xor();

/// <summary>
///
/// </summary>
public static readonly PXor PXor = new PXor();

/// <summary>
///
/// </summary>
@@ -286,6 +291,16 @@ public static class X86
/// </summary>
public static readonly Movsd Movsd = new Movsd();

/// <summary>
///
/// </summary>
public static readonly MovUPS MovUPS = new MovUPS();

/// <summary>
///
/// </summary>
public static readonly MovAPS MovAPS = new MovAPS();

/// <summary>
///
/// </summary>
@@ -471,4 +486,4 @@ public static class X86
/// </summary>
public static readonly Btr Btr = new Btr();
}
}
}
@@ -164,8 +164,8 @@ public void LdelemaR8(int index, double value)
Assert.True(Run<bool>("Mosa.Test.Collection", "DoubleTests", "Ldelema", index, value));
}

//[Theory]
//[PropertyData("R8")]
[Theory]
[PropertyData("R8")]
public void IsNaN(double value)
{
Assert.Equal(DoubleTests.IsNaN(value), Run<bool>("Mosa.Test.Collection", "DoubleTests", "IsNaN", value));
@@ -63,8 +63,9 @@ public void DivR4R4DivideByZeroException(float a)
Run<float>("Mosa.Test.Collection", "SingleTests", "DivR4R4", (float)0, a, (float)0);
}

[Theory]
[PropertyData("R4R4")]
// TinySimulator can't simulate this.
//[Theory]
//[PropertyData("R4R4")]
public void RemR4R4(float a, float b)
{
if (a == int.MinValue && b == -1)
@@ -11,6 +11,11 @@ namespace Mosa.Test.Collection
{
public static class SpecificTests
{
public unsafe static void RefPointer(ref int* ptr)
{
ptr++;
}

public static uint Test2(uint size)
{
uint first = 0xFFFFFFFF; // Marker
@@ -49,4 +54,4 @@ public static uint Test2(uint size)
// return Double.IsPositiveInfinity(Double.NegativeInfinity);
//}
}
}
}
@@ -47,37 +47,36 @@ public static void Start()

DebugClient.Setup(Serial.COM1);
Screen.Write('0');
SSE.Setup();
Screen.Write('1');
IDT.SetInterruptHandler(null);
Screen.Write('2');
Screen.Write('1');
Multiboot.Setup();
Screen.Write('3');
Screen.Write('2');
PIC.Setup();
Screen.Write('4');
Screen.Write('3');
GDT.Setup();
Screen.Write('5');
Screen.Write('4');
IDT.Setup();
Screen.Write('6');
Screen.Write('5');
PageFrameAllocator.Setup();
Screen.Write('7');
Screen.Write('6');
PageTable.Setup();
Screen.Write('8');
Screen.Write('7');
VirtualPageAllocator.Setup();
Screen.Write('9');
Screen.Write('8');
ProcessManager.Setup();
Screen.Write('0');
Screen.Write('9');
GC.Setup();
Screen.Write('A');
Screen.Write('0');
//Runtime.Setup();
Screen.Write('B');
Screen.Write('A');
TaskManager.Setup();
Screen.Write('C');
Screen.Write('B');
IDT.SetInterruptHandler(ProcessInterrupt);
Screen.Write('D');
Screen.Write('C');
ConsoleManager.Setup();
Screen.Write('E');
Screen.Write('D');
Console = ConsoleManager.Controller.Boot;
Screen.Write('E');
Screen.Write('F');

Console.Color = 0x0E;
@@ -26,6 +26,7 @@
<UpgradeBackupLocation />
<TargetFrameworkProfile />
<NoStdLib>true</NoStdLib>
<IsWebBootstrapper>false</IsWebBootstrapper>
<PublishUrl>publish\</PublishUrl>
<Install>true</Install>
<InstallFrom>Disk</InstallFrom>
@@ -38,7 +39,6 @@
<MapFileExtensions>true</MapFileExtensions>
<ApplicationRevision>0</ApplicationRevision>
<ApplicationVersion>1.0.0.%2a</ApplicationVersion>
<IsWebBootstrapper>false</IsWebBootstrapper>
<UseApplicationTrust>false</UseApplicationTrust>
<BootstrapperEnabled>true</BootstrapperEnabled>
</PropertyGroup>
@@ -56,7 +56,7 @@
<OutputPath>..\..\bin\</OutputPath>
<RegisterForComInterop>False</RegisterForComInterop>
<RemoveIntegerChecks>False</RemoveIntegerChecks>
<TreatWarningsAsErrors>true</TreatWarningsAsErrors>
<TreatWarningsAsErrors>false</TreatWarningsAsErrors>
<WarningLevel>4</WarningLevel>
<DebugType>full</DebugType>
<NoWarn>1685</NoWarn>
@@ -92,7 +92,7 @@ public static void RunTests()
var simpleTest = new OptimizationTest();
var reflectionTest = new ReflectionTest();
var arrayTest = new ArrayTest();
//var int64Test = new Int64Test();
var int64Test = new Int64Test();
var otherTest = new OtherTest();

delegateTest.Test();
@@ -107,7 +107,7 @@ public static void RunTests()
simpleTest.Test();
//reflectionTest.Test();
arrayTest.Test();
//int64Test.Test();
int64Test.Test();
otherTest.Test();
}

@@ -30,6 +30,13 @@ public OtherTest()
testMethods.AddLast(ConditionalBug);
testMethods.AddLast(PointerBug);
testMethods.AddLast(AddressOfThisBug);
testMethods.AddLast(RemR4);
testMethods.AddLast(RemR8);
testMethods.AddLast(NullableTest1);
testMethods.AddLast(NullableTest2);
testMethods.AddLast(NullableTest3);
testMethods.AddLast(NullableTest4);
testMethods.AddLast(NullableTest5);
}

private static uint StaticValue = 0x200000;
@@ -185,6 +192,59 @@ public static bool AddressOfThisBug()
return PointerBugClass.Test2();
}

static float f1 = 1.232145E+10f;
static float f2 = 2f;
public static bool RemR4()
{
return (f1 % f2) == 0f;
}

static double d1 = 1.232145E+10d;
static double d2 = 15d;
public static bool RemR8()
{
return (d1 % d2) == 0d;
}

public static bool NullableTest1()
{
bool? v1 = true;

return (v1 == true);
}

public static bool NullableTest2()
{
bool? v1 = null;

return (v1 == null);
}

public static bool NullableTest3()
{
bool? v1 = null;

return !(v1 == true);
}

public static bool NullableTest4()
{
bool? v1 = null;
bool? v2 = true;

return !(v1 == v2);
}

public static bool NullableTest5()
{
int? v1 = null;
int? v2 = 32;

long? v3 = v1 ?? v2;

return (v3 == 32);
}

unsafe public static class PointerBugClass
{
private static uint pageDirectoryAddress = 0x1000;
@@ -56,9 +56,9 @@ private static void Main(string[] args)
//Test4();
//Test12();

//Test13();
Test13();

Test14();
//Test14();
}
catch (Exception e)
{
@@ -29,6 +29,8 @@ public class TestCompiler : ITraceListener

protected SimLinker linker;

protected const uint MaxTicks = 500000;

public TestCompiler(BaseTestPlatform platform)
{
this.platform = platform;
@@ -65,15 +67,27 @@ protected void CompileTestCode()

compiler.Load(TypeSystem.Load(moduleLoader.CreateMetadata()));

//compiler.Execute();
compiler.Execute(Environment.ProcessorCount);

linker = compiler.Linker as SimLinker;

//DumpSymbols();
//simAdapter.SimCPU.Monitor.DebugOutput = true; // DEBUG OPTION

Run<int>(string.Empty, "Default", "AssemblyInit", true);

//simAdapter.SimCPU.Monitor.DebugOutput = true; // DEBUG OPTION
simAdapter.SimCPU.Monitor.DebugOutput = true; // DEBUG OPTION
}

public void DumpSymbols()
{
var symbols = simAdapter.SimCPU.Symbols;

foreach (var symbol in symbols)
{
Debug.WriteLine(symbol.Value.ToString());
}
}

public T Run<T>(string ns, string type, string method, params object[] parameters)
@@ -107,12 +121,12 @@ protected T Run<T>(string ns, string type, string method, bool reset, params obj

platform.PrepareToExecuteMethod(simAdapter, address, parameters);

simAdapter.SimCPU.Monitor.BreakAtTick = simAdapter.SimCPU.Monitor.BreakAtTick + 500000; // nothing should take this long
simAdapter.SimCPU.Monitor.BreakAtTick = simAdapter.SimCPU.Monitor.BreakAtTick + MaxTicks; // nothing should take this long
simAdapter.SimCPU.Execute();

if (simAdapter.SimCPU.Monitor.BreakAtTick == simAdapter.SimCPU.Tick)
{
throw new Exception("Aborted. Method did not complete under 500000 ticks. " + simAdapter.SimCPU.Tick.ToString());
throw new Exception("Aborted. Method did not complete under " + MaxTicks.ToString() + " ticks. " + simAdapter.SimCPU.Tick.ToString());
}

if (runtimeMethod.Signature.ReturnType.IsVoid)
@@ -174,4 +188,4 @@ void ITraceListener.OnNewTraceLog(TraceLog traceLog)
{
}
}
}
}
@@ -41,7 +41,11 @@ SimInstruction ISimAdapter.Convert(InstructionNode node, MosaMethod method, Basi

byte size = 0;

if (node.Size == InstructionSize.Size32)
if (node.Size == InstructionSize.Size128)
size = 128;
else if (node.Size == InstructionSize.Size64)
size = 64;
else if (node.Size == InstructionSize.Size32)
size = 32;
else if (node.Size == InstructionSize.Size16)
size = 16;
@@ -122,16 +126,6 @@ private static void AdjustInstructionOperands(BaseOpcode opcode, List<SimOperand
{
if (operands[0] == operands[1]) operands.RemoveAt(0);
}
else if (opcode == Opcode.Movsd)
{
operands[0].Size = 64;
operands[1].Size = 64;
}
else if (opcode == Opcode.Movss)
{
operands[0].Size = 32;
operands[1].Size = 32;
}
}

private SimOperand ConvertToOpcodeOperand(Operand operand, int size)
@@ -262,8 +256,8 @@ private static bool IsSecondOperandDuplicate(BaseOpcode opcode)
//if (opcode == Opcode.Cvtsi2sd) return true;
//if (opcode == Opcode.Cvtsi2ss) return true;
//if (opcode == Opcode.Cvtss2sd) return true;
if (opcode == Opcode.Cvttsd2si) return true;
if (opcode == Opcode.Cvttss2si) return true;
//if (opcode == Opcode.Cvttsd2si) return true;
//if (opcode == Opcode.Cvttss2si) return true;
if (opcode == Opcode.Dec) return true;
if (opcode == Opcode.Div) return true;
if (opcode == Opcode.Divsd) return true;
@@ -300,6 +294,7 @@ private static bool IsSecondOperandDuplicate(BaseOpcode opcode)
//if (opcode == Opcode.Ucomiss) return true;
//if (opcode == Opcode.Xchg) return true;
if (opcode == Opcode.Xor) return true;
if (opcode == Opcode.Pxor) return true;
//if (opcode == Opcode.Ucomisd) return true;
//if (opcode == Opcode.Ucomiss) return true;
if (opcode == Opcode.Neg) return true;
@@ -394,7 +389,10 @@ private static BaseOpcode ConvertToOpcode(X86Instruction instruction, ConditionC
if (instruction == X86.Subss) return Opcode.Subss;
if (instruction == X86.Xchg) return Opcode.Xchg;
if (instruction == X86.Xor) return Opcode.Xor;
if (instruction == X86.PXor) return Opcode.Pxor;
if (instruction == X86.MovCR) return Opcode.Mov;
if (instruction == X86.MovUPS) return Opcode.Movups;
if (instruction == X86.MovAPS) return Opcode.Movaps;
if (instruction == X86.Ucomisd) return Opcode.Ucomisd;
if (instruction == X86.Ucomiss) return Opcode.Ucomiss;
if (instruction == X86.Test) return Opcode.Test;
@@ -104,6 +104,14 @@ private void WriteStackValue(ISimAdapter simAdapter, uint value)
x86.Write32(x86.ESP.Value, value);
}

private void WriteStackValue(ISimAdapter simAdapter, ulong value)
{
var x86 = simAdapter.SimCPU as CPUx86;

x86.ESP.Value = x86.ESP.Value - 8;
x86.Write64(x86.ESP.Value, value);
}

public void PopulateStack(ISimAdapter simAdapter, object parameter)
{
if ((parameter == null) || !(parameter is ValueType))
@@ -163,8 +171,7 @@ public void PopulateStack(ISimAdapter simAdapter, object parameter)
{
var b = BitConverter.GetBytes((double)parameter);
var u = BitConverter.ToUInt64(b, 0);
WriteStackValue(simAdapter, (uint)(u >> 32));
WriteStackValue(simAdapter, (uint)u);
WriteStackValue(simAdapter, u);
}
//else if (parameter is UIntPtr) { WriteStackValue(simAdapter, (uint)parameter); }
//else if (parameter is IntPtr) { WriteStackValue(simAdapter, (uint)parameter); }
@@ -199,9 +206,9 @@ public override object GetResult(ISimAdapter simAdapter, MosaType type)
else if (type.IsBoolean)
return (object)(bool)(x86.EAX.Value != 0);
else if (type.IsR4)
return (object)(float)x86.XMM0.Value;
return (object)(float)x86.XMM0.Value.LowF;
else if (type.IsR8)
return (object)(double)x86.XMM0.Value;
return (object)(double)x86.XMM0.Value.Low;
else if (type.IsVoid)
return null;

@@ -215,7 +215,7 @@ protected void StoreValue(CPUx86 cpu, SimOperand operand, uint value, int size)
}
}

protected double LoadFloatValue(CPUx86 cpu, SimOperand operand)
protected FloatingValue LoadFloatValue(CPUx86 cpu, SimOperand operand, int size)
{
if (operand.IsRegister)
{
@@ -226,26 +226,57 @@ protected double LoadFloatValue(CPUx86 cpu, SimOperand operand)
{
uint address = (uint)cpu.GetSymbol(operand.Label).Address;

return ReadFloat(cpu, address, operand.Size);
return ReadFloat(cpu, address, size);
}

if (operand.IsMemory)
{
uint address = GetAddress(cpu, operand);

return ReadFloat(cpu, address, operand.Size);
return ReadFloat(cpu, address, size);
}

throw new SimCPUException();
}

protected void StoreFloatValue(CPUx86 cpu, SimOperand operand, float value, int size)
{
var val = new FloatingValue()
{
LowF = value
};
StoreFloatValue(cpu, operand, val, size);
}

protected void StoreFloatValue(CPUx86 cpu, SimOperand operand, double value, int size)
{
var val = new FloatingValue()
{
Low = value
};
StoreFloatValue(cpu, operand, val, size);
}

protected void StoreFloatValue(CPUx86 cpu, SimOperand operand, FloatingValue value, int size)
{
Debug.Assert(!operand.IsImmediate);

if (operand.IsRegister)
{
((operand.Register) as RegisterFloatingPoint).Value = value;
var newValue = ((operand.Register) as RegisterFloatingPoint).Value;
switch (size)
{
case 128:
newValue = value;
break;
case 64:
newValue.Low = value.Low;
break;
case 32:
newValue.LowF = value.LowF;
break;
}
((operand.Register) as RegisterFloatingPoint).Value = newValue;
}

if (operand.IsLabel)
@@ -279,61 +310,50 @@ protected void Write(CPUx86 cpu, uint address, uint value, int size)
else if (size == 8) cpu.Write8(address, (byte)value);
}

protected double ReadFloat(CPUx86 cpu, uint address, int size)
protected FloatingValue ReadFloat(CPUx86 cpu, uint address, int size)
{
if (size == 64)
if (size == 128)
{
byte[] b = new byte[8];

b[0] = cpu.Read8(address + 0);
b[1] = cpu.Read8(address + 1);
b[2] = cpu.Read8(address + 2);
b[3] = cpu.Read8(address + 3);
b[4] = cpu.Read8(address + 4);
b[5] = cpu.Read8(address + 5);
b[6] = cpu.Read8(address + 6);
b[7] = cpu.Read8(address + 7);

return BitConverter.ToDouble(b, 0);
return new FloatingValue()
{
ULow = cpu.Read64(address),
UHigh = cpu.Read64(address + 0x8)
};
}
else if (size == 64)
{
return new FloatingValue()
{
ULow = cpu.Read64(address)
};
}
else if (size == 32)
{
byte[] b = new byte[4];

b[0] = cpu.Read8(address + 0);
b[1] = cpu.Read8(address + 1);
b[2] = cpu.Read8(address + 2);
b[3] = cpu.Read8(address + 3);

return BitConverter.ToSingle(b, 0);
var val = new FloatingValue();
var b = BitConverter.GetBytes(cpu.Read32(address));
val.LowF = BitConverter.ToSingle(b, 0);
return val;
}

throw new SimCPUException();
}

protected void WriteFloat(CPUx86 cpu, uint address, double value, int size)
protected void WriteFloat(CPUx86 cpu, uint address, FloatingValue value, int size)
{
if (size == 64)
if (size == 128)
{
byte[] b = BitConverter.GetBytes(value);

cpu.Write8(address + 0, b[0]);
cpu.Write8(address + 1, b[1]);
cpu.Write8(address + 2, b[2]);
cpu.Write8(address + 3, b[3]);
cpu.Write8(address + 4, b[4]);
cpu.Write8(address + 5, b[5]);
cpu.Write8(address + 6, b[6]);
cpu.Write8(address + 7, b[7]);
cpu.Write64(address, value.ULow);
cpu.Write64(address + 0x08, value.UHigh);
}
else if (size == 64)
{
cpu.Write64(address, value.ULow);
}
else if (size == 32)
{
byte[] b = BitConverter.GetBytes((float)value);

cpu.Write8(address + 0, b[0]);
cpu.Write8(address + 1, b[1]);
cpu.Write8(address + 2, b[2]);
cpu.Write8(address + 3, b[3]);
var b = BitConverter.GetBytes(value.LowF);
uint val = BitConverter.ToUInt32(b, 0);
cpu.Write32(address, val);
}
}

@@ -63,8 +63,11 @@
<Compile Include="Opcodes\Bts.cs" />
<Compile Include="Opcodes\Cmovcc.cs" />
<Compile Include="Opcodes\CmpXchg.cs" />
<Compile Include="Opcodes\Movaps.cs" />
<Compile Include="Opcodes\Movups.cs" />
<Compile Include="Opcodes\Pause.cs" />
<Compile Include="Opcodes\Lock.cs" />
<Compile Include="Opcodes\Pxor.cs" />
<Compile Include="Opcodes\Setcc.cs" />
<Compile Include="Opcodes\Test.cs" />
<Compile Include="Opcodes\InternalBreak.cs" />
@@ -1,10 +1,11 @@
/*
* (c) 2013 MOSA - The Managed Operating System Alliance
* (c) 2015 MOSA - The Managed Operating System Alliance
*
* Licensed under the terms of the New BSD License.
*
* Authors:
* Phil Garcia (tgiphil) <phil@thinkedge.com>
* Stefan Andres Charsley (charsleysa) <charsleysa@gmail.com>
*/

using Mosa.TinyCPUSimulator.x86.Opcodes;
@@ -150,7 +151,10 @@ public static class Opcode
public static BaseX86Opcode Lock = new Lock();
public static BaseX86Opcode Pause = new Pause();
public static BaseX86Opcode CmpXchg = new CmpXchg();
public static BaseX86Opcode Movups = new Movups();
public static BaseX86Opcode Movaps = new Movaps();
public static BaseX86Opcode Pxor = new Pxor();

public static BaseX86Opcode InternalBreak = new InternalBreak();
}
}
}
@@ -13,11 +13,11 @@ public class Addsd : BaseX86Opcode
{
public override void Execute(CPUx86 cpu, SimInstruction instruction)
{
double a = LoadFloatValue(cpu, instruction.Operand1);
double b = LoadFloatValue(cpu, instruction.Operand2);
int size = instruction.Operand1.Size;
var a = LoadFloatValue(cpu, instruction.Operand1, instruction.Size);
var b = LoadFloatValue(cpu, instruction.Operand2, instruction.Size);
int size = instruction.Size;

double r = a + b;
double r = a.Low + b.Low;

StoreFloatValue(cpu, instruction.Operand1, r, size);
}
@@ -9,7 +9,17 @@

namespace Mosa.TinyCPUSimulator.x86.Opcodes
{
public class Addss : Addsd
public class Addss : BaseX86Opcode
{
public override void Execute(CPUx86 cpu, SimInstruction instruction)
{
var a = LoadFloatValue(cpu, instruction.Operand1, instruction.Size);
var b = LoadFloatValue(cpu, instruction.Operand2, instruction.Size);
int size = instruction.Size;

float r = a.LowF + b.LowF;

StoreFloatValue(cpu, instruction.Operand1, r, size);
}
}
}
@@ -13,9 +13,9 @@ public class Comisd : BaseX86Opcode
{
public override void Execute(CPUx86 cpu, SimInstruction instruction)
{
double a = LoadFloatValue(cpu, instruction.Operand1);
double b = LoadFloatValue(cpu, instruction.Operand2);
int size = instruction.Operand1.Size;
var a = LoadFloatValue(cpu, instruction.Operand1, instruction.Size).Low;
var b = LoadFloatValue(cpu, instruction.Operand2, instruction.Size).Low;
int size = instruction.Size;

if (double.IsNaN(a) || double.IsNaN(b))
{
@@ -41,6 +41,10 @@ public override void Execute(CPUx86 cpu, SimInstruction instruction)
cpu.EFLAGS.Parity = false;
cpu.EFLAGS.Carry = true;
}

cpu.EFLAGS.Overflow = false;
cpu.EFLAGS.Adjust = false;
cpu.EFLAGS.Sign = false;
}
}
}
@@ -9,7 +9,42 @@

namespace Mosa.TinyCPUSimulator.x86.Opcodes
{
public class Comiss : Comisd
public class Comiss : BaseX86Opcode
{
public override void Execute(CPUx86 cpu, SimInstruction instruction)
{
var a = LoadFloatValue(cpu, instruction.Operand1, instruction.Size).LowF;
var b = LoadFloatValue(cpu, instruction.Operand2, instruction.Size).LowF;
int size = instruction.Size;

if (float.IsNaN(a) || float.IsNaN(b))
{
cpu.EFLAGS.Zero = true;
cpu.EFLAGS.Parity = true;
cpu.EFLAGS.Carry = true;
}
else if (a == b)
{
cpu.EFLAGS.Zero = true;
cpu.EFLAGS.Parity = false;
cpu.EFLAGS.Carry = false;
}
else if (a > b)
{
cpu.EFLAGS.Zero = false;
cpu.EFLAGS.Parity = false;
cpu.EFLAGS.Carry = false;
}
else
{
cpu.EFLAGS.Zero = false;
cpu.EFLAGS.Parity = false;
cpu.EFLAGS.Carry = true;
}

cpu.EFLAGS.Overflow = false;
cpu.EFLAGS.Adjust = false;
cpu.EFLAGS.Sign = false;
}
}
}
@@ -9,7 +9,14 @@

namespace Mosa.TinyCPUSimulator.x86.Opcodes
{
public class Cvtsd2ss : Cvtss2sd
public class Cvtsd2ss : BaseX86Opcode
{
public override void Execute(CPUx86 cpu, SimInstruction instruction)
{
var a = LoadFloatValue(cpu, instruction.Operand2, instruction.Operand2.Size);
int size = instruction.Operand1.Size;

StoreFloatValue(cpu, instruction.Operand1, a, size);
}
}
}
@@ -16,8 +16,7 @@ public override void Execute(CPUx86 cpu, SimInstruction instruction)
int a = (int)LoadValue(cpu, instruction.Operand2);
int size = instruction.Operand1.Size;

double r = (double)a;
StoreFloatValue(cpu, instruction.Operand1, r, size);
StoreFloatValue(cpu, instruction.Operand1, (double)a, size);
}
}
}
@@ -9,7 +9,14 @@

namespace Mosa.TinyCPUSimulator.x86.Opcodes
{
public class Cvtsi2ss : Cvtss2sd
public class Cvtsi2ss : BaseX86Opcode
{
public override void Execute(CPUx86 cpu, SimInstruction instruction)
{
int a = (int)LoadValue(cpu, instruction.Operand2);
int size = instruction.Operand1.Size;

StoreFloatValue(cpu, instruction.Operand1, (float)a, size);
}
}
}
@@ -13,7 +13,7 @@ public class Cvtss2sd : BaseX86Opcode
{
public override void Execute(CPUx86 cpu, SimInstruction instruction)
{
double a = LoadFloatValue(cpu, instruction.Operand2);
var a = LoadFloatValue(cpu, instruction.Operand2, instruction.Operand1.Size);
int size = instruction.Operand1.Size;

StoreFloatValue(cpu, instruction.Operand1, a, size);
@@ -13,10 +13,10 @@ public class Cvttsd2si : BaseX86Opcode
{
public override void Execute(CPUx86 cpu, SimInstruction instruction)
{
double a = LoadFloatValue(cpu, instruction.Operand2);
var a = LoadFloatValue(cpu, instruction.Operand2, instruction.Operand2.Size);
int size = instruction.Operand1.Size;

uint r = (uint)a;
uint r = (uint)a.Low;
StoreValue(cpu, instruction.Operand1, r, size);
}
}
@@ -9,7 +9,15 @@

namespace Mosa.TinyCPUSimulator.x86.Opcodes
{
public class Cvttss2si : Cvttsd2si
public class Cvttss2si : BaseX86Opcode
{
public override void Execute(CPUx86 cpu, SimInstruction instruction)
{
var a = LoadFloatValue(cpu, instruction.Operand2, instruction.Operand2.Size);
int size = instruction.Operand1.Size;

uint r = (uint)a.LowF;
StoreValue(cpu, instruction.Operand1, r, size);
}
}
}
@@ -13,11 +13,11 @@ public class Divsd : BaseX86Opcode
{
public override void Execute(CPUx86 cpu, SimInstruction instruction)
{
double a = LoadFloatValue(cpu, instruction.Operand1);
double b = LoadFloatValue(cpu, instruction.Operand2);
int size = instruction.Operand1.Size;
var a = LoadFloatValue(cpu, instruction.Operand1, instruction.Size);
var b = LoadFloatValue(cpu, instruction.Operand2, instruction.Size);
int size = instruction.Size;

double r = a / b;
double r = a.Low / b.Low;

StoreFloatValue(cpu, instruction.Operand1, r, size);
}
@@ -9,7 +9,17 @@

namespace Mosa.TinyCPUSimulator.x86.Opcodes
{
public class Divss : Divsd
public class Divss : BaseX86Opcode
{
public override void Execute(CPUx86 cpu, SimInstruction instruction)
{
var a = LoadFloatValue(cpu, instruction.Operand1, instruction.Size);
var b = LoadFloatValue(cpu, instruction.Operand2, instruction.Size);
int size = instruction.Size;

float r = a.LowF / b.LowF;

StoreFloatValue(cpu, instruction.Operand1, r, size);
}
}
}
@@ -13,7 +13,7 @@ public class Fld : BaseX86Opcode
{
public override void Execute(CPUx86 cpu, SimInstruction instruction)
{
double r = LoadFloatValue(cpu, instruction.Operand1);
var r = LoadFloatValue(cpu, instruction.Operand1, instruction.Operand1.Size);
int size = instruction.Operand1.Size;

cpu.ST0.Value = r;
@@ -0,0 +1,22 @@
/*
* (c) 2015 MOSA - The Managed Operating System Alliance
*
* Licensed under the terms of the New BSD License.
*
* Authors:
* Stefan Andres Charsley (charsleysa) <charsleysa@gmail.com>
*/

namespace Mosa.TinyCPUSimulator.x86.Opcodes
{
public class Movaps : BaseX86Opcode
{
public override void Execute(CPUx86 cpu, SimInstruction instruction)
{
var a = LoadFloatValue(cpu, instruction.Operand2, instruction.Size);
int size = instruction.Size;

StoreFloatValue(cpu, instruction.Operand1, a, size);
}
}
}
@@ -13,10 +13,10 @@ public class Movsd : BaseX86Opcode
{
public override void Execute(CPUx86 cpu, SimInstruction instruction)
{
double a = LoadFloatValue(cpu, instruction.Operand2);
int size = instruction.Operand1.Size;
var a = LoadFloatValue(cpu, instruction.Operand2, instruction.Size);
int size = instruction.Size;

StoreFloatValue(cpu, instruction.Operand1, a, size);
StoreFloatValue(cpu, instruction.Operand1, a.Low, size);
}
}
}
@@ -1,15 +1,22 @@
/*
* (c) 2013 MOSA - The Managed Operating System Alliance
* (c) 2015 MOSA - The Managed Operating System Alliance
*
* Licensed under the terms of the New BSD License.
*
* Authors:
* Phil Garcia (tgiphil) <phil@thinkedge.com>
* Stefan Andres Charsley (charsleysa) <charsleysa@gmail.com>
*/

namespace Mosa.TinyCPUSimulator.x86.Opcodes
{
public class Movss : Movsd
public class Movss : BaseX86Opcode
{
public override void Execute(CPUx86 cpu, SimInstruction instruction)
{
var a = LoadFloatValue(cpu, instruction.Operand2, instruction.Size);
int size = instruction.Size;

StoreFloatValue(cpu, instruction.Operand1, a.LowF, size);
}
}
}
@@ -0,0 +1,22 @@
/*
* (c) 2015 MOSA - The Managed Operating System Alliance
*
* Licensed under the terms of the New BSD License.
*
* Authors:
* Stefan Andres Charsley (charsleysa) <charsleysa@gmail.com>
*/

namespace Mosa.TinyCPUSimulator.x86.Opcodes
{
public class Movups : BaseX86Opcode
{
public override void Execute(CPUx86 cpu, SimInstruction instruction)
{
var a = LoadFloatValue(cpu, instruction.Operand2, instruction.Size);
int size = instruction.Size;

StoreFloatValue(cpu, instruction.Operand1, a, size);
}
}
}
@@ -13,11 +13,11 @@ public class Mulsd : BaseX86Opcode
{
public override void Execute(CPUx86 cpu, SimInstruction instruction)
{
double a = LoadFloatValue(cpu, instruction.Operand1);
double b = LoadFloatValue(cpu, instruction.Operand2);
int size = instruction.Operand1.Size;
var a = LoadFloatValue(cpu, instruction.Operand1, instruction.Size);
var b = LoadFloatValue(cpu, instruction.Operand2, instruction.Size);
int size = instruction.Size;

double r = a * b;
double r = a.Low * b.Low;

StoreFloatValue(cpu, instruction.Operand1, r, size);
}
@@ -9,7 +9,17 @@

namespace Mosa.TinyCPUSimulator.x86.Opcodes
{
public class Mulss : Mulsd
public class Mulss : BaseX86Opcode
{
public override void Execute(CPUx86 cpu, SimInstruction instruction)
{
var a = LoadFloatValue(cpu, instruction.Operand1, instruction.Size);
var b = LoadFloatValue(cpu, instruction.Operand2, instruction.Size);
int size = instruction.Size;

float r = a.LowF * b.LowF;

StoreFloatValue(cpu, instruction.Operand1, r, size);
}
}
}
@@ -0,0 +1,26 @@
/*
* (c) 2015 MOSA - The Managed Operating System Alliance
*
* Licensed under the terms of the New BSD License.
*
* Authors:
* Stefan Andres Charsley (charsleysa) <charsleysa@gmail.com>
*/

namespace Mosa.TinyCPUSimulator.x86.Opcodes
{
public class Pxor : BaseX86Opcode
{
public override void Execute(CPUx86 cpu, SimInstruction instruction)
{
var a = LoadFloatValue(cpu, instruction.Operand1, instruction.Size);
var b = LoadFloatValue(cpu, instruction.Operand2, instruction.Size);
int size = instruction.Size;

a.ULow = a.ULow ^ b.ULow;
a.UHigh = a.UHigh ^ b.UHigh;

StoreFloatValue(cpu, instruction.Operand1, a, size);
}
}
}
@@ -15,13 +15,27 @@ public class Roundsd : BaseX86Opcode
{
public override void Execute(CPUx86 cpu, SimInstruction instruction)
{
double a = LoadFloatValue(cpu, instruction.Operand1);
var a = LoadFloatValue(cpu, instruction.Operand1, instruction.Size);
uint p = LoadValue(cpu, instruction.Operand2);
int size = instruction.Operand1.Size;
int size = instruction.Size;

//TODO - p is ignored

double r = Math.Truncate(a);
double r;
if ((p & 0x3) == 0x3)
{
r = Math.Truncate(a.Low);
}
else if ((p & 0x2) == 0x2)
{
r = Math.Ceiling(a.Low);
}
else if ((p & 0x1) == 0x1)
{
r = Math.Floor(a.Low);
}
else
{
r = Math.Round(a.Low);
}

StoreFloatValue(cpu, instruction.Operand1, r, size);
}
@@ -7,9 +7,37 @@
* Phil Garcia (tgiphil) <phil@thinkedge.com>
*/

using System;

namespace Mosa.TinyCPUSimulator.x86.Opcodes
{
public class Roundss : Movsd
public class Roundss : BaseX86Opcode
{
public override void Execute(CPUx86 cpu, SimInstruction instruction)
{
var a = LoadFloatValue(cpu, instruction.Operand1, instruction.Size);
uint p = LoadValue(cpu, instruction.Operand2);
int size = instruction.Size;

float r;
if ((p & 0x3) == 0x3)
{
r = (float)Math.Truncate(a.LowF);
}
else if ((p & 0x2) == 0x2)
{
r = (float)Math.Ceiling(a.LowF);
}
else if ((p & 0x1) == 0x1)
{
r = (float)Math.Floor(a.LowF);
}
else
{
r = (float)Math.Round(a.LowF);
}

StoreFloatValue(cpu, instruction.Operand1, r, size);
}
}
}
@@ -13,11 +13,11 @@ public class Subsd : BaseX86Opcode
{
public override void Execute(CPUx86 cpu, SimInstruction instruction)
{
double a = LoadFloatValue(cpu, instruction.Operand1);
double b = LoadFloatValue(cpu, instruction.Operand2);
int size = instruction.Operand1.Size;
var a = LoadFloatValue(cpu, instruction.Operand1, instruction.Size);
var b = LoadFloatValue(cpu, instruction.Operand2, instruction.Size);
int size = instruction.Size;

double r = a - b;
double r = a.Low - b.Low;

StoreFloatValue(cpu, instruction.Operand1, r, size);
}
@@ -9,7 +9,17 @@

namespace Mosa.TinyCPUSimulator.x86.Opcodes
{
public class Subss : Subsd
public class Subss : BaseX86Opcode
{
public override void Execute(CPUx86 cpu, SimInstruction instruction)
{
var a = LoadFloatValue(cpu, instruction.Operand1, instruction.Size);
var b = LoadFloatValue(cpu, instruction.Operand2, instruction.Size);
int size = instruction.Size;

float r = a.LowF - b.LowF;

StoreFloatValue(cpu, instruction.Operand1, r, size);
}
}
}
@@ -13,9 +13,9 @@ public class Ucomisd : BaseX86Opcode
{
public override void Execute(CPUx86 cpu, SimInstruction instruction)
{
double a = LoadFloatValue(cpu, instruction.Operand1);
double b = LoadFloatValue(cpu, instruction.Operand2);
int size = instruction.Operand1.Size;
var a = LoadFloatValue(cpu, instruction.Operand1, instruction.Size).Low;
var b = LoadFloatValue(cpu, instruction.Operand2, instruction.Size).Low;
int size = instruction.Size;

if (double.IsNaN(a) || double.IsNaN(b))
{
@@ -41,6 +41,10 @@ public override void Execute(CPUx86 cpu, SimInstruction instruction)
cpu.EFLAGS.Parity = false;
cpu.EFLAGS.Carry = true;
}

cpu.EFLAGS.Overflow = false;
cpu.EFLAGS.Adjust = false;
cpu.EFLAGS.Sign = false;
}
}
}
@@ -9,7 +9,42 @@

namespace Mosa.TinyCPUSimulator.x86.Opcodes
{
public class Ucomiss : Comisd
public class Ucomiss : BaseX86Opcode
{
public override void Execute(CPUx86 cpu, SimInstruction instruction)
{
var a = LoadFloatValue(cpu, instruction.Operand1, instruction.Size).LowF;
var b = LoadFloatValue(cpu, instruction.Operand2, instruction.Size).LowF;
int size = instruction.Size;

if (float.IsNaN(a) || float.IsNaN(b))
{
cpu.EFLAGS.Zero = true;
cpu.EFLAGS.Parity = true;
cpu.EFLAGS.Carry = true;
}
else if (a == b)
{
cpu.EFLAGS.Zero = true;
cpu.EFLAGS.Parity = false;
cpu.EFLAGS.Carry = false;
}
else if (a > b)
{
cpu.EFLAGS.Zero = false;
cpu.EFLAGS.Parity = false;
cpu.EFLAGS.Carry = false;
}
else
{
cpu.EFLAGS.Zero = false;
cpu.EFLAGS.Parity = false;
cpu.EFLAGS.Carry = true;
}

cpu.EFLAGS.Overflow = false;
cpu.EFLAGS.Adjust = false;
cpu.EFLAGS.Sign = false;
}
}
}
@@ -98,14 +98,14 @@ public SimState(CPUx86 x86)
CR3 = x86.CR3.Value;
CR4 = x86.CR4.Value;

XMM0 = x86.XMM0.Value;
XMM1 = x86.XMM1.Value;
XMM2 = x86.XMM2.Value;
XMM3 = x86.XMM3.Value;
XMM4 = x86.XMM4.Value;
XMM5 = x86.XMM5.Value;
XMM6 = x86.XMM6.Value;
XMM7 = x86.XMM7.Value;
XMM0 = x86.XMM0.Value.Low;
XMM1 = x86.XMM1.Value.Low;
XMM2 = x86.XMM2.Value.Low;
XMM3 = x86.XMM3.Value.Low;
XMM4 = x86.XMM4.Value.Low;
XMM5 = x86.XMM5.Value.Low;
XMM6 = x86.XMM6.Value.Low;
XMM7 = x86.XMM7.Value.Low;

Zero = x86.EFLAGS.Zero;
Parity = x86.EFLAGS.Parity;
@@ -7,11 +7,12 @@
* Phil Garcia (tgiphil) <phil@thinkedge.com>
*/

using System.Runtime.InteropServices;
namespace Mosa.TinyCPUSimulator
{
public class RegisterFloatingPoint : SimRegister
{
public virtual double Value { get; set; }
public virtual FloatingValue Value { get; set; }

public RegisterFloatingPoint(string name, int index, RegisterType registerType, bool physical)
: base(name, index, registerType, 128, physical)
@@ -25,7 +26,46 @@ public RegisterFloatingPoint(string name, int index, RegisterType registerType)

public override string ToString()
{
return base.ToString() + " = 0x" + Value.ToString("D");
return base.ToString() + " = 0x" + Value.High.ToString("D") + Value.Low.ToString("D");
}
}

[StructLayout(LayoutKind.Explicit, Size = 16)]
public struct FloatingValue
{
// As Float
//[FieldOffset(0)]
//public float LowLow;
//[FieldOffset(4)]
//public float LowHigh;
//[FieldOffset(8)]
//public float HighLow;
//[FieldOffset(12)]
//public float HighHigh;

// To/From Float
public float LowF
{
get { return (float)Low; }
set { Low = (double)value; }
}

public float HighF
{
get { return (float)Low; }
set { Low = (double)value; }
}

// As Double
[FieldOffset(0)]
public double Low;
[FieldOffset(8)]
public double High;

// As ULong
[FieldOffset(0)]
public ulong ULow;
[FieldOffset(8)]
public ulong UHigh;
}
}
@@ -301,6 +301,22 @@ protected void InternalWrite8(ulong address, byte value)
//Debug.Assert(InternalRead8(address) == value);
}

public ulong DirectRead64(ulong address)
{
uint low = InternalRead32(address);
uint high = InternalRead32(address + 0x4);
ulong val = high | ((ulong)low << 32);

var value = val;

if (Endian.NativeIsLittleEndian)
{
value = Endian.Swap(value);
}

return value;
}

public uint DirectRead32(ulong address)
{
uint value = InternalRead32(address);
@@ -330,6 +346,29 @@ public byte DirectRead8(ulong address)
return InternalRead8(address);
}

public void DirectWrite64(ulong address, ulong value)
{
ulong val = value;

if (Endian.NativeIsLittleEndian)
{
val = Endian.Swap(val);
}

uint low = (uint)(val >> 32);
uint high = (uint)val;

InternalWrite32(address, low);
InternalWrite32(address + 0x4, high);

// very slow performance if assert enabled
//Debug.Assert(DirectRead64(address) == value);

//Debug.WriteLine(address.ToString("X") + ": " + value.ToString("X"));

MemoryUpdate(address, 64);
}

public void DirectWrite32(ulong address, uint value)
{
uint val = value;
@@ -395,6 +434,11 @@ public void Write32(ulong address, uint value)
DirectWrite32(TranslateToPhysical(address), value);
}

public void Write64(ulong address, ulong value)
{
DirectWrite64(TranslateToPhysical(address), value);
}

public byte Read8(ulong address)
{
return DirectRead8(TranslateToPhysical(address));
@@ -410,6 +454,11 @@ public uint Read32(ulong address)
return DirectRead32(TranslateToPhysical(address));
}

public ulong Read64(ulong address)
{
return DirectRead64(TranslateToPhysical(address));
}

public void SetSymbol(string name, ulong address, ulong size)
{
Symbols.Add(name, new SimSymbol(name, address, size));
@@ -17,7 +17,7 @@ public class SimSymbol

public ulong Size { get; private set; }

public ulong EndAddress { get { return Address + Size; } }
public ulong EndAddress { get { return Size == 0 ? Address : Address + Size - 1; } }

public SimSymbol(string name, ulong address, ulong size)
{
@@ -28,7 +28,7 @@ public SimSymbol(string name, ulong address, ulong size)

public override string ToString()
{
return "0x" + Address.ToString("X") + " " + Name;
return "0x" + Address.ToString("X") + " - " + "0x" + EndAddress.ToString("X") + " " + Name + " (" + Size.ToString() + ")";
}
}
}
}
@@ -42,7 +42,7 @@ private class MethodStages
public List<string> OrderedStageNames = new List<string>();
public List<string> OrderedDebugStageNames = new List<string>();
public Dictionary<string, List<string>> InstructionLogs = new Dictionary<string, List<string>>();
public Dictionary<string, string> DebugLogs = new Dictionary<string, string>();
public Dictionary<string, List<string>> DebugLogs = new Dictionary<string, List<string>>();
}

private StringBuilder compileLog = new StringBuilder();
@@ -186,7 +186,7 @@ private void SubmitInstructionTraceInformation(MosaMethod method, string stage,
}
}

private void SubmitDebugStageInformation(MosaMethod method, string stage, string lines)
private void SubmitDebugStageInformation(MosaMethod method, string stage, List<string> lines)
{
lock (methodStagelock)
{
@@ -517,9 +517,13 @@ private void cbDebugStages_SelectedIndexChanged(object sender, EventArgs e)
string stage = cbDebugStages.SelectedItem.ToString();

if (methodStage.DebugLogs.ContainsKey(stage))
rbOtherResult.Text = methodStage.DebugLogs[stage].ToString();
{
rbOtherResult.Text = GetDebugLogText(methodStage.DebugLogs[stage]);
}
else
{
rbOtherResult.Text = string.Empty;
}
}
}

@@ -620,11 +624,13 @@ private void toolStripButton3_Click(object sender, EventArgs e)

private void cbLabels_SelectedIndexChanged(object sender, EventArgs e)
{
tbResult.Text = string.Empty;
SetStatus(string.Empty);

if (currentInstructionLines == null)
{
tbResult.Text = string.Empty;
return;
}

var node = GetCurrentNode<ViewNode<MosaMethod>>();

@@ -633,9 +639,34 @@ private void cbLabels_SelectedIndexChanged(object sender, EventArgs e)

SetStatus(node.Type.FullName);

tbResult.Text = GetCurrentStageInstructions(currentInstructionLines);
}

private string GetDebugLogText(List<string> list)
{
var result = new StringBuilder();

if (currentInstructionLines == null)
return string.Empty;

foreach (var l in list)
{
result.AppendLine(l);
}

return result.ToString();
}

private string GetCurrentStageInstructions(List<string> lines)
{
var result = new StringBuilder();

if (lines == null)
return string.Empty;

if (cbLabels.SelectedIndex == 0)
{
foreach (string l in currentInstructionLines)
foreach (string l in lines)
{
string line = l;

@@ -645,18 +676,18 @@ private void cbLabels_SelectedIndexChanged(object sender, EventArgs e)
if (line.Contains("IR.BlockStart") || line.Contains("IR.BlockEnd"))
continue;

tbResult.AppendText(line);
tbResult.AppendText("\n");
result.Append(line);
result.Append("\n");
}

return;
return result.ToString();
}

string blockLabel = cbLabels.SelectedItem as string;

bool inBlock = false;

foreach (string l in currentInstructionLines)
foreach (string l in lines)
{
string line = l;

@@ -673,13 +704,17 @@ private void cbLabels_SelectedIndexChanged(object sender, EventArgs e)
if (line.Contains("IR.BlockStart") || line.Contains("IR.BlockEnd"))
continue;

tbResult.AppendText(line);
tbResult.AppendText("\n");
result.Append(line);
result.Append("\n");

if (line.StartsWith(" Next:"))
return;
{
return result.ToString();
}
}
}

return result.ToString();
}

private void toolStripButton4_Click(object sender, EventArgs e)
@@ -727,12 +762,61 @@ void ITraceListener.OnNewTraceLog(TraceLog traceLog)
if (traceLog.Section != null)
stagesection = stagesection + "-" + traceLog.Section;

SubmitDebugStageInformation(traceLog.Method, stagesection, traceLog.ToString());
SubmitDebugStageInformation(traceLog.Method, stagesection, traceLog.Lines);
}
else if (traceLog.Type == TraceType.InstructionList)
{
SubmitInstructionTraceInformation(traceLog.Method, traceLog.Stage, traceLog.Lines);
}
}

private void dumpAllMethodStagesToolStripMenuItem_Click(object sender, EventArgs e)
{
var node = GetCurrentNode<ViewNode<MosaMethod>>();

if (node == null)
return;

var type = node.Type.FullName;

if (folderBrowserDialog1.ShowDialog() == System.Windows.Forms.DialogResult.OK)
{
var path = folderBrowserDialog1.SelectedPath;

cbStages.SelectedIndex = 0;

while (true)
{
cbStages_SelectedIndexChanged(null, null);

string stage = cbStages.SelectedItem.ToString();
var result = tbResult.Text.Replace("\n", "\r\n");

File.WriteAllText(Path.Combine(path, stage + "-stage.txt"), result);

if (cbStages.Items.Count == cbStages.SelectedIndex + 1)
break;

cbStages.SelectedIndex++;
}

cbDebugStages.SelectedIndex = 0;

while (true)
{
cbDebugStages_SelectedIndexChanged(null, null);

string stage = cbDebugStages.SelectedItem.ToString();
var result = rbOtherResult.Text.Replace("\n","\r\n");

File.WriteAllText(Path.Combine(path, stage + "-debug.txt"), result);

if (cbDebugStages.Items.Count == cbDebugStages.SelectedIndex + 1)
break;

cbDebugStages.SelectedIndex++;
}
}
}
}
}
@@ -183,6 +183,9 @@
RK5CYII=
</value>
</data>
<metadata name="folderBrowserDialog1.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
<value>486, 17</value>
</metadata>
<metadata name="$this.TrayHeight" type="System.Int32, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>25</value>
</metadata>
@@ -71,18 +71,18 @@ private void UpdateBuilderOptions()
switch (cbImageFormat.SelectedIndex)
{
case 0: Options.ImageFormat = ImageFormat.IMG; break;
case 1: Options.ImageFormat = ImageFormat.VHD; break;
case 2: Options.ImageFormat = ImageFormat.VDI; break;
case 3: Options.ImageFormat = ImageFormat.ISO; break;
case 1: Options.ImageFormat = ImageFormat.ISO; break;
case 2: Options.ImageFormat = ImageFormat.VHD; break;
case 3: Options.ImageFormat = ImageFormat.VDI; break;
case 4: Options.ImageFormat = ImageFormat.VMDK; break;
default: break;
}

switch (cbEmulator.SelectedIndex)
{
case 0: Options.Emulator = EmulatorType.Qemu; break;
case 1: Options.Emulator = EmulatorType.Boches; break;
case 2: Options.Emulator = EmulatorType.WMware; break;
case 1: Options.Emulator = EmulatorType.Bochs; break;
case 2: Options.Emulator = EmulatorType.VMware; break;
default: break;
}

@@ -149,18 +149,18 @@ private void UpdateInterfaceOptions()
switch (Options.ImageFormat)
{
case ImageFormat.IMG: cbImageFormat.SelectedIndex = 0; break;
case ImageFormat.VHD: cbImageFormat.SelectedIndex = 1; break;
case ImageFormat.VDI: cbImageFormat.SelectedIndex = 2; break;
case ImageFormat.ISO: cbImageFormat.SelectedIndex = 3; break;
case ImageFormat.ISO: cbImageFormat.SelectedIndex = 1; break;
case ImageFormat.VHD: cbImageFormat.SelectedIndex = 2; break;
case ImageFormat.VDI: cbImageFormat.SelectedIndex = 3; break;
case ImageFormat.VMDK: cbImageFormat.SelectedIndex = 4; break;
default: break;
}

switch (Options.Emulator)
{
case EmulatorType.Qemu: cbEmulator.SelectedIndex = 0; break;
case EmulatorType.Boches: cbEmulator.SelectedIndex = 1; break;
case EmulatorType.WMware: cbEmulator.SelectedIndex = 2; break;
case EmulatorType.Bochs: cbEmulator.SelectedIndex = 1; break;
case EmulatorType.VMware: cbEmulator.SelectedIndex = 2; break;
default: break;
}

@@ -300,8 +300,8 @@ public void Launch()
switch (Options.Emulator)
{
case EmulatorType.Qemu: LaunchQemu(Options.ExitOnLaunch); break;
case EmulatorType.Boches: LaunchBochs(Options.ExitOnLaunch); break;
case EmulatorType.WMware: LaunchVMwarePlayer(Options.ExitOnLaunch); break;
case EmulatorType.Bochs: LaunchBochs(Options.ExitOnLaunch); break;
case EmulatorType.VMware: LaunchVMwarePlayer(Options.ExitOnLaunch); break;
default: throw new InvalidOperationException();
}
}
@@ -322,6 +322,11 @@ private void LaunchQemu(bool exit)
" -hda " + Quote(imageFile);
}

if (Options.PlatformType == PlatformType.X86)
{
arg = arg + " -cpu qemu32,+sse4.1";
}

//arg = arg + " -vga vmware";

if (Options.DebugConnectionOption == DebugConnectionOption.Pipe)
@@ -18,12 +18,30 @@ public static class CheckOptions
{
public static string Verify(Options options)
{
if (options.Emulator == EmulatorType.Boches && options.ImageFormat == ImageFormat.VMDK)
if (options.Emulator == EmulatorType.Qemu && options.ImageFormat == ImageFormat.VDI)
{
return "QEMU does not support the VDI image format";
}

if (options.Emulator == EmulatorType.Bochs && options.ImageFormat == ImageFormat.VDI)
{
return "Boches does not support the VDI image format";
}

if (options.Emulator == EmulatorType.Bochs && options.ImageFormat == ImageFormat.VMDK)
{
return "Boches does not support the VMDK image format";
}

//TODO: Add more checks
if (options.Emulator == EmulatorType.VMware && options.ImageFormat == ImageFormat.IMG)
{
return "VMware does not support the IMG image format";
}

if (options.Emulator == EmulatorType.VMware && options.ImageFormat == ImageFormat.VDI)
{
return "VMware does not support the VHD image format";
}

return null;
}
@@ -9,5 +9,5 @@

namespace Mosa.Utility.Launcher
{
public enum EmulatorType { Qemu, WMware, Boches };
public enum EmulatorType { Qemu, VMware, Bochs };
}
@@ -126,8 +126,8 @@ public void LoadArguments(string[] args)
case "-map": GenerateMapFile = true; continue;
case "-asm": GenerateASMFile = true; continue;
case "-qemu": Emulator = EmulatorType.Qemu; continue;
case "-vmware": Emulator = EmulatorType.WMware; continue;
case "-bochs": Emulator = EmulatorType.Boches; continue;
case "-vmware": Emulator = EmulatorType.VMware; continue;
case "-bochs": Emulator = EmulatorType.Bochs; continue;
case "-debugger": MOSADebugger = true; continue;
case "-vhd": ImageFormat = ImageFormat.VHD; continue;
case "-img": ImageFormat = ImageFormat.IMG; continue;
BIN +287 KB (200%) Tools/ndisasm/ndisasm.exe
Binary file not shown.
BIN +0 Bytes (100%) Tools/qemu/bios/bios.bin
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
BIN +869 KB (150%) Tools/qemu/qemu-img.exe
Binary file not shown.
BIN +2.73 MB Tools/qemu/qemu-io.exe
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.