mirror of
https://github.com/danbulant/Cosmos
synced 2026-05-22 22:09:12 +00:00
- To solve the slowness of the MemoryBlock Fill() method when the block has a big size I've created a new class for this MemoryOperations that for now contains only the method Fill() with a part implemented in ASM and with some overloads to semplify its usage from managed code. In future in this class will be added other methods to operate fast on memory for example Cmp() and Copy(). - Adding (not passing) test of the Color struct to the BoxingTest kernel - Removed BoxingTest kernel inside BCL test: it was a duplicate of the BoxingTest kernel - Restored correct TestKernelSets - In the CGS Test kernel the last rectangle is now LimeGreen instead of another type of red (more clear that is working correctly) - Added to X# the generation of the instruction Shuftps - Added to X# the generation of the instruction MoveUPS - Modified Guess Demo to wait for a key press to terminate (it closed suddenly in case the number was guessed) - The VBE IOMemoryBlock has again size of 1920x1200 (the max usable) - Added CGS Demo - Code clean up
185 lines
5.5 KiB
C#
185 lines
5.5 KiB
C#
using System;
|
|
using Cosmos.Assembler.x86.SSE;
|
|
using Cosmos.Assembler.x86.x87;
|
|
using static XSharp.Compiler.XSRegisters;
|
|
|
|
namespace XSharp.Compiler
|
|
{
|
|
partial class XS
|
|
{
|
|
public static class SSE
|
|
{
|
|
public static void SSEInit()
|
|
{
|
|
XS.Comment("BEGIN - SSE Init");
|
|
|
|
// CR4[bit 9]=1, CR4[bit 10]=1, CR0[bit 2]=0, CR0[bit 1]=1
|
|
|
|
XS.Set(EAX, CR4);
|
|
XS.Or(EAX, 0x100);
|
|
XS.Set(CR4, EAX);
|
|
XS.Set(EAX, CR4);
|
|
XS.Or(EAX, 0x200);
|
|
XS.Set(CR4, EAX);
|
|
XS.Set(EAX, CR0);
|
|
XS.And(EAX, 0xfffffffd);
|
|
XS.Set(CR0, EAX);
|
|
XS.Set(EAX, CR0);
|
|
|
|
XS.And(EAX, 1);
|
|
XS.Set(CR0, EAX);
|
|
XS.Comment("END - SSE Init");
|
|
}
|
|
|
|
public static void AddSS(RegisterXMM destination, RegisterXMM source)
|
|
{
|
|
DoDestinationSource<AddSS>(destination, source);
|
|
}
|
|
|
|
public static void MulSS(RegisterXMM destination, RegisterXMM source)
|
|
{
|
|
DoDestinationSource<MulSS>(destination, source);
|
|
}
|
|
|
|
public static void SubSS(RegisterXMM destination, RegisterXMM source)
|
|
{
|
|
DoDestinationSource<SubSS>(destination, source);
|
|
}
|
|
|
|
public static void XorPS(RegisterXMM destination, RegisterXMM source)
|
|
{
|
|
DoDestinationSource<XorPS>(destination, source);
|
|
}
|
|
|
|
public static void CompareSS(RegisterXMM destination, RegisterXMM source, ComparePseudoOpcodes comparision)
|
|
{
|
|
new CompareSS()
|
|
{
|
|
DestinationReg = destination,
|
|
SourceReg = source,
|
|
pseudoOpcode = (byte) comparision
|
|
};
|
|
}
|
|
|
|
public static void ConvertSI2SS(RegisterXMM destination, Register32 source, bool sourceIsIndirect = false)
|
|
{
|
|
new ConvertSI2SS()
|
|
{
|
|
DestinationReg = destination,
|
|
SourceReg = source,
|
|
SourceIsIndirect = sourceIsIndirect
|
|
};
|
|
}
|
|
|
|
public static void MoveSS(RegisterXMM destination, Register32 source, bool sourceIsIndirect = false)
|
|
{
|
|
new MoveSS()
|
|
{
|
|
DestinationReg = destination,
|
|
SourceReg = source,
|
|
SourceIsIndirect = sourceIsIndirect
|
|
};
|
|
}
|
|
|
|
public static void MoveSS(Register32 destination, RegisterXMM source, bool destinationIsIndirect = false)
|
|
{
|
|
new MoveSS()
|
|
{
|
|
DestinationReg = destination,
|
|
DestinationIsIndirect = destinationIsIndirect,
|
|
SourceReg = source
|
|
};
|
|
}
|
|
|
|
public static void MoveSS(RegisterXMM destination, String sourceLabel, bool destinationIsIndirect = false, int? destinationDisplacement = null, bool sourceIsIndirect = false, int? sourceDisplacement = null)
|
|
{
|
|
DoDestinationSource<MoveSS>(destination, sourceLabel, destinationIsIndirect, destinationDisplacement, sourceIsIndirect, sourceDisplacement);
|
|
}
|
|
|
|
public static void MoveUPS(Register32 destination, RegisterXMM source, bool destinationIsIndirect = false, int? destinationDisplacement = null, bool sourceIsIndirect = false, int? sourceDisplacement = null)
|
|
{
|
|
DoDestinationSource<MoveUPS>(destination, source, destinationIsIndirect, destinationDisplacement, sourceIsIndirect, sourceDisplacement);
|
|
}
|
|
|
|
#if false
|
|
public static void MoveUPS(Register32 destination, RegisterXMM source, bool destinationIsIndirect = false, Register32 destinationDisplacement = null, bool sourceIsIndirect = false, int? sourceDisplacement = null)
|
|
{
|
|
//DoDestinationSource<MoveUPS>(destination, source, destinationIsIndirect, destinationDisplacement, sourceIsIndirect, sourceDisplacement);
|
|
new MoveUPS()
|
|
{
|
|
DestinationReg = destination,
|
|
DestinationIsIndirect = destinationIsIndirect,
|
|
DestinationDisplacement = (int)destinationDisplacement,
|
|
SourceDisplacement = sourceDisplacement,
|
|
SourceReg = source
|
|
};
|
|
}
|
|
#endif
|
|
|
|
public static void ConvertSS2SD(RegisterXMM destination, Register32 source, bool sourceIsIndirect = false)
|
|
{
|
|
new ConvertSS2SD()
|
|
{
|
|
DestinationReg = destination,
|
|
SourceReg = source,
|
|
SourceIsIndirect = sourceIsIndirect
|
|
};
|
|
}
|
|
|
|
public static void ConvertSS2SIAndTruncate(Register32 destination, RegisterXMM source)
|
|
{
|
|
new ConvertSS2SIAndTruncate
|
|
{
|
|
DestinationReg = destination,
|
|
SourceReg = source
|
|
};
|
|
}
|
|
|
|
public static void DivPS(RegisterXMM destination, RegisterXMM source)
|
|
{
|
|
new DivPS
|
|
{
|
|
DestinationReg = destination,
|
|
SourceReg = source
|
|
};
|
|
}
|
|
|
|
public static void DivSS(RegisterXMM destination, RegisterXMM source)
|
|
{
|
|
new DivSS
|
|
{
|
|
DestinationReg = destination,
|
|
SourceReg = source
|
|
};
|
|
}
|
|
|
|
public static void FXSave(Register32 destination, bool isIndirect)
|
|
{
|
|
new FXSave
|
|
{
|
|
DestinationReg = destination,
|
|
DestinationIsIndirect = isIndirect
|
|
};
|
|
}
|
|
|
|
public static void FXRestore(Register32 destination, bool isIndirect)
|
|
{
|
|
new FXStore()
|
|
{
|
|
DestinationReg = destination,
|
|
DestinationIsIndirect = isIndirect
|
|
};
|
|
}
|
|
|
|
public static void Shufps(RegisterXMM destination, RegisterXMM source, int bitmask)
|
|
{
|
|
new Shufps()
|
|
{
|
|
DestinationReg = destination,
|
|
SourceReg = source,
|
|
pseudoOpcode = (byte)bitmask
|
|
};
|
|
}
|
|
}
|
|
}
|
|
}
|