Detecting CPU speed !
Posted: Wed Jul 04, 2007 10:11 am
Hello (again),
I've found a code that works in Windows, that will detect the CPU speed in megahertz. So I converted it a little
(CPUSpeed, TLow, THigh are doubleword data types)
It's expected to work (this worked in Windows) and I've executed this at the protected-mode part of my OS, where the timer is reprogrammed. But my conversion was false, on the real machine it throwd something about 459XXX, wow, 459000 MHz CPU?
So, do you have any idea to fix this code [again]? You know, I would be *very* grateful
Regards,
inflater
I've found a code that works in Windows, that will detect the CPU speed in megahertz. So I converted it a little
Code: Select all
dw 310Fh ;dw 310Fh = rdtsc
mov dword [TLow], eax
mov dword [THigh], edx
mov ax,9 ;This will set up about a
call SetTimer ;500 ms delay (that will halt the
dw 310Fh ;execution until its completed)
sub eax, dword [TLow]
sub edx, dword [THigh]
mov dword [TLow], eax
mov dword [THigh], edx
mov eax,dword [TLow / 500000d]
mov dword[CPUSpeed],eax
It's expected to work (this worked in Windows) and I've executed this at the protected-mode part of my OS, where the timer is reprogrammed. But my conversion was false, on the real machine it throwd something about 459XXX, wow, 459000 MHz CPU?
So, do you have any idea to fix this code [again]? You know, I would be *very* grateful
Regards,
inflater