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.
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;
I think that this does it:
function SupportsSSE2: LongBool;
const
CPUID_INTEL_SSE2 = $04000000;
asm
push ebx
mov eax, 1
cpuid
mov eax, FALSE
test edx, CPUID_INTEL_SSE2
jz @END
mov eax, TRUE
@END:
pop ebx
end;
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With