Question about which tools to use, bugs, the best way to implement a function, etc should go here. Don't forget to see if your question is answered in the wiki first! When in doubt post here.
Are you only checking "ticks" using putint() or are you actually examining the value in memory? It might be that the error is in putint() rather than the counter. If you aren't sure, do something like putchar('S') inside the if-statement to see if it ever runs.
The other possibility is that using 64-bit integers requires support code and so doesn't increment properly. As you are only ever counting up to 9 anyway, try using a normal int.
mystran wrote:
What is "double long" btw? Is is really an integer at all? AFAIK gcc usually calls 64-bit (on ia-32 anyway) integers "long long".
For GCC a "double long" is considered a 96 bit floating point value - in reality it's an 80 bit (10 byte) floating point value with 16 bits of padding.
As for "long long", I'm waiting for SSE4 and 128 bit integers in IA-32 .
Cheers,
Brendan
For all things; perfection is, and will always remain, impossible to achieve in practice. However; by striving for perfection we create things that are as perfect as practically possible. Let the pursuit of perfection be our guide.
Another point I'd like to mention: newer GCC releases (3.x and later) are quite aggressive with eliminating redundant loads/stores, so if you plan to read the tick-counter from another thread (which GCC doesn't know anything about) you probably need to declare the variable as "volatile" as in "this variable is read/written from multiple concurrent threads, and therefore caching it in a register will cause problems".
I'm not sure if DJGPP was ever updated to new enough GCC, but I'd use "volatile" anyway where necessary, because adding those later is VERY painful. Possibly even more painful than adding spinlocks for SMP protection.