1
10
13
14
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
141
174
188
202
216
230
244
258
272
286
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
316
320
321
322
323
324
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
...
...
...
#define FX_SOURCE_CODE
#include "fx_api.h"
#include "fx_system.h"
...
...
VOID _fx_system_timer_entry(ULONG id)
{
UINT second;
UINT minute;
UINT hour;
UINT day;
UINT month;
UINT year;
if (id == FX_TIMER_ID)
{
second = (_fx_system_time & FX_SECOND_MASK) * 2;
minute = (_fx_system_time >> FX_MINUTE_SHIFT) & FX_MINUTE_MASK;
hour = (_fx_system_time >> FX_HOUR_SHIFT) & FX_HOUR_MASK;
day = _fx_system_date & FX_DAY_MASK;
month = (_fx_system_date >> FX_MONTH_SHIFT) & FX_MONTH_MASK;
year = ((_fx_system_date >> FX_YEAR_SHIFT) & FX_YEAR_MASK) + FX_BASE_YEAR;
second = second + FX_UPDATE_RATE_IN_SECONDS;
if (second > FX_MAXIMUM_SECOND)
{
minute = minute + second / 60;
second = second % 60;
if (minute > FX_MAXIMUM_MINUTE)
{
hour = hour + minute / 60;
minute = minute % 60;
if (hour > FX_MAXIMUM_HOUR)
{
hour = 0;
day++;
switch (month)
{
case 1:
{
if (day > 31)
{
day = 1;
month++;
}if (day > 31) { ... }
break;
...}
case 1:
case 2:
{
/* ... */
if ((year % 4) == 0)
{
/* ... */
if (day > 29)
{
day = 1;
month++;
}if (day > 29) { ... }
}if ((year % 4) == 0) { ... }
else
{
if (day > 28)
{
day = 1;
month++;
}if (day > 28) { ... }
}else { ... }
break;
...}
case 2:
case 3:
{
if (day > 31)
{
day = 1;
month++;
}if (day > 31) { ... }
break;
...}
case 3:
case 4:
{
if (day > 30)
{
day = 1;
month++;
}if (day > 30) { ... }
break;
...}
case 4:
case 5:
{
if (day > 31)
{
day = 1;
month++;
}if (day > 31) { ... }
break;
...}
case 5:
case 6:
{
if (day > 30)
{
day = 1;
month++;
}if (day > 30) { ... }
break;
...}
case 6:
case 7:
{
if (day > 31)
{
day = 1;
month++;
}if (day > 31) { ... }
break;
...}
case 7:
case 8:
{
if (day > 31)
{
day = 1;
month++;
}if (day > 31) { ... }
break;
...}
case 8:
case 9:
{
if (day > 30)
{
day = 1;
month++;
}if (day > 30) { ... }
break;
...}
case 9:
case 10:
{
if (day > 31)
{
day = 1;
month++;
}if (day > 31) { ... }
break;
...}
case 10:
case 11:
{
if (day > 30)
{
day = 1;
month++;
}if (day > 30) { ... }
break;
...}
case 11:
case 12:
{
if (day > 31)
{
day = 1;
month = 1;
year++;
/* ... */
if (year > FX_MAXIMUM_YEAR)
{
return;
}if (year > FX_MAXIMUM_YEAR) { ... }
}if (day > 31) { ... }
break;
...}
case 12:
default:
return; default
}switch (month) { ... }
}if (hour > FX_MAXIMUM_HOUR) { ... }
}if (minute > FX_MAXIMUM_MINUTE) { ... }
}if (second > FX_MAXIMUM_SECOND) { ... }
_fx_system_date = ((year - FX_BASE_YEAR) << FX_YEAR_SHIFT) |
(month << FX_MONTH_SHIFT) | day;
_fx_system_time = (hour << FX_HOUR_SHIFT) |
(minute << FX_MINUTE_SHIFT) | (second / 2);
}if (id == FX_TIMER_ID) { ... }
}{ ... }