News:

MASM32 SDK Description, downloads and other helpful links
MASM32.com New Forum Link
masmforum WebSite

How long program has run

Started by Magnum, June 05, 2010, 01:40:56 AM

Previous topic - Next topic

Magnum

This is not working for some reason.


; 16 bit (10 divided by 2)
; xor dx,dx ; zero out dx
; mov ax,10
; mov bx,2
; div bx ;AX = 5 and DX = 0
            xor edx,edx        ; convert to seconds
            xor ebx,ebx
            mov ebx,1000d   ; divide by 1000
            div ebx 


Have a great day,
                         Andy

Tedd

Quote from: Magnum on June 05, 2010, 10:41:20 PM
The original source was wrong(would not compile), so I used Ollydbg to come up with this.
Can you convert to the "Non-hard version."
The original source assembles fine, unmodified. The "non-hard version" is what was there in the first place.
Most likely you removed the 'usage' string and/or 'len_usage' in which case those labels won't be found, so you'd need to fix the line to either print what you want, or remove it altogether.


For the conversion, DIV gives the quotient in eax and remainder in edx:

987654321 ms:

987654321 / 1000 = 987654, remainder 321 {msec}
987654 / 60 = 16460, remainder 54 {sec}
16460 / 60 = 274, remainder 20 {min}
274 / 24 = 11 {days}, remainder 10 {hours}

==> 11 days, 10:20:54.321


And you can just check which components are zero, if you want to only print the minimum (i.e. if days is zero, don't print days.)
No snowflake in an avalanche feels responsible.

Magnum

I get this with the attached source.

C:\masm32\SOURCE\test.asm(196) : error A2070: invalid instruction operands
Have a great day,
                         Andy

Tedd

Strange, I don't. It assembles without error or warning, for me.

Even stranger, line 196 in that source file is "xor eax,eax" Either there is something very wrong with your installation of masm, or that isn't the actual source you're getting an error from.


Also, if you're only running and timing firefox, you can remove all of the commandline handling stuff, and converting the process user and kernel times - but that would require you to understand the code instead of repeatedly copying and pasting junk from all over the place.
No snowflake in an avalanche feels responsible.

qWord

In the attachmend you will find an example. However, it is not working for all programs as expected: e.g. explorer.exe or iexplore.exe(maybe an protection)
Usage:ptime C:\myexe.exe

qWord
FPU in a trice: SmplMath
It's that simple!

Tedd

Quote from: qWord on June 06, 2010, 12:31:33 PM
it is not working for all programs as expected: e.g. explorer.exe or iexplore.exe(maybe an protection)
explorer is running constantly - it provides the GUI. So when you try to launch an instance, that sees it's already running, tells it to create an 'explorer window' and then exits - the time you get is from the dummy instance (which lasts less than a second.)
And the same for iexplore, as long as you already have an instance running (the first instance gives the correct time.)
No snowflake in an avalanche feels responsible.

qWord

Quote from: Tedd on June 06, 2010, 10:02:39 PMAnd the same for iexplore, as long as you already have an instance running (the first instance gives the correct time.)
that can't be all about it. As more IE instances started, as more process will be created - but the number of processes is not allway the same as visible windows.
My thought is  that m$ has split some jobs into different processes for security reason - but maybe I'm wrong  :bg
FPU in a trice: SmplMath
It's that simple!

Magnum

Quote from: Tedd on June 06, 2010, 11:54:50 AM
Strange, I don't. It assembles without error or warning, for me.

Even stranger, line 196 in that source file is "xor eax,eax" Either there is something very wrong with your installation of masm, or that isn't the actual source you're getting an error from.


Also, if you're only running and timing firefox, you can remove all of the commandline handling stuff, and converting the process user and kernel times - but that would require you to understand the code instead of repeatedly copying and pasting junk from all over the place.


I re-installed masm, and it assembles correctly. TGF Disk Imager. :-)

Qword's ptime is just what I need,  but I am still studying your code to learn all I can.

I came up with a div routine that converts ms to seconds but it isn't working like it should
A lot of the code before isn't commented, so I don't understand it all.

Copying and pasting is part of my learning process.
I do read the APIs, tutorials, and the Intel documentation first to minimize the above line.


Have a great day,
                         Andy

oex

Hey guys, I dont know if this has anything to do with your problem but I noticed the other day that when I close an ie browser window the process doesnt end.... until I close the last browser window....

I dont know if this is always the case, whether this is because of toolbars or whether it's because of js....

If you do happen to know I'd also be interested in knowing but anyways it would probably explain your issue
We are all of us insane, just to varying degrees and intelligently balanced through networking

http://www.hereford.tv

Magnum

Quote from: oex on June 07, 2010, 12:56:25 AM
Hey guys, I dont know if this has anything to do with your problem but I noticed the other day that when I close an ie browser window the process doesnt end.... until I close the last browser window....

I dont know if this is always the case, whether this is because of toolbars or whether it's because of js....

If you do happen to know I'd also be interested in knowing but anyways it would probably explain your issue

Are you referring to having multiple instances of ie being open?

Have a great day,
                         Andy

rags

Magnum,
Are you including partial run times in your time logging?

For example, if you used your browser for an hour, then for some reason it crashed would that hours time
be logged as time being used?  The browser was used for an hour, but the process wasn't ended in a 'normal' way.
Just something else to think about.
God made Man, but the monkey applied the glue -DEVO

oex

Quote from: Magnum on June 07, 2010, 02:54:14 AM
Are you referring to having multiple instances of ie being open?

Yeah multiple ie windows rather than tabs.... In task manager the process keeps running even though the window is closed.... I would have expected the process to close with the window not when the final ie window is closed for all ie processes to end
We are all of us insane, just to varying degrees and intelligently balanced through networking

http://www.hereford.tv

dedndave

it may depend on whether the window was opened from a link or seperately
if you have IE open, then right-click on a link, then Open in a new window, it will be a new window of the same instance
if you have IE open, then use a shortcut (LNK, not URL) to open another IE window, it creates a new instance

oex

Ah that could be it I do right click open all the time I detest tabs
We are all of us insane, just to varying degrees and intelligently balanced through networking

http://www.hereford.tv

dedndave

well - i use IE6 when i do use IE - not sure about 7 or 8
i usually use Firefox which, if it is a different window, it is a new instance