#include "stdafx.h"
#include < stdio.h >
#include < memory.h >
#include < atlstr.h >
#include < conio.h >

// CPU details for Arabteam2000
int getCPUModel()
{ int retVal;
_asm {        mov eax , 1
                cpuid
                mov retVal , eax
         }
return ((retVal > > 4 ) & 0x0000000f);
}
//********** int getCPUStepping()
{
        int retVal;

        _asm {
                mov eax , 1
                cpuid
                mov retVal , eax
        }

        return (retVal & 0x0000000f);
}
//********** int getCPUFamily()
{
        int retVal;

        _asm {
                mov eax , 1
                cpuid
                mov retVal , eax
        }

        return (retVal > > 8);
}
//********* int __stdcall getCPUSpeed()
{
        LARGE_INTEGER ulFreq , ulTicks , ulValue , ulStartCounter , ulEAX_EDX , ulResult;

        // it is number of ticks per seconds         QueryPerformanceFrequency(&ulFreq);

        // current valueofthe performance counter         QueryPerformanceCounter(&ulTicks);

        // calculate one second interval         ulValue.QuadPart = ulTicks.QuadPart + ulFreq.QuadPart;

        // read time stamp counter         // this asm instruction load the highorder 32 bit of the register into EDX         // and the lower order 32 bits into EAX         _asm {
                rdtsc
                mov ulEAX_EDX.LowPart , EAX
                mov ulEAX_EDX.HighPart , EDX
        }

        // start no of ticks         ulStartCounter.QuadPart = ulEAX_EDX.QuadPart;

        // loop for 1 second         do {
                QueryPerformanceCounter(&ulTicks);
        } while (ulTicks.QuadPart < = ulValue.QuadPart);

        // get the actual no of ticks         _asm {
                rdtsc
                mov ulEAX_EDX.LowPart , EAX
                mov ulEAX_EDX.HighPart , EDX
        }
        // calculate result         ulResult.QuadPart = ulEAX_EDX.QuadPart - ulStartCounter.QuadPart;

        return (int)ulResult.QuadPart / 1000000;
}
//********* int _tmain(int argc , _TCHAR* argv[])
{
        //------- CPU Type         static char pszCPUType[13];
         memset(pszCPUType , 0 , 13);

        _asm {
                mov eax , 0
                cpuid

                // getting information from EBX                 mov pszCPUType[0] , bl
                mov pszCPUType[1] , bh

                ror ebx , 16
                mov pszCPUType[2] , bl
                mov pszCPUType[3] , bh

                // getting information from EDX                 mov pszCPUType[4] , dl
                mov pszCPUType[5] , dh

                ror edx , 16
                mov pszCPUType[6] , dl
                mov pszCPUType[7] , dh

                // getting information from ECX                 mov pszCPUType[8] , cl
                mov pszCPUType[9] , ch

                ror ecx , 16
                mov pszCPUType[10] , cl
                mov pszCPUType[11] , ch
        }

        pszCPUType[12] = ' \0 ' ;

//------- main part         printf(" \n\t Assalamou Alaykom\n These are some details about your CPU\n\n");
        printf(" CPU Type:         % s\n" , pszCPUType);
        printf(" CPU Model:         % d\n" , getCPUModel() );
        printf(" CPU Stepping: % d\n" , getCPUStepping());
        printf(" CPU Family:        % d\n" , getCPUFamily());
        printf(" CPU Speed:         % dMHz\n" , getCPUSpeed());
        printf(" \n\t Press any key to exit ...");
        getch();
        return 0;
}


  • Currently 45/5 Stars.
  • 1 2 3 4 5
15 تصويتات / 435 مشاهدة
نشرت فى 20 ديسمبر 2006 بواسطة Badeaonly

ساحة النقاش

عدد زيارات الموقع

75,485