2 !!DESCRIPTION!! Signed comparisons of the form: (variable<=LIT)
3 !!ORIGIN!! SDCC regression tests
4 !!LICENCE!! GPL, read COPYING.GPL
11 This regression test exercises all of the boundary
12 conditions in literal less than or equal comparisons. There
13 are numerous opportunities to optimize these comparison
14 and each one has an astonishing capability of failing
18 unsigned char success = 0;
19 unsigned char failures = 0;
20 unsigned char dummy = 0;
21 unsigned char result = 0;
25 signed char char0 = 0;
26 signed char char1 = 0;
28 /* *** NOTE *** This particular test takes quite a while to run
29 * ~ 10,000,000 instruction cycles. (2.5 seconds on a 20Mhz PIC).
30 * The WDT will reset the CPU if it's enabled. So disable it...
39 void c_char_lte_lit1(unsigned char expected_result)
58 if(result != expected_result)
62 void char_compare(void)
65 c_char_lte_lit1(0x10);
68 c_char_lte_lit1(0x10);
71 c_char_lte_lit1(0x10);
74 c_char_lte_lit1(0x10);
77 c_char_lte_lit1(0x18);
80 c_char_lte_lit1(0x1c);
83 c_char_lte_lit1(0x1e);
86 c_char_lte_lit1(0x1e);
89 c_char_lte_lit1(0x1e);
92 c_char_lte_lit1(0x1e);
95 c_char_lte_lit1(0x1f);
98 /* c_char_lte_lit1(0x1f); */
100 /* Now test entire range */
102 for(char0=2; char0 != 0x7f; char0++)
103 c_char_lte_lit1(0x10);
105 for(char0=-0x7e; char0 != 0; char0++)
106 c_char_lte_lit1(0x1e);
109 void c_int_lte_lit1(unsigned char expected_result)
137 if(result != expected_result)
141 void int_compare1(void)
144 c_int_lte_lit1(0xff);
147 c_int_lte_lit1(0xff);
150 c_int_lte_lit1(0xfe);
153 c_int_lte_lit1(0xfc);
156 c_int_lte_lit1(0xfc);
159 c_int_lte_lit1(0xfc);
162 c_int_lte_lit1(0xf8);
165 c_int_lte_lit1(0xf0);
168 c_int_lte_lit1(0xe0);
171 c_int_lte_lit1(0xe0);
174 c_int_lte_lit1(0xc0);
177 c_int_lte_lit1(0x80);
182 /* now check contiguous ranges */
184 for(int0 = -0x7fff; int0 != 1; int0++)
185 c_int_lte_lit1(0xff);
187 for(int0 = 2; int0 != 0xff; int0++)
188 c_int_lte_lit1(0xfc);
190 for(int0 = 0x202; int0 != 0x7fff; int0++)
194 void c_int_lte_lit2(unsigned char expected_result)
222 if(result != expected_result)
226 void int_compare2(void)
229 c_int_lte_lit2(0xff);
232 c_int_lte_lit2(0xfe);
235 c_int_lte_lit2(0xfc);
238 c_int_lte_lit2(0xf8);
241 c_int_lte_lit2(0xf0);
244 c_int_lte_lit2(0xf0);
247 c_int_lte_lit2(0xf0);
250 c_int_lte_lit2(0xf0);
253 c_int_lte_lit2(0xe0);
256 c_int_lte_lit2(0xc0);
259 c_int_lte_lit2(0x80);
262 c_int_lte_lit2(0x80);
265 c_int_lte_lit2(0x00);
268 c_int_lte_lit2(0x00);
271 c_int_lte_lit2(0x00);
273 /* now check contiguous ranges */
275 for(int0 = -0x7ffe; int0 != -0x7f00; int0++)
276 c_int_lte_lit2(0xfe);
278 for(int0 = -0x7dff; int0 != -0x101; int0++)
279 c_int_lte_lit2(0xf0);
281 for(int0 = 0; int0 != 0x7fff; int0++)
294 printf("failures: %d\n",failures);