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

  1. /*     $Archive: /General Utilities/CPUID/extstr.cpp $
  2.     $Author : $
  3.     $Date   : $
  4.     $Header : $
  5.     $History: extstr.cpp $
  6.  * 
  7.  * *****************  Version 5  *****************
  8.  * User: Tanb         Date: 7/18/96    Time: 5:00p
  9.  * Updated in $/General Utilities/CPUID
  10.  * Minor changed in display
  11.  */
  12.  
  13.  
  14. #include "defines.h"
  15. #include <iostream.h>
  16. #include <iomanip.h>
  17. #include <conio.h>
  18.  
  19. //ext_cpu_name_str() displays the processor names string up to 48 characters.
  20. //The processor names string is the name of the AMD processor.
  21.  
  22. void cpuid :: ext_cpu_name_str(void)
  23. {
  24.  unsigned long reg_eax, reg_ebx, reg_ecx, reg_edx;    //Register variables
  25.  char idstr[48];             //Processor name string variable
  26.  int func;                   //Case statement variable
  27.  int maxfunc = 2;            //Control loop variable
  28.  
  29.  clrscr();
  30.  cout << "Function 8000_0002, 8000_0003, 8000_0004 (EAX = 80000002/3/4)" << endl;
  31.  cout << "=============================================================";
  32.  cout << "\n\n";
  33.  for (func = 0; func <= maxfunc; func++){
  34.     switch (func){
  35.  
  36.       case 0 :  cout << "          Input: EAX = 80000002 " << endl;
  37.                     cout << "              EAX = ";
  38.                     cout.setf(ios::uppercase);
  39.  
  40.                     asm mov eax, 0x80000002          //EAX=80000002
  41.                     asm db 0x0F, 0xA2         //CPUID opcode
  42.                     reg_eax = _EAX;           //store the processor name string
  43.                     reg_ebx = _EBX;
  44.                     reg_edx = _EDX;
  45.                     reg_ecx = _ECX;
  46.                     cout << setw(8) << hex << reg_eax << endl;
  47.                     cout << "              EBX = " << setw(8) << hex
  48.                           << reg_ebx << endl; 
  49.                     cout << "              ECX = "
  50.                           << setw(8) << hex << reg_ecx << endl;             
  51.                     cout << "              EDX = " << setw(8) << hex
  52.                           << reg_edx << endl;
  53.  
  54.                      _EAX = reg_eax;
  55.                      _EBX = reg_ebx;
  56.                      _ECX = reg_ecx;
  57.                      _EDX = reg_edx;
  58.  
  59.                     //get the first 12 characters of the processor name string
  60.                     idstr[0] = _AL;
  61.                     idstr[1] = _AH;
  62.                     asm  ror eax,0x10  
  63.                     idstr[2] = _AL;
  64.                     idstr[3] = _AH;
  65.                     idstr[4] = _BL;
  66.                     idstr[5] = _BH;
  67.                     asm ror ebx,0x10
  68.                     idstr[6] = _BL;
  69.                     idstr[7] = _BH;
  70.                     idstr[8] = _CL;
  71.                     idstr[9] = _CH;
  72.                     asm ror  ecx,0x10
  73.                     idstr[10] = _CL;
  74.                     idstr[11] = _CH;
  75.                     idstr[12] = _DL;
  76.                     idstr[13] = _DH;
  77.                     asm ror edx, 0x10;
  78.                     idstr[14] = _DL;
  79.                     idstr[15] = _DH;
  80.                     //idstr[16] = '\0';
  81.                     break;
  82.       case 1 :  cout << "          Input: EAX = 80000003 " << endl;
  83.                     cout << "              EAX = ";
  84.  
  85.                     asm mov eax, 0x80000003    //EAX = 8000_0003
  86.                     asm db 0x0F, 0xA2          //CPUID opcode
  87.                     reg_eax = _EAX;
  88.                     reg_ebx = _EBX;
  89.                     reg_edx = _EDX;
  90.                     reg_ecx = _ECX;
  91.                     cout << setw(8) << hex << reg_eax << endl
  92.                           << "              EBX = " << setw(8) << hex
  93.                           << reg_ebx << endl << "              ECX = "
  94.                           << setw(8) << hex << reg_ecx << endl
  95.                           << "              EDX = " << setw(8) << hex
  96.                           << reg_edx << endl;
  97.  
  98.                      _EAX = reg_eax;
  99.                      _EBX = reg_ebx;
  100.                      _ECX = reg_ecx;
  101.                      _EDX = reg_edx;
  102.                     //get the second 12 characters of the processor name string
  103.                     idstr[16] = _AL;
  104.                     idstr[17] = _AH;
  105.                     asm  ror eax,0x10
  106.                     idstr[18] = _AL;
  107.                     idstr[19] = _AH;
  108.                     idstr[20] = _BL;
  109.                     idstr[21] = _BH;
  110.                     asm ror ebx,0x10
  111.                     idstr[22] = _BL;
  112.                     idstr[23] = _BH;
  113.                     idstr[24] = _CL;
  114.                     idstr[25] = _CH;
  115.                     asm ror  ecx,0x10
  116.                     idstr[26] = _CL;
  117.                     idstr[27] = _CH;
  118.                     idstr[28] = _DL;
  119.                     idstr[29] = _DH;
  120.                     asm ror edx, 0x10;
  121.                     idstr[30] = _DL;
  122.                     idstr[31] = _DH;
  123.                     break;
  124.       case 2 :  cout << "          Input: EAX = 80000004 " << endl;
  125.                     cout << "              EAX = ";
  126.  
  127.                     asm mov eax, 0x80000004      //EAX = 8000_00004
  128.                     asm db 0x0F, 0xA2            //CPUID opcode
  129.                     reg_eax = _EAX;
  130.                     reg_ebx = _EBX;
  131.                     reg_edx = _EDX;
  132.                     reg_ecx = _ECX;
  133.                     cout << setw(8) << hex << reg_eax << endl
  134.                           << "              EBX = " << setw(8) << hex
  135.                           << reg_ebx << endl << "              ECX = "
  136.                           << setw(8) << hex << reg_ecx << endl
  137.                           << "              EDX = " << setw(8) << hex
  138.                           << reg_edx << endl;
  139.                      cout.unsetf(ios::uppercase);
  140.  
  141.                      _EAX = reg_eax;
  142.                      _EBX = reg_ebx;
  143.                      _ECX = reg_ecx;
  144.                      _EDX = reg_edx;
  145.                     //get the less of the processor name string
  146.                     idstr[32] = _AL;
  147.                     idstr[33] = _AH;
  148.                     asm  ror eax,0x10
  149.                     idstr[34] = _AL;
  150.                     idstr[35] = _AH;
  151.                     idstr[36] = _BL;
  152.                     idstr[37] = _BH;
  153.                     asm ror ebx,0x10
  154.                     idstr[38] = _BL;
  155.                     idstr[39] = _BH;
  156.                     idstr[40] = _CL;
  157.                     idstr[41] = _CH;
  158.                     asm ror  ecx,0x10
  159.                     idstr[42] = _CL;
  160.                     idstr[43] = _CH;
  161.                     idstr[44] = _DL;
  162.                     idstr[45] = _DH;
  163.                     asm ror edx, 0x10;
  164.                     idstr[46] = _DL;
  165.                     idstr[47] = _DH;
  166.                     idstr[48] = '\0';
  167.                     break;
  168.     }
  169.  } 
  170.  cout << "\n   Processor Name String : " << idstr;
  171.  cout << "\n\n          Press any key for more."<<"\n\n";
  172.  getch();
  173.  
  174. }
  175.