Detecting CPU Speed: Difference between revisions

m
[unchecked revision][unchecked revision]
m (→‎General Method: And Again)
Line 105:
* it's assumed that the command CPUID is supported.
 
<source lang = "asm">
<pre>
;__get_speed__:
;first do a cpuid command, with eax=1
Line 140:
; ax contains measured speed in MHz
mov ~[mhz], ax
</presource>
 
See the intel manual (see links) for more information.
Line 149:
I'd be tempted to say 'yes', though I haven't gave it a test nor heard of it elsewhere so far. Here is the trick:
 
<source lang="C">
<pre>
disable() // disable interrupts (if still not done)
outb(0x43,0x34); // set PIT channel 0 to single-shot mode
Line 160:
byte lo=inb(0x40);
byte hi=inb(0x40);
</presource>
 
Now, we know that
Anonymous user