Hi Mark,
I don't think we can get the actual clock speed with cpuid. Cpuid will return a "processor name string" (not the same as the "vendor string" returned by cpuid with eax=0), which includes the nominal "maximum supported speed" (I just now learned this - I often get educated trying to "help" you guys!).
Naturally, Intel has a document... in "painful document format" :(
http://www.intel.com/Assets/PDF/appnote/241618.pdfThis includes example programs (for dos, and in Masm syntax) for both the "name string" and for calculating the actual current frequency.
The latter uses the "tick count" in the Bios Data Area to get an "interval" to count over, reading rdtsc before and after (and doing the division in an odd way...). On a less archaic OS, "interval" may actually be more of a problem. Linux, for example, has "sys_nanosleep" which should give us an interval - wait a full second to simplify the arithmetic? - but I think it'll give us a second... plus whenever the scheduler decides to give us the CPU back. Maybe "close enough"? You would use cpuid to make sure that rdtsc exists, after making sure that cpuid exists, if you're being paranoid. (better to be a little too paranoid than not quite paranoid enough!)
I'll append a quick-and-dirty example for "name string". The display is horrible, but it shows the useage of cpuid okay, I guess. Whether this will help you, and how accurate an interval you need if you're going to "count", depends on "why do you want to know?", probably...
Best,
Frank
; nasm -f elf cpuname.asm
; ld -o cpuname cpuname.o
;
; change the display and exit parts for 'doze
global _start
section .bss
namestring resb 48
section .text
_start:
mov eax, 80000000h
cpuid
cmp eax, 80000004h
jb exit ; not supported
mov edi, namestring ; need 48 bytes to store it
mov eax, 80000002h
cpuid
call savestring
mov eax, 80000003h
cpuid
call savestring
mov eax, 80000004h
cpuid
call savestring
; print it
mov ecx, namestring
mov edx, 48
mov ebx, 1 ; stdout
mov eax, 4 ; write
int 80h
exit:
mov eax, 1
int 80h
;----------------
;--------------------
savestring:
stosd
mov eax, ebx
stosd
mov eax, ecx
stosd
mov eax, edx
stosd
ret
;------------------