Cosmos/source/Cosmos.Core_Asm/CPUInformationPlugs/CanReadCPUID.cs
Valentin Charbonnier 2c28dff298 First CPU Impl.
2018-03-26 21:20:51 +02:00

35 lines
963 B
C#

using XSharp;
using XSharp.Assembler;
namespace Cosmos.Core_Asm.CPUInformationPlugs
{
class CanReadCPUID : AssemblerMethod
{
public override void AssembleNew(Assembler aAssembler, object aMethodInfo)
{
/*
* pushfd
* pushfd
* xor dword [esp], 00200000h
* popfd
* pushfd
* pop eax
* xor eax, [esp]
* and eax, 00200000h
* ret
*/
XS.Pushfd();
XS.Pushfd();
XS.Xor(XSRegisters.ESP, 0x00200000, destinationIsIndirect: true);
XS.Popfd();
XS.Pushfd();
XS.Pop(XSRegisters.EAX);
XS.Xor(XSRegisters.EAX, XSRegisters.ESP, destinationIsIndirect: true);
XS.Popfd();
XS.And(XSRegisters.EAX, 0x00200000);
XS.Set(XSRegisters.EAX, 1);
XS.Push(XSRegisters.EAX);
}
}
}