The MASM Forum

General => The Campus => Topic started by: Rusica on April 29, 2014, 10:45:38 PM

Title: Read CPU Temperature
Post by: Rusica on April 29, 2014, 10:45:38 PM
Hi,
I have a project to do where I must display the CPU temperature. How should I do this?
Here I have a window wich has a timer and I need to display the CPU temperature too.
Thanks
Title: Re: Read CPU Temperature
Post by: Gunther on April 30, 2014, 03:12:08 AM
Hi Rusica,

first things first: welcome to the forum.

To your question. That's a bit tricky. You have to check the temperature feature with the CPUID instruction. Set EAX = 1 and check the bit 22 of register EDX. Details could you find here (http://www.alterbit.ru/files/11.pdf).

Gunther
Title: Re: Read CPU Temperature
Post by: Rusica on April 30, 2014, 03:31:08 AM
Thanks, but it's a bit harder for me, because I didn't work with masm before. I am a "rookie", but I want to learn.
Title: Re: Read CPU Temperature
Post by: Gunther on April 30, 2014, 04:09:55 AM
Hi Rusica,

Quote from: Rusica on April 30, 2014, 03:31:08 AM
Thanks, but it's a bit harder for me, because I didn't work with masm before. I am a "rookie", but I want to learn.

the best thing you can do is to download the MASM32 package (download link in the upper right corner of the forum home page). It has a lot of examples and tutorials.

Gunther
Title: Re: Read CPU Temperature
Post by: Gunther on April 30, 2014, 04:27:34 AM
A few other hints. There you'll find ADVANCED CONFIGURATION AND POWER INTERFACE SPECIFICATION (ACPI) specification (http://www.acpi.info/DOWNLOADS/ACPIspec50pdf.zip). It has over 900 pages and is a playground for the "overclocker". The next article describes the access of the driver ACPI.sys (http://msdn.microsoft.com/en-us/library/windows/hardware/Dn614028%28v=vs.85%29.aspx). Good luck.

Gunther 
Title: Re: Read CPU Temperature
Post by: Adamanteus on April 30, 2014, 04:32:15 AM
 Using thermal monitor is privileged instruction, so fully relies on OS and returning to applications  with help of WMI (http://theroadtodelphi.wordpress.com/wmi-delphi-code-creator), but seems that this not fully supported on client OSes, so best way is simple not to overload CPU usage, as I already recommended in BitBlt And CPU 100% (http://masm32.com/board/index.php?topic=3137.30) thread.
Title: Re: Read CPU Temperature
Post by: Rusica on April 30, 2014, 04:33:01 AM
Thank you! I'll do that.
For the moment, can anyone help me with my homework, because ai did all I can do for now, and I need to do it imediately? :D
Title: Re: Read CPU Temperature
Post by: gelatine1 on April 30, 2014, 04:56:01 AM
This is not a homework site unfortunately maybe google can offer you the help you need.
Title: Re: Read CPU Temperature
Post by: dedndave on April 30, 2014, 05:09:21 AM
it's a tough assignment
some CPU's don't support tempurature
also - if you are running XP or earlier, you can use a driver
Vista and later have WHQL issues
Title: Re: Read CPU Temperature
Post by: Rusica on April 30, 2014, 05:22:26 AM
 CPU percentage is more easier to display in that window?
Title: Re: Read CPU Temperature
Post by: KeepingRealBusy on April 30, 2014, 06:28:02 AM
Rusica,

If you are running Windows, and all you want is CPU percentage, then use the Task Manager, Performance Tab.  But, that does not fulfill the homework task.

Dave.
Title: Re: Read CPU Temperature
Post by: GoneFishing on April 30, 2014, 07:24:35 AM
Getting LoadPercentage from WMI is really simple and straitforward ( unlike CPU temperature ,read the last post in this thread (http://social.msdn.microsoft.com/Forums/en-US/18ce0701-e87d-4414-a8b5-8be3908a21b8/reading-cpu-temperature-wmi?forum=vblanguage) if you want to know why)
Quote
; ¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤
    include \masm32\include\masm32rt.inc
; ¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤

comment * -----------------------------------------------------
                        Build this  template with
                       "CONSOLE ASSEMBLE AND LINK"
        ----------------------------------------------------- *

   
    .code

start:
   
; ¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤

    call main
 
    exit

; ¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤

main proc

    invoke WinExec,chr$("wmic cpu get LoadPercentage /format:list /every:1 "),0 ; updates every second
 
    ret

main endp

; ¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤

end start
Press CTRL-C (or any key when prompted) to terminate it
Title: Re: Read CPU Temperature
Post by: Gunther on May 01, 2014, 02:49:16 AM
Hi Rusica,

Quote from: Rusica on April 30, 2014, 04:33:01 AM
For the moment, can anyone help me with my homework, because ai did all I can do for now, and I need to do it imediately? :D

it's very simple: we've a NO HOMEWORK Rule, which you can find here (rule #9) (http://masm32.com/board/index.php?topic=4.0). But we can help finding errors and weaknesses in code which you provide.

Gunther
Title: Re: Read CPU Temperature
Post by: dedndave on May 01, 2014, 03:03:40 AM
we don't mind helping
but, we won't do all the work for you
a common misconception is that an urgency on your part creates an emergency on ours   :lol:
not our fault if you wait til it's due to ask for help
Title: Re: Read CPU Temperature
Post by: Magnum on May 01, 2014, 02:36:04 PM
Super Dave,

I feel that displaying the CPU temp is a harder project than writing an O.S. :-)

It is not a homework assignment unless the Professor is cruel. :-)

No offense intended to Gunther. :-)

Andy
Title: Re: Read CPU Temperature
Post by: dedndave on May 02, 2014, 12:31:26 AM
it is a cruel assignment - lol
especially if you want one that runs on XP, Vista, Win7, and Win8