home *** CD-ROM | disk | FTP | other *** search
- /* $Archive: /General Utilities/CPUID/cpuidstr.cpp $
- $Author : $
- $Date : $
- $Header : $
- $History: cpuidstr.cpp $
- *
- * ***************** Version 6 *****************
- * User: Tanb Date: 7/18/96 Time: 4:55p
- * Updated in $/General Utilities/CPUID
- * Make the display look better
- */
-
-
- #include "DEFINES.H"
- #include <iomanip.h>
- #include <iostream.h>
- #include <conio.h>
- #include <stdlib.h>
- #include <string.h>
-
- //Vendor_id_str() finds the largest function value recognized by
- //AMD processors. It also to identify AMD as the vendor for the CPU
- //by returning "AuthenticAMD" in idstr. If another vendor's identification
- //is return the program aborts.
-
- void cpuid::std_vendor_id_str()
- {
- char idstr[13]; // Vendor string variable
- int largest_func = 0; //Largest function variable
- unsigned long reg_eax, //Register variables
- reg_ebx,
- reg_ecx,
- reg_edx;
-
-
- asm {
- mov eax,0x0 //EAX = 0
- db 0x0F,0xA2 //CPUID opcode
- }
- reg_eax = _EAX; //Store the vendor indentification string
- reg_ebx = _EBX;
- reg_edx = _EDX;
- reg_ecx = _ECX;
-
- largest_func = _EAX; //The largest function value
-
- idstr[0] = _BL; //Get the 12 character ASCII string
- idstr[1] = _BH; //that identifies AMD as the vendor
- asm { //of the CPU.
- ror ebx,0x10
- }
- idstr[2] = _BL;
- idstr[3] = _BH;
- idstr[4] = _DL;
- idstr[5] = _DH;
- asm {
- ror edx,0x10
- }
- idstr[6] = _DL;
- idstr[7] = _DH;
- idstr[8] = _CL;
- idstr[9] = _CH;
- asm {
- ror ecx,0x10
- }
- idstr[10] = _CL;
- idstr[11] = _CH;
- idstr[12] = '\0';
- cout.setf(ios::uppercase);
- cout << "\nFunction 0 (EAX = 0)" << endl;
- cout << "===================";
- cout << "\n\n";
-
- cout << "EAX == " <<setw(8)<< setfill('0') << hex << reg_eax;
- cout << " EBX == " << setw(8) << hex << reg_ebx;
- cout << " EDX == " << setw(8) << hex << reg_edx;
- cout << " ECX == " << setw(8) << hex << reg_ecx;
- cout << "\n\n";
- cout << " Largest Function Input Value : " << largest_func;
-
- cout << "\n\n";
- cout << " Vendor Identification String : " << idstr;
- cout.unsetf(ios::uppercase);
- if ( strcmp(idstr, "AuthenticAMD") != 0 ) //If is not AMD then abort
- {
- cout <<"\n\n\n\n";
- cout <<" This is not an AMD-K86 processor." << "\n\n";
- exit(1);
- }
- cout<< "\n\n\n Press any key for more." << "\n\n";
- getch();
-
- }
-