Detecting CPU Speed: Difference between revisions
[unchecked revision] | [unchecked revision] |
Content deleted Content added
m →Knowing how many cycles your loop takes: Sourceification |
m →General Method: And Again |
||
Line 105:
* it's assumed that the command CPUID is supported.
<source lang = "asm">
;__get_speed__:
;first do a cpuid command, with eax=1
Line 140:
; ax contains measured speed in MHz
mov ~[mhz], ax
</
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">
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);
</
Now, we know that
|