I just figured out why my program behaved like it was on speed on XP. Whenever I started it, the call to QueryPerformanceFrequency returned 0 (just as if it wasn't supported) So now that leaves me wondering... what if on some system the high resolution timer is not supported, or in my case what if I have no clue why this call returns 0? I mean.. In any way I have to find a way around in case it fails...

Can anyone recommend a working alternative?

Thanks in advance,
JimmyClif
Posted on 2002-03-03 14:08:45 by JimmyClif
StopWatch!!! :grin: How about timeGetTime or RDTSC or any SystemTime function???

I don't know try it :)
Posted on 2002-03-03 14:12:40 by stryker
thanks u-6007 :)

timegettime does the trick... Too bad I have to restructure quite a bit now :(

But can anyone tell me why it fails on XP in my case? Last OS I had on it was Win98SE and it worked just fine...
Posted on 2002-03-03 14:53:51 by JimmyClif
actually timeGetTime or any time functions aren't that good compared to QueryPerformanceFrequency(and the likes) but it's an alternative :) As for XP can't help ya cause I don't have XP, maybe some XP users will punch in some answers. :alright:
Posted on 2002-03-03 15:00:28 by stryker
Hi.
Did you try GetLastError?
Bye.
Posted on 2002-03-03 19:22:25 by GogetaSSJ4
Yes.. it returns:

"Invalid Access to memory location"

This means to me:

:confused:

:grin: JimmyClif
Posted on 2002-03-03 20:03:48 by JimmyClif
This Seems to work on my box. The only thing
i can think of is you were passing the actual
value and not a pointer to the function.
hope this helps
prs


.686

.model flat, stdcall


include \masm32\include\kernel32.inc
include \masm32\include\windows.inc
include \masm32\include\user32.inc

includelib \masm32\lib\kernel32.lib
includelib \masm32\lib\user32.lib



.data

liResult LARGE_INTEGER <0>
szFormat db "lowdword =%d highdword=%d",0
szBuff db 25 dup (?),0

.code
start:

invoke QueryPerformanceCounter, addr liResult

mov edx, DWORD PTR
mov eax, DWORD PTR

invoke wsprintf, addr szBuff, addr szFormat, edx, eax

invoke MessageBox, NULL, addr szBuff, addr szBuff, MB_OK
invoke ExitProcess, eax

end start
Posted on 2002-03-03 21:22:47 by prs
prs,

Thanks a lot for the sample source code.... Even tho that it is hard to believe... your code works fine and was exactly the same as mine which didn't work.

I even replaced yours with mine and vice versa and nothing worked!

Now it works... (Sherlock Holmes would say :"It is an old maxim of mine that when you have excluded the impossible, whatever remains, however improbable, must be the truth.") The most improbable place where the error could be was the .data? section where I stored the values.. So I moved my QWORD's from beginning of my .data? to the end of it, and no error!

I dunno what the heck is wrong with it but it wouldn't just accept them at the place where I had them. I even moved them at some point into .data and it wouldn't accept them either... only the end of the .data? section...

Weird.
Posted on 2002-03-03 23:06:58 by JimmyClif
In my experience, order of your "variables" on the data section matters.

E.G.



.DATA
var1 DD 0
var2 DD 0

.CODE

mov esi, OFFSET var1
mov DWORD PTR [esi+4], 6


here var2 will have a value 6. I don't know the rest of you guys if you experienced this.
Posted on 2002-03-04 00:09:31 by stryker
No, I know that - I kinda guess it must be related to my HUGE resource section... (should have used the giflib, but now it's way too late) and I don't even use the hi-dword from the QueryPerformanceFreq call... so, i don't use any +4's in that section of code at all...
Posted on 2002-03-04 00:31:48 by JimmyClif
:) I thought you were using it!!! :) Geee! ....
Posted on 2002-03-04 00:37:46 by stryker
nah i don't see no use for a number which rarely changes...
The lower dword is the one which increases like crazy thus me being able to base my gametime on it... ;)
Posted on 2002-03-04 00:40:31 by JimmyClif
prs,
your code works on my copy of xp (returns non-zero values).
Posted on 2002-03-04 02:50:13 by peterverstappen

prs,

Thanks a lot for the sample source code.... Even tho that it is hard to believe... your code works fine and was exactly the same as mine which didn't work.

I even replaced yours with mine and vice versa and nothing worked!

Now it works... (Sherlock Holmes would say :"It is an old maxim of mine that when you have excluded the impossible, whatever remains, however improbable, must be the truth.") The most improbable place where the error could be was the .data? section where I stored the values.. So I moved my QWORD's from beginning of my .data? to the end of it, and no error!

I dunno what the heck is wrong with it but it wouldn't just accept them at the place where I had them. I even moved them at some point into .data and it wouldn't accept them either... only the end of the .data? section...

Weird.


The "enigma" is quickly solved: you must pass a longword aligned memory pointer.

Blame on Microsoft that requires that (on a CPU which works perfectly also on misaligned data), and doesn't even report that on the SDK, in that function.
Posted on 2002-03-22 18:51:37 by Maverick
Maverick,

A what ? *hehehe* A longword aligned memory pointer ? *hehehe* Where do I find that? How do I do such a thing ?

Cheers,
JimmyClif
Posted on 2002-03-22 20:33:44 by JimmyClif
Sorry, I should have been more clear, but it was late night: to QueryPerformanceXXX you pass a pointer to a unsigned 64 bit value. Now, your unsigned 64 bit variable must be at least longword aligned.. otherwise the function will return 0 (!!!).

Under Win 9x instead alignment doesn't matter (as it should..).
Posted on 2002-03-23 04:46:58 by Maverick
Afternoon, All.

Dunno if this'll be useful or not...
I've attached the asm file I include for doing the timing in some of the DX examples.
The file is called dxutil.asm because the timing stuff has been taken from the M$ dxutil file.

It uses QueryPerformanceXXX if available, otherwise it falls back on using timegettime. It hasn't been fully tested, however the basics work (start/stop/getelapsedtime/etc).

Cheers,
Scronty
Posted on 2002-03-23 06:10:33 by Scronty
Well, as earlier said I passed a pointer to a Qword... This alignment stuff is over my head tho... How you know that they need to be aligned? Would "align 4" do the trick when placed before my Qwords? What exactly does align do ?
Posted on 2002-03-23 12:33:24 by JimmyClif