I have tested with versions v1.8 (official), v1.9 (official), Nightly build v20111101.
The code is basically a infinite loop that measures time (and loops counter) and shows a text every second (measure time don't include printf time). For measuring time i have used a Amstrad firmware function (KL TIME PLEASE) that returns the time that has elapsed since the computer was switched on or reset (in 1/300ths of a second). From my experience I think that this counter does not increase with interrupts disabled.
Results:
z88dk v1.8: Every second the printf shows about 2600 loops (works as expected)
z88dk v1.9: Every 7 seconds shows about 19000 loops
z88dk v20111101: Every 3 seconds shows about 8400 loops
All the programs runs at 'same velocity' (2600 * 7 = 18000 loops, 2600 * 3 = 7800 loops), but only in v1.8 Amstrad firmware function (KL TIME PLEASE) works as expected, the others 'must disable interrupts longer'.
The code:
Code: Select all
#include <stdio.h>
////////////////////////////////////////////////////////////////////////
unsigned char char1,char2,char3,char4;
unsigned int GetTime()
{
unsigned int nTime = 0;
#asm
CALL $BD0D //KL TIME PLEASE
PUSH HL
/*
LD HL, _char1
LD (HL), D
LD HL, _char2
LD (HL), E
*/
POP DE
LD HL, _char3
LD (HL), D
LD HL, _char4
LD (HL), E
#endasm
nTime = (char3 << 8) + char4;
return nTime;
}
////////////////////////////////////////////////////////////////////////
main()
{
unsigned int nFPS = 0;
unsigned int nTimeLast = 0;
unsigned int nTimeDiff = 0;
nTimeLast = GetTime();
while(1)
{
nFPS++;
nTimeDiff = GetTime() - nTimeLast;
if(nTimeDiff >= 300)
{
printf("Fps %u, time %u\n", nFPS, nTimeDiff);
nTimeLast = GetTime();
nFPS = 0;
}
}
}