Search code examples
delphissebasm

How to probe a computer if it supports SSE2 in Delphi 32?


The c++ way to do it is here (under Windows).

The same answer but under Linux using GCC.

Excerpt of the relevant asm code as I understand it:

mov     eax, 1
cpuid
mov     features, edx

I'm not very comfortable at BASM.

My Question:

I need to wrap the test as follows

function IsSSE2: Boolean;
begin
  try
    Result := False;
    //
    // Some BASM code here
    //
  except
    Result := False;
  end;
end;

Please help me.


Solution

  • You can do that without assembler as well. Works with Windows XP and newer only though.

    function IsProcessorFeaturePresent(ProcessorFeature: DWORD): BOOL; stdcall;
      external kernel32 name 'IsProcessorFeaturePresent';
    
    const
      PF_XMMI64_INSTRUCTIONS_AVAILABLE = 10;
    
    function HasSSE2: boolean;
    begin
      result := IsProcessorFeaturePresent(PF_XMMI64_INSTRUCTIONS_AVAILABLE);
    end;