cpu type over 486 & speed

Question about which tools to use, bugs, the best way to implement a function, etc should go here. Don't forget to see if your question is answered in the wiki first! When in doubt post here.
Post Reply
udarkman

cpu type over 486 & speed

Post by udarkman »

Is there a way to find the cpu type over 80486. All the algorithms I found checks cpu type up to 486 and then gives the cpuid result. how can I find type of Cpu, such as Pentium II, Pentium III, Celeron, AMD..??

And as a second question, how can I measure the speed of CPU??

Thanks for any help, example, advice or web addr... :)
Even for good google search keys except: cpu,type,speed:))
slacker

Re:cpu type over 486 & speed

Post by slacker »

look at cpuid in intel manual
udarkman

Re:cpu type over 486 & speed

Post by udarkman »

slacker wrote: look at cpuid in intel manual
I wonder if intel manual includes AMD specific information. But as I learnt, some AMD processors supports CPUID instruction.

And what about speed?how would you measure the speed of CPU?
gtsphere

Re:cpu type over 486 & speed

Post by gtsphere »

i doubt Intel would carry such knowledge of AMD. try amd's website.
-GT
User avatar
Pype.Clicker
Member
Member
Posts: 5964
Joined: Wed Oct 18, 2006 2:31 am
Location: In a galaxy, far, far away
Contact:

Re:cpu type over 486 & speed

Post by Pype.Clicker »

the CPUID instruction is generic. It will help you defining the CPU manufacturer (as it's returned in texto by the processor whether it's GenuineIntel or AuthenticAMD :) ) and various misc. info like does it support MMX, SSE, PGE, etc.

Now, if you have 486 only, CPUID will raise a InvalidOpcode exception, because it's an instruction that has been introduced on the Pentium only. (i.e. supported on all Pentium compatible processors, including AMD K6 and K7 family)

To determine your processor speed, the best way is to combine the use of a timer interrupt and the use of RDTSC instruction (also pentium-specific) or a counting loop that consumes a well-known amount of CPU cycles.

You should find more infos about this in this thread and in this other one
Tim

Re:cpu type over 486 & speed

Post by Tim »

Later 486 chips do support CPUID, so check the ID bit in EFLAGS (was it EFLAGS? or was it some other register? -- check in Intel manual).

CPUID can also give you the CPU speed in MHz. Alternatively, there was a thread in alt.os.development recently about Pype.Clicker's way of doing it.
User avatar
Pype.Clicker
Member
Member
Posts: 5964
Joined: Wed Oct 18, 2006 2:31 am
Location: In a galaxy, far, far away
Contact:

Re:cpu type over 486 & speed

Post by Pype.Clicker »

i gave a quick look at http://grafi.ii.pw.edu.pl/gbm/x86/cpuid ... tidroutine , but i don't see any information about speed. Other documents give a table of stepping information and the speed of the processor, but just relying on that table cannot take into account over/underclocked processors.

Or is it something i'm just missing ?
User avatar
Pype.Clicker
Member
Member
Posts: 5964
Joined: Wed Oct 18, 2006 2:31 am
Location: In a galaxy, far, far away
Contact:

Re:cpu type over 486 & speed

Post by Pype.Clicker »

Tim Robinson wrote: Later 486 chips do support CPUID, so check the ID bit in EFLAGS (was it EFLAGS? or was it some other register? -- check in Intel manual).
from the above link:

Checking for CPUID support

This is quite easy. Try to change the value of CPUID bit (bit 21) in EFLAGS. If the bit can be toggled, CPUID is supported and shall be used for precise identification. On Cyrix chips the bit cannot be toggled if not explicitly allowed - please use this link ....(not ready yet)
udarkman

Re:cpu type over 486 & speed

Post by udarkman »

Pype.Clicker wrote: a counting loop that consumes a well-known amount of CPU cycles.
Is there a common-loop-pattern? I may use RDTSC but I dont want the procedure to be pentium specific..
udarkman

Re:cpu type over 486 & speed

Post by udarkman »

For instance, you have IRQ0@1KHz, and some code looking like
here:
inc [counter]
cmp [done],1
jne here
cpu_speed = [counter] * $x

using $x cpu cycles for each loop.
Is it possible to calculate the total cycle to execute this loop once? I think the total cycle is not the sum of each instructions execute cycles, due to the pipeline. Arent I right?
Tim

Re:cpu type over 486 & speed

Post by Tim »

On any CPU that doesn't have RDTSC, you can count instruction cycles. On more modern pipelined CPUs you have to rely on RDTSC to count cycles.
Post Reply