flat assembler
Message board for the users of flat assembler.

Index > Windows > NOTE:ALIGN 4 on dq params for QueryPerformance functions !

Author
Thread Post new topic Reply to topic
hopcode



Joined: 04 Mar 2008
Posts: 563
Location: Germany
hopcode 02 Nov 2008, 03:18
Important:
invoke QueryPerformanceCounter,n1
invoke QueryPerformanceFrequency,n2
require ALIGN 4 for the LARGE_INTEGER (dq)
n1 and n2. If not aligned the functions fail!!
Code:
 align 4
 n1 dq 0
 n2 dq 0
    
Post 02 Nov 2008, 03:18
View user's profile Send private message Visit poster's website Reply with quote
LocoDelAssembly
Your code has a bug


Joined: 06 May 2005
Posts: 4624
Location: Argentina
LocoDelAssembly 02 Nov 2008, 04:11
True, have you found any documentation backing that? I know it is true, but I never found where the documentation imposes such alignment constraint (maybe I was too blind).

[edit] BTW, align 4 or align 8? I though it was the latter
Post 02 Nov 2008, 04:11
View user's profile Send private message Reply with quote
revolution
When all else fails, read the source


Joined: 24 Aug 2004
Posts: 20299
Location: In your JS exploiting you and your system
revolution 02 Nov 2008, 05:10
I always align dwords to 4 and qwords to 8 as a matter of standard. There is really no reason why predefined data declarations would not be aligned.

As to why the functions fails, well that is hard to know. It could be a hang over from the original NT days with the Alpha and Motorola CPUs not being so friendly about alignment. And putting in the necessary alignment fixup code into a high performance counter function is likely to create an overhead that is out of proportion with the intended use.
Post 02 Nov 2008, 05:10
View user's profile Send private message Visit poster's website Reply with quote
hopcode



Joined: 04 Mar 2008
Posts: 563
Location: Germany
hopcode 07 Nov 2008, 15:52
LocoDelAssembly wrote:
True, have you found any documentation backing that?...BTW, align 4 or align 8? I though it was the latter

No,at the moment. I am investigating...I can only imagine why, but i am not at all sure...
Pheraps this ALIGN 4/8 (4 should be already sufficient) is in a way
related with the structure of KUSER_SHARED_DATA
(look at this thread )
...
Post 07 Nov 2008, 15:52
View user's profile Send private message Visit poster's website Reply with quote
asmcoder



Joined: 02 Jun 2008
Posts: 784
asmcoder 10 Nov 2008, 09:55
[content deleted]


Last edited by asmcoder on 14 Aug 2009, 14:55; edited 1 time in total
Post 10 Nov 2008, 09:55
View user's profile Send private message Reply with quote
bitshifter



Joined: 04 Dec 2007
Posts: 796
Location: Massachusetts, USA
bitshifter 10 Nov 2008, 10:03
That is very strange.
Is the LARGE_INTEGER defined as global or local?
Maybe try pushing 4 word values and using call instead.
Post 10 Nov 2008, 10:03
View user's profile Send private message Reply with quote
Display posts from previous:
Post new topic Reply to topic

Jump to:  


< Last Thread | Next Thread >
Forum Rules:
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You can download files in this forum


Copyright © 1999-2024, Tomasz Grysztar. Also on GitHub, YouTube.

Website powered by rwasa.