The MASM Forum Archive 2004 to 2012

General Forums => The Workshop => Topic started by: edkedk on August 16, 2006, 10:22:40 AM

Title: How to disable interrupts on win32 with masm32 to use rdtsc instruction
Post by: edkedk on August 16, 2006, 10:22:40 AM
Hi,

I want to check how many cpu-cycles certain routines i have coded consume, but i _must_ disable all interrupts during this moment, otherwise the rdtsc timestamps are not the real amount of cycles from the routine.

Windows does not like it when i use the "cli" instruction, it closes my win32 app.
What is the best option for me ?

ex.


mainloop:
...
...
<disable interrupts ?>

rdtsc
save dx:ax
call routine
rdtsc
sub dx:ax from saved dx:ax
rdtsc

<enable interrupts again?>

jmp mainloop if not keypressed



I hope someone can help me out.

Thanks for your time!


Bye,

Erik de Keijzer

Title: Re: How to disable interrupts on win32 with masm32 to use rdtsc instruction
Post by: Mark Jones on August 16, 2006, 12:41:28 PM
Hello Erik, in Win32 mode, try Michael's timers.asm or Petrozski's timing routines here:

http://www.masm32.com/board/index.php?topic=770.0
Title: Re: How to disable interrupts on win32 with masm32 to use rdtsc instruction
Post by: Ghirai on August 16, 2006, 12:44:50 PM
Or write a kmd?
Title: Re: How to disable interrupts on win32 with masm32 to use rdtsc instruction
Post by: Mark_Larson on August 16, 2006, 03:12:15 PM

  Someone posted a driver on the old forum that did this.  I'll see if I can find the link.

http://www.oldboard.assemblercode.com/index.php?topic=1762.30

Title: Re: How to disable interrupts on win32 with masm32 to use rdtsc instruction
Post by: dioxin on August 17, 2006, 12:39:13 AM
Erik,
   run your code in Windows 98, it may be scoffed at but it has a much more sensible approach to the user and doesn't try to stop you using CLI/STI.


Paul
Title: Re: How to disable interrupts on win32 with masm32 to use rdtsc instruction
Post by: Mark Jones on August 18, 2006, 05:42:26 AM
I heard that MS is dropping all support for 98/98SE/ME...
Title: Re: How to disable interrupts on win32 with masm32 to use rdtsc instruction
Post by: dioxin on August 18, 2006, 11:09:21 AM
Mark,
  MS may no longer support Win98 but Win98 doesn't stop working because of that.

Paul.
Title: Re: How to disable interrupts on win32 with masm32 to use rdtsc instruction
Post by: Mark Jones on August 19, 2006, 06:20:08 AM
So I wonder, is it more a financial push, the migration to newer versions of Windows?

Or are they trying to distance themselves from older code?