2 !!DESCRIPTION!! Signed comparisons of the form: (variable<LIT)
3 !!ORIGIN!! SDCC regression tests
4 !!LICENCE!! GPL, read COPYING.GPL
10 /* This regression test exercises all of the boundary
11 conditions in literal less than comparisons. There
12 are numerous opportunities to optimize these comparison
13 and each one has an astonishing capability of failing
16 unsigned char success = 0;
17 unsigned char failures = 0;
18 unsigned char dummy = 0;
19 unsigned char result = 0;
21 #ifdef SUPPORT_BIT_TYPES
26 signed char char0 = 0;
27 signed char char1 = 0;
31 /* *** NOTE *** This particular test takes quite a while to run
32 * ~ 10,000,000 instruction cycles. (2.5 seconds on a 20Mhz PIC).
33 * The WDT will reset the CPU if it's enabled. So disable it...
42 void c_char_lt_lit1(unsigned char expected_result)
61 if(result != expected_result)
65 void char_compare(void)
100 c_char_lt_lit1(0x1e);
103 c_char_lt_lit1(0x1f);
105 /* Now test entire range */
107 for(char0=1; char0 != 0x7f; char0++)
108 c_char_lt_lit1(0x10);
110 for(char0=-0x7f; char0 != -1; char0++)
111 c_char_lt_lit1(0x1e);
114 void c_int_lt_lit1(unsigned char expected_result)
142 if(result != expected_result)
146 void int_compare1(void)
187 /* now check contiguous ranges */
189 for(int0 = -0x7fff; int0 != -1; int0++)
192 for(int0 = 1; int0 != 0xff; int0++)
195 for(int0 = 0x201; int0 != 0x7fff; int0++)
199 void c_int_lt_lit2(unsigned char expected_result)
227 if(result != expected_result)
231 void int_compare2(void)
278 /* now check contiguous ranges */
282 for(int0 = -0x7ffe; int0 != -0x7f01; int0++)
285 for(int0 = -0x7e00; int0 != -0x101; int0++)
288 for(int0 = -1; int0 != 0x7fff; int0++)
296 printf("failures: %d\n",failures);
299 printf("failures: %d\n",failures);
304 printf("failures: %d\n",failures);