Mail Archives: djgpp/2001/01/17/18:36:47
From: | "Alexei A. Frounze" <dummy_addressee AT hotmail DOT com>
|
Newsgroups: | comp.os.msdos.djgpp
|
Subject: | Re: Reading MSR (Athlon multiplier)
|
Date: | Wed, 17 Jan 2001 18:36:57 -0500
|
Lines: | 110
|
Message-ID: | <945a90$ckgq1$1@ID-57378.news.dfncis.de>
|
References: | <3a66161d DOT 226362160 AT news DOT sci DOT fi>
|
NNTP-Posting-Host: | pppa39-resalerochester3-5r7104.dialinx.net (4.4.209.228)
|
X-Trace: | fu-berlin.de 979774562 13255489 4.4.209.228 (16 [57378])
|
X-Priority: | 3
|
X-MSMail-Priority: | Normal
|
X-Newsreader: | Microsoft Outlook Express 5.50.4133.2400
|
X-MimeOLE: | Produced By Microsoft MimeOLE V5.50.4133.2400
|
To: | djgpp AT delorie DOT com
|
DJ-Gateway: | from newsgroup comp.os.msdos.djgpp
|
Reply-To: | djgpp AT delorie DOT com
|
right, you can use RDTSC for getting CPU speed. But RDTSC can be disabled in
user mode (e.g. Privilege Level 3) by an OS.
for instance, the following code works fine on my Celeron566 imder winME and
gives 564-566MHz:
-------8<------
; cpuspeed.asm
; compile with nasm as follows:
; nasm.exe cpuspeed.asm -o cpuspeed.com
section .text
org 100h
push byte 40h
pop es
mov ch, 17 ; 17 values for average of 16 periods
l1:
call wait_for_tick
rdtsc
push edx
push eax
dec ch
jnz l1
xor cl, cl
xor ebx, ebx ; allocate cl:ebx for the sum
pop eax
pop edx
mov ch, 16
l2:
pop esi
pop edi
sub eax, esi
sbb edx, edi
add ebx, eax
adc cl, dl
mov eax, esi
mov edx, edi
dec ch
jnz l2
mov eax, ebx
movzx edx, cl ; edx:eax = total sum of 16 values
shrd eax, edx, 4 ; eax = average value
mov ebx, 182
mul ebx ; mul by 18.2*10 (18.2 timer ticks per second)
mov ebx, 10000000
div ebx ; div by 1e6*10 to get frequency in MHZ instead of HZ
mov bx, 10
xor ch, ch
l3:
xor dx, dx
div bx
push dx
inc ch
or ax, ax
jnz l3
mov ah, 2
l4:
pop dx
add dl, "0"
int 21h
dec ch
jnz l4
mov ah, 9
mov dx, msg
int 21h
ret
wait_for_tick:
mov ax, [es:6ch]
.1:
cmp ax, [es:6ch]
je .1
ret
msg db " MHz",13,10,"$"
-------8<------
Good Luck
--
Alexei A. Frounze
alexfru [AT] chat [DOT] ru
frounze [AT] ece [DOT] rochester [DOT] edu
http://alexfru.chat.ru
http://members.xoom.com/alexfru/
http://welcome.to/pmode/
"Lasse Kärkkäinen / Tronic" <tronic2 AT sci DOT fi DOT don'tSPAMmeBUTremoveTHIS> wrote
in message news:3a66161d DOT 226362160 AT news DOT sci DOT fi...
> Hi!
>
> Multiplier of Athlon processor should be readable by MSR 0xC0010015,
> but I can't read it, or any other MSR (and believe it or not I have
> tried to find info on it, NOTHING anywhere). So, how to read one?
>
> Another thing related to this, I need to find out the processor speed.
> This is done with time stamp counter (isn't it?), which is also in
> MSRs, right? Anyway, I'll need to read this one too.
>
> Thanks.
>
> - Tronic -
- Raw text -