[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

CPUID detection



Hi,

"Mum, I did it, yeahhhh!"

I'm not Anakin Skywalker, bu I'm happy, too.

I attached the working CPUID detection which is based on assembler
(Linux and Windows).

PS: Am I good?

bye

Felix Kollmann, DG5PT

Future Interactive 

email: fkollmann@gmx.net
http://www.futureint.com

----
Don't fear the future, because fear is the path to the dark side.
Fear is to angry. Angry is to hate and hate is to suffering.
-- Yoda
// detects the CPU

void def_system::CPUDETECTING()
{
FUNC ("void def_system::CPUDETECTING()")

  unsigned long id;

#ifdef Linux

  unsigned long adress= 0x80000001;

  asm (
  "mov %%eax, %1					\n"
  "CPUID						\n"
  "mov %0, %%edx					\n"

  :"=d" (id)
  :"a" (adress)
  );

#else ifdef Windows

  __asm {
  mov eax, 80000001h
  CPUID
  mov id, edx
  };
  
#endif

// checking for technologies

#define CPUID_esd       33554432        // 2^25 (bit 25)
#define CPUID_mmx       8388608         // 2^23 (bit 23)
#define CPUID_3dnow	2147483648      // 2^31 (bit 31)
#define CPUID_3dnow_p   1073741824      // 2^30 (bit 30)

  IFMBIT (id, CPUID_esd)
    hasESD= true;

  IFMBIT (id, CPUID_mmx)
    hasMMX= true;

  IFMBIT (id, CPUID_3dnow)
    has3DNow= true;

  IFMBIT (id, CPUID_3dnow_p)
    has3DNow_plus= true;
  
END ("Felix Kollmann");
}