5

I'm trying to build slightly modified versions of some functions of the VS2010 CRT library, all is well except for the parts where it tries to access a global variable which presumably holds the instruction set architecture version (ISA):

if (__isa_available > __ISA_AVAILABLE_SSE2)
{
    // ...
}
else if (__isa_available == __ISA_AVAILABLE_SSE2)
{
    // ...
}

The values it should hold I found in an assembly file

__ISA_AVAILABLE_X86   equ 0
__ISA_AVAILABLE_SSE2  equ 1
__ISA_AVAILABLE_SSE42 equ 2
__ISA_AVAILABLE_AVX   equ 3

How and where __isa_available is assigned a value is nowhere to be found (I've tried a find-in-files in all my directories...)

MSDN refers to the CPUID example to determine the instruction set. The problem with that is it uses __asm blocks and those are not allowed in my x64 build.

Does anyone knows how to quickly assign the correct value to __isa_available?

Peter Cordes
  • 328,167
  • 45
  • 605
  • 847
demorge
  • 1,097
  • 1
  • 7
  • 17

2 Answers2

4

Microsoft decided to stop the support of inline assembly. But they introduced a new format. You can find more information about CPUID in the new format here (with example).

The advantage of intrinsics over inline assembly is that they are compatible with both x86 and x64 without additional code and are easier to use.

0xC0000022L
  • 20,597
  • 9
  • 86
  • 152
Fox32
  • 13,126
  • 9
  • 50
  • 71
3

VC++ has an intrinsic that allows you to use CPUID without inline ASM:

__cpuid in intrin.h

On that same website is an extensive code sample, too.

0xC0000022L
  • 20,597
  • 9
  • 86
  • 152
pezcode
  • 5,490
  • 2
  • 24
  • 37