🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: borland.public.cppbuilder.nativeapi
Article #12860

Re: AMD cpu not recognized..Why ??

#12860
From: Colin Maharaj
Date: Mon, 17 Nov 2003 01:26
149 lines
6089 bytes
Try this, not terribly up-to-date but detects my AMD!!
Call CPUID(); and print value of CPUName string;

//---------------------------------------------------------------------------

char CPUName[128];

//---------------------------------------------------------------------------
void __fastcall EmiTSysInfoId(void)
{
   __emit__(0x0F, 0xa2);
}

//---------------------------------------------------------------------------

void CPUID()
{
  unsigned int x;
  BYTE vendor_id[12]="------------";
  // 0: CPU Vendor CPUName Stamp
  __asm mov eax, 0
  EmiTSysInfoId();
  __asm
  {
  	mov    dword ptr vendor_id, ebx
   	mov    dword ptr vendor_id[+4], edx
   	mov    dword ptr vendor_id[+8], ecx
  }
  char s[14];

  strncpy (s, (char*)vendor_id , 12);
  s[12]=NULL;
  strcpy(VendorString, s);

  // 1: CPU Family Model Stepping
  __asm mov eax, 1
  EmiTSysInfoId();
  __asm
  {
    mov    dword ptr x, eax;
  }
  Family   = (x & 0x00000F00) >> 4*2;
  Model    = (x & 0x000000F0) >> 4*1;
  Stepping = (x & 0x0000000F);

  if (strcmp(VendorString, "AuthenticAMD")==0)
  {
    strcpy(CPUName, "AMD ");
    AnsiString A = (AnsiString) "AMD - Fam:" + IntToStr(Family) + " 
Model:" + IntToStr(Model) + " Stepping:" + IntToStr(Stepping);
    switch (Family)
    {
      case 5 : if (Model < 4) strcat(CPUName, "K5 ");
               else           strcat(CPUName, "K6 ");
               switch (Model)
               {
                 case 0: strcat   (CPUName, "Model 0 "); break;
                 case 1: strcat   (CPUName, "Model 1 "); break;
                 case 2: strcat   (CPUName, "Model 2 "); break;
                 case 3: strcat   (CPUName, "Model 3 "); break;
                 case 6: strcat   (CPUName, "Model 6 "); break;
                 case 7: strcat   (CPUName, "Model 7 "); break;
                 case 8: strcat   (CPUName, "-2 Model 8 "); break;
                 case 9: strcat   (CPUName, "-3 Model 9 "); break;
                 case 0xd: strcat (CPUName, "-2+, or III+ "); break;
               }
               break;


      case 6 : strcat(CPUName, "(K7) ");
               switch (Model)
               {
                 case 1:
                 case 2: strcat (CPUName, "Athlon W/Ext L2-Cache");
break;
                 case 3: strcat (CPUName, "Duron "); break;
                 case 4: strcat (CPUName, "Athlon W/Int L2-Cache");
break;
               }
               break;

     default : strcpy(CPUName, A.c_str()); break;

    }
  }

  if (strcmp(VendorString, "GenuineIntel")==0)
  {
    strcpy(CPUName, "Intel ");
    AnsiString A = (AnsiString) "Intel - Fam:" + IntToStr(Family) + " 
Model:" + IntToStr(Model) + " Stepping:" + IntToStr(Stepping);
    switch (Family)
    {
      case 4 : strcat(CPUName, "486-");
               switch (Model)
               {
                 case 0 :
                 case 1 : strcat(CPUName, "DX "); break;
                 case 2 : strcat(CPUName, "SX "); break;
                 case 3 : strcat(CPUName, "DX2 "); break;
                 case 4 : strcat(CPUName, "SL "); break;
                 case 5 : strcat(CPUName, "SX2 "); break;
                 case 7 : strcat(CPUName, "DX2 WB "); break;
                 case 8 : strcat(CPUName, "DX4 "); break;
                 case 9 : strcat(CPUName, "DX4 WB "); break;
               }
               break;

      case 5 : strcat(CPUName, "Pentium ");
               switch (Model)
               {
                 case 0 : strcat(CPUName, "first Generation "); break;
                 case 1 : strcat(CPUName, "60/66 5V "); break;
                 case 2 : strcat(CPUName, "P54C "); break;
                 case 3 : strcat(CPUName, "Overdrive for 486 "); break;
                 case 4 : strcat(CPUName, "with MMX "); break;
                 case 5 : strcat(CPUName, "DX4 Overdrive "); break;
                 case 6 : strcat(CPUName, "P5 Overdrive "); break;
                 case 7 : strcat(CPUName, "P54C "); break;
                 case 8 : strcat(CPUName, "w/ MMX low Voltage "); break;
               }
               break;

      case 6 : strcat(CPUName, "Pentium ");
               switch (Model)
               {
                 case 0   : strcat(CPUName, "Pro "); break;
                 case 1   : strcat(CPUName, "Pro "); break;
                 case 3   : strcat(CPUName, "II Kalmath "); break;
                 case 4   : strcat(CPUName, "P55CT "); break;
                 case 5   : strcat(CPUName, "II Deschutes"); break;
                 case 6   : strcat(CPUName, "Celeron A "); break;
                 case 7   : strcat(CPUName, "III Katmai "); break;
                 case 8   : strcat(CPUName, "III CopperMine Celeron
w/SSE "); break;
                 case 0xa : strcat(CPUName, "III Xeon "); break;
                 case 0xf : strcat(CPUName, "IV Willamette family");
break;
               }
               break;


      default : strcpy(CPUName, A.c_str()); break;

      }
  }
}

//---------------------------------------------------------------------------
Technical Details
Message-ID: <3FB823DA.4B2FDE7C@cablenett.net>
Path: arc1-ca.pugleaf.net!archiver1.google.com!news2.google.com!news.maxwell.syr.edu!newsfeed00.sul.t-online.de!newsfeed01.sul.t-online.de!t-online.de!newsgroups.borland.com!not-for-mail
References: <3fb7ed02@newsgroups.borland.com>

Show Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit
X-Google-Thread: 10cc67,5c5f838658412107
X-Google-Attributes: gid10cc67,public
X-Google-ArrivalTime: 2003-11-16 17:39:16 PST
Message-ID: <3FB823DA.4B2FDE7C@cablenett.net>
Date: Sun, 16 Nov 2003 21:26:50 -0400
From: Colin Maharaj <cbm@cablenett.net>
Reply-To: cbm@cablenett.net
X-Mailer: Mozilla 4.78 [en] (Windows NT 5.0; U)
X-Accept-Language: en
MIME-Version: 1.0
Newsgroups: borland.public.cppbuilder.nativeapi
Subject: Re: AMD cpu not recognized..Why ??
References: <3fb7ed02@newsgroups.borland.com>
Content-Type: text/plain; charset=us-ascii
Content-Transfer-Encoding: 7bit
NNTP-Posting-Host: 196.32.37.92
X-Trace: newsgroups.borland.com 1069032406 196.32.37.92 (16 Nov 2003 17:26:46 -0700)
Lines: 149
Path: arc1-ca.pugleaf.net!archiver1.google.com!news2.google.com!news.maxwell.syr.edu!newsfeed00.sul.t-online.de!newsfeed01.sul.t-online.de!t-online.de!newsgroups.borland.com!not-for-mail