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

  1. /*     $Archive: /General Utilities/CPUID/ckcpubit.cpp $
  2.     $Author : $
  3.     $Date   : $
  4.     $Header : $
  5.     $History: ckcpubit.cpp $
  6.  * 
  7.  * *****************  Version 6  *****************
  8.  * User: Tanb         Date: 7/18/96    Time: 4:52p
  9.  * Updated in $/General Utilities/CPUID
  10.  * Make the display look better
  11.  */
  12.  
  13.  
  14. #include "DEFINES.H"
  15.  
  16. // This function checks the processor ID bit (bit 21) in the EFLAGS
  17. // register. The program abort if the processor does not implement the CPUID 
  18. // instruction.
  19.  
  20. int cpuid::chkcpubit(void)
  21. {
  22.   asm {
  23.          .486
  24.          pushfd                          //save EFLAGS
  25.          pop            eax
  26.          test           eax,0x00200000   //check ID bit (bit 21)
  27.          jz             set_21           //bit 21 is not set, so jump to set_21
  28.          and            eax,0xffdfffff  //clear bit 21
  29.          push           eax            //save new value in register
  30.          popfd                         //store new value in flags
  31.          pushfd
  32.          pop            eax
  33.          test           eax,0x00200000 //check ID bit
  34.          jz             cpu_id_ok      //if bit 21 is clear,then jump to cpu_id_ok
  35.          jmp            err            //if bit 21 is set, so CPUID inst is not
  36.         }                              //supporting
  37.         set_21:
  38.         asm {
  39.          or             eax,0x00200000  //set bit 21
  40.          push           eax             //store new value
  41.          popfd                          //store new value in EFLAGS
  42.          pushfd
  43.          pop            eax
  44.          test           eax,0x00200000  //if bit 21 is on
  45.          jnz            cpu_id_ok       //then jump to cpu_id_ok
  46.         }
  47.         err:
  48.         asm {
  49.          mov            eax,0xffffffff  //CPUID inst is not supported
  50.          jmp            exit            // so exit
  51.         }
  52.         cpu_id_ok:                      //Support CPUID inst
  53.         asm  mov  eax,0                 // return 0
  54.  
  55.         exit:
  56.         if(_EAX == 0xffffffff){
  57.             return (-1);
  58.         }
  59.         if (_EAX == 0x0) {
  60.             return (0);
  61.         }
  62. }
  63.