home *** CD-ROM | disk | FTP | other *** search
/ PC Welt 1998 April / Freeware-CD.bin / cputst / amd_cpu / amd!.EXE / CPUIDSTR.CPP < prev    next >
Encoding:
C/C++ Source or Header  |  1996-12-19  |  2.5 KB  |  94 lines

  1. /*     $Archive: /General Utilities/CPUID/cpuidstr.cpp $
  2.     $Author : $
  3.     $Date   : $
  4.     $Header : $
  5.     $History: cpuidstr.cpp $
  6.  * 
  7.  * *****************  Version 6  *****************
  8.  * User: Tanb         Date: 7/18/96    Time: 4:55p
  9.  * Updated in $/General Utilities/CPUID
  10.  * Make the display look better
  11.  */
  12.  
  13.  
  14. #include "DEFINES.H"
  15. #include <iomanip.h>
  16. #include <iostream.h>
  17. #include <conio.h>
  18. #include <stdlib.h>
  19. #include <string.h>
  20.  
  21. //Vendor_id_str() finds the largest function value recognized by
  22. //AMD processors. It also to identify AMD as the vendor for the CPU
  23. //by returning "AuthenticAMD" in idstr. If another vendor's identification 
  24. //is return the program aborts.
  25.  
  26. void cpuid::std_vendor_id_str()
  27. {
  28.   char idstr[13];             // Vendor string variable
  29.   int largest_func = 0;       //Largest function variable
  30.   unsigned long reg_eax,      //Register variables
  31.                      reg_ebx,
  32.                      reg_ecx,
  33.                      reg_edx;
  34.  
  35.  
  36.   asm {
  37.           mov    eax,0x0        //EAX = 0
  38.           db     0x0F,0xA2      //CPUID opcode
  39.   }
  40.   reg_eax = _EAX;             //Store the vendor indentification string
  41.   reg_ebx = _EBX;
  42.   reg_edx = _EDX;
  43.   reg_ecx = _ECX;
  44.  
  45.   largest_func = _EAX;       //The largest function value
  46.  
  47.   idstr[0] = _BL;            //Get the 12 character ASCII string
  48.   idstr[1] = _BH;            //that identifies AMD as the vendor
  49.   asm {                      //of the CPU.
  50.           ror ebx,0x10
  51.   }
  52.   idstr[2] = _BL;
  53.   idstr[3] = _BH;
  54.   idstr[4] = _DL;
  55.   idstr[5] = _DH;
  56.   asm {
  57.          ror edx,0x10          
  58.   }
  59.   idstr[6] = _DL;
  60.   idstr[7] = _DH;
  61.   idstr[8] = _CL;
  62.   idstr[9] = _CH;
  63.   asm {
  64.           ror  ecx,0x10
  65.   }
  66.   idstr[10] = _CL;
  67.   idstr[11] = _CH;
  68.   idstr[12] = '\0';
  69.   cout.setf(ios::uppercase);
  70.   cout << "\nFunction 0 (EAX = 0)" << endl;
  71.   cout << "===================";
  72.   cout << "\n\n";
  73.  
  74.   cout << "EAX == " <<setw(8)<< setfill('0') << hex << reg_eax;
  75.   cout << "   EBX == " << setw(8) << hex << reg_ebx;
  76.   cout << "   EDX == " << setw(8) << hex << reg_edx;
  77.   cout << "   ECX == " << setw(8) << hex << reg_ecx;
  78.   cout << "\n\n";
  79.   cout << "     Largest Function Input Value : " << largest_func;
  80.  
  81.   cout << "\n\n";
  82.   cout << "     Vendor Identification String : " << idstr;
  83.   cout.unsetf(ios::uppercase);
  84.   if ( strcmp(idstr, "AuthenticAMD") != 0 )   //If is not AMD then abort
  85.     {
  86.      cout <<"\n\n\n\n";
  87.      cout <<"     This is not an AMD-K86 processor." << "\n\n";
  88.      exit(1);
  89.     }
  90.     cout<< "\n\n\n                Press any key for more." << "\n\n";
  91.     getch();
  92.  
  93. }
  94.