flat assembler
Message board for the users of flat assembler.
Index
> Main > Cross-platform GetTickCount() ? |
Author |
|
asmcoder 23 Aug 2008, 13:28
[content deleted]
Last edited by asmcoder on 14 Aug 2009, 14:56; edited 1 time in total |
|||
23 Aug 2008, 13:28 |
|
revolution 23 Aug 2008, 14:42
Unfortunately there is no 100% reliable way to get a high resolution counter. RDTSC is not available on all IA32 CPUs. If your requirement can be relaxed to just the later range of CPUs that do have RDTSC (ie. excluding 80386 etc.) then it is a start. However you need to ensure that you limit your thread to one CPU in a multicore setup else you can get different count values returned from each of the cores. Also, some cores change the rate of count when entering lower power modes and other cores keep to one rate, so reliable count rates can be troublesome.
Probably the best way to ensure reliable timing from a counter is the use the motherboard timer. It doesn't count as fast as RDTSC but it is available on all boards that support IA32 CPUs and doesn't change the rate of count during lower power modes. Also, it doesn't matter which CPU th thread runs on, the count value is always monotonic and increasing. |
|||
23 Aug 2008, 14:42 |
|
adnimo 23 Aug 2008, 14:49
Hi, thanks for the info.
So how does GetTickCount() work on windows?, I would like to have both lower and higher resolution timers, I don't mind limiting to certain CPUs, I'm guessing that the majority of the market now supports the instruction right?. The game I'm working on targets CPUs of 300mhz and up (P2, etc) I'm not willing to support anything lower than that because I believe it's pointless. |
|||
23 Aug 2008, 14:49 |
|
revolution 23 Aug 2008, 15:12
GetTickCount returns a millisecond counter however the accuracy is never actually 1ms. For all Windows systems I have used the accuracy is 10ms, ie. it counts in steps is 10ms each time.
The underlying timer for GetTickCount is the motherboard timer. If you are using Windows then have a look at QueryPerformanceCounter, and the related QueryPerformanceFrequency. Perhaps they can give you what you need. |
|||
23 Aug 2008, 15:12 |
|
adnimo 23 Aug 2008, 18:46
hi, thanks. however I'm trying to achieve a platform independent timer, because I would like to compile my code in linux as well. I'm using the performance counter right now under windows, it works just great but I don't want to learn yet another api just to do the timing... why should I when its all available through asm?
|
|||
23 Aug 2008, 18:46 |
|
Madis731 23 Aug 2008, 22:54
If you're making a game today, I think its pointless to support anything under a Core 2/Athlon 64 setup because ppl who play games go storm on newer architectures just to play @24FPS their new games
If they are a player type, they already have a conf. that will play your game. CPUID/RDTSC were introduced somewhere in Pentium times and have been on every architecture since then. By architecture I mean Intel ones, AMD ones and even VIA chips (though I don't know how does an average person get or have one). What I'm trying to say is that its safe to use this instruction |
|||
23 Aug 2008, 22:54 |
|
vid 24 Aug 2008, 07:54
Use some game engine, it saves load of problems for you. SDL comes to mind...
|
|||
24 Aug 2008, 07:54 |
|
Patrick_ 24 Aug 2008, 22:27
The clock() libc function is a cross-platform GetTickCount() equivalent.
|
|||
24 Aug 2008, 22:27 |
|
< Last Thread | Next Thread > |
Forum Rules:
|
Copyright © 1999-2025, Tomasz Grysztar. Also on GitHub, YouTube.
Website powered by rwasa.