home *** CD-ROM | disk | FTP | other *** search
- /* $Archive: /General Utilities/CPUID/extstr.cpp $
- $Author : $
- $Date : $
- $Header : $
- $History: extstr.cpp $
- *
- * ***************** Version 5 *****************
- * User: Tanb Date: 7/18/96 Time: 5:00p
- * Updated in $/General Utilities/CPUID
- * Minor changed in display
- */
-
-
- #include "defines.h"
- #include <iostream.h>
- #include <iomanip.h>
- #include <conio.h>
-
- //ext_cpu_name_str() displays the processor names string up to 48 characters.
- //The processor names string is the name of the AMD processor.
-
- void cpuid :: ext_cpu_name_str(void)
- {
- unsigned long reg_eax, reg_ebx, reg_ecx, reg_edx; //Register variables
- char idstr[48]; //Processor name string variable
- int func; //Case statement variable
- int maxfunc = 2; //Control loop variable
-
- clrscr();
- cout << "Function 8000_0002, 8000_0003, 8000_0004 (EAX = 80000002/3/4)" << endl;
- cout << "=============================================================";
- cout << "\n\n";
- for (func = 0; func <= maxfunc; func++){
- switch (func){
-
- case 0 : cout << " Input: EAX = 80000002 " << endl;
- cout << " EAX = ";
- cout.setf(ios::uppercase);
-
- asm mov eax, 0x80000002 //EAX=80000002
- asm db 0x0F, 0xA2 //CPUID opcode
- reg_eax = _EAX; //store the processor name string
- reg_ebx = _EBX;
- reg_edx = _EDX;
- reg_ecx = _ECX;
- cout << setw(8) << hex << reg_eax << endl;
- cout << " EBX = " << setw(8) << hex
- << reg_ebx << endl;
- cout << " ECX = "
- << setw(8) << hex << reg_ecx << endl;
- cout << " EDX = " << setw(8) << hex
- << reg_edx << endl;
-
- _EAX = reg_eax;
- _EBX = reg_ebx;
- _ECX = reg_ecx;
- _EDX = reg_edx;
-
- //get the first 12 characters of the processor name string
- idstr[0] = _AL;
- idstr[1] = _AH;
- asm ror eax,0x10
- idstr[2] = _AL;
- idstr[3] = _AH;
- idstr[4] = _BL;
- idstr[5] = _BH;
- asm ror ebx,0x10
- idstr[6] = _BL;
- idstr[7] = _BH;
- idstr[8] = _CL;
- idstr[9] = _CH;
- asm ror ecx,0x10
- idstr[10] = _CL;
- idstr[11] = _CH;
- idstr[12] = _DL;
- idstr[13] = _DH;
- asm ror edx, 0x10;
- idstr[14] = _DL;
- idstr[15] = _DH;
- //idstr[16] = '\0';
- break;
- case 1 : cout << " Input: EAX = 80000003 " << endl;
- cout << " EAX = ";
-
- asm mov eax, 0x80000003 //EAX = 8000_0003
- asm db 0x0F, 0xA2 //CPUID opcode
- reg_eax = _EAX;
- reg_ebx = _EBX;
- reg_edx = _EDX;
- reg_ecx = _ECX;
- cout << setw(8) << hex << reg_eax << endl
- << " EBX = " << setw(8) << hex
- << reg_ebx << endl << " ECX = "
- << setw(8) << hex << reg_ecx << endl
- << " EDX = " << setw(8) << hex
- << reg_edx << endl;
-
- _EAX = reg_eax;
- _EBX = reg_ebx;
- _ECX = reg_ecx;
- _EDX = reg_edx;
- //get the second 12 characters of the processor name string
- idstr[16] = _AL;
- idstr[17] = _AH;
- asm ror eax,0x10
- idstr[18] = _AL;
- idstr[19] = _AH;
- idstr[20] = _BL;
- idstr[21] = _BH;
- asm ror ebx,0x10
- idstr[22] = _BL;
- idstr[23] = _BH;
- idstr[24] = _CL;
- idstr[25] = _CH;
- asm ror ecx,0x10
- idstr[26] = _CL;
- idstr[27] = _CH;
- idstr[28] = _DL;
- idstr[29] = _DH;
- asm ror edx, 0x10;
- idstr[30] = _DL;
- idstr[31] = _DH;
- break;
- case 2 : cout << " Input: EAX = 80000004 " << endl;
- cout << " EAX = ";
-
- asm mov eax, 0x80000004 //EAX = 8000_00004
- asm db 0x0F, 0xA2 //CPUID opcode
- reg_eax = _EAX;
- reg_ebx = _EBX;
- reg_edx = _EDX;
- reg_ecx = _ECX;
- cout << setw(8) << hex << reg_eax << endl
- << " EBX = " << setw(8) << hex
- << reg_ebx << endl << " ECX = "
- << setw(8) << hex << reg_ecx << endl
- << " EDX = " << setw(8) << hex
- << reg_edx << endl;
- cout.unsetf(ios::uppercase);
-
- _EAX = reg_eax;
- _EBX = reg_ebx;
- _ECX = reg_ecx;
- _EDX = reg_edx;
- //get the less of the processor name string
- idstr[32] = _AL;
- idstr[33] = _AH;
- asm ror eax,0x10
- idstr[34] = _AL;
- idstr[35] = _AH;
- idstr[36] = _BL;
- idstr[37] = _BH;
- asm ror ebx,0x10
- idstr[38] = _BL;
- idstr[39] = _BH;
- idstr[40] = _CL;
- idstr[41] = _CH;
- asm ror ecx,0x10
- idstr[42] = _CL;
- idstr[43] = _CH;
- idstr[44] = _DL;
- idstr[45] = _DH;
- asm ror edx, 0x10;
- idstr[46] = _DL;
- idstr[47] = _DH;
- idstr[48] = '\0';
- break;
- }
- }
- cout << "\n Processor Name String : " << idstr;
- cout << "\n\n Press any key for more."<<"\n\n";
- getch();
-
- }
-