Visit our Sponsor   Visit our Sponsor
delphi3000.com - the free delphi knowledge platform
delphi3000.com - the free delphi knowledge platform
488 Users Online NOW
Have a look at your member-status

connecting people's knowledge


  - Recent ArticlesRSS feed for Recent Articles on delphi3000.com
  - List of All Articles
  - Top Viewed Articles
  - Articles (+Attachem.)
  - Articles Of Interest
  - Categories
  - Top Uploader
  - Search
  - Index

  - My Home
  - Submit an Article
  - My Articles
  - My Personal Data
  - My Bookmarks
  - Activities
  - Login/Logout

  - Sign Up
  - Why Sign Up
  - Newsletter

  - Press
  - Advertise

  - Contact
  - Feedback





Community
Borland
ClubeDelphi
Dr. Bob
UK-BUG
Delphi Meetings
Planeta Delphi



Loremo - the 1.5 liter car coming in 2009




Startblatt.de






Share this article with friendsShare this article with friends
Rate this articleRate this article - to keep the quality of delphi3000.com !
Comment this article or read through previous comments (2)


Is my CPU branded?Format this article printer-friendly!Bookmark function is only available for registered users!
How to use the extended CPUID instruction.
Product:
Delphi 2.x
Category:
System
Skill Level:
Scoring:
Last Update:
09/11/2001
Search Keys:
delphi delphi3000 article borland vcl code-snippet CPUID Pentium Athlon Intel AMD Duron Brand-String
Times Scored:
5
Visits:
3549
Uploader: Flurin Honegger
Company:
Reference: N/A
 
Question/Problem/Abstract:
Recent Intel and AMD processors have an extend CPUID function call, that returns the name of the processor. In earlier cpu models you had to use the version and feature information function of CPUID to look up names in a string list of your own.

The function GetBrandString shows how to access the brand tring, provided the CPUID instuction is available.
Answer:



function GetBrandString:string;
{Newer AMD (K5 Model 1/2/3,K6 Model 6/7, K6 -2 Model 8, K6-III Model 9,
   all Athlon and Duron) and Intel (Pentium IV) support a Processor Name String
   that is a 0 byte terminated string that can be a up to 47 characters long
   (terminating 0 byte excluded) terminating.
}  

function CPUIDAvail:boolean;assembler;
{Thests wheter the CPUID instruction is available}
asm
  pushfd             // get flags into ax
  pop   eax          // save a copy on the stack
  mov   edx,eax
  xor   eax, 0200000h    // flip bit 21
  push  eax          // load new value into flags
  popfd              // get them back
  pushfd
  pop   eax
  xor   eax,edx
  and   eax, 0200000h    // clear all but bit 21
  shr   eax, 21
end;
  
const
  CPUID=$a20f;
var
  s:array[0..48] of char;
begin
  fillchar(s,sizeof(s),0);
  if CPUIDAvail then begin
    asm
  //save regs  
       push ebx
       push ecx
       push edx
  //check if necessary extended CPUID calls are supported, if not return null string
       mov  eax,080000000h
       dw   CPUID
       cmp  eax,080000004h
       jb   @@endbrandstr
  //get first name part    
       mov  eax,080000002h
       dw   CPUID
       mov  longword(s[0]),eax
       mov  longword(s[4]),ebx
       mov  longword(s[8]),ecx
       mov  longword(s[12]),edx
  //get second name part    
       mov  eax,080000003h
       dw   CPUID
       mov  longword(s[16]),eax
       mov  longword(s[20]),ebx
       mov  longword(s[24]),ecx
       mov  longword(s[28]),edx
  //get third name part    
       mov  eax,080000004h
       dw   CPUID
       mov  longword(s[32]),eax
       mov  longword(s[36]),ebx
       mov  longword(s[40]),ecx
       mov  longword(s[44]),edx
  @@endbrandstr:    
  //restore regs
       pop  edx
       pop  ecx
       pop  ebx
     end;
   end;  
   result:=StrPas(s);
end;





Please rate this article!
Skill level:
BeginnerExpert

Useful:
No!Very!

Overall rating:
PoorExcellent



Comments to this article
Write a new comment
Compile error
    Adam Stewart (Mar 1 2002 12:15PM)

i put this function in to d6, and it starts to complain at the line dw CPUID, and the compile error is inline assembler syntax error - there are seven of these erorrs in total
Respond

RE: Compile error
anonymus (Mar 1 2002 2:41PM)

I have not d6. So I can only make a suggestion.

Replace the offending lines with
    db     0fh, 0a2h         // CPUID opcode

Good look

Flurin

Respond














 
Sign up to consume product discounts for Bronze memberships !

read more


  Visit our Sponsor

 

  Community Ad of
R. Lefter
 
   














 







     
  Copyright © 2000 - 2007 delphi3000.com - All rights reserved. Terms of use. || Privacy
delphi3000.com is a service by bluestep.com IT-Services GmbH (Vienna)