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 unsigned char uchar0 = 0;
27 unsigned char uchar1 = 0;
28 signed char char0 = 0;
29 signed char char1 = 0;
33 /* *** NOTE *** This particular test takes quite a while to run
34 * ~ 10,000,000 instruction cycles. (2.5 seconds on a 20Mhz PIC).
35 * The WDT will reset the CPU if it's enabled. So disable it...
44 void c_char_gt_lit1(unsigned char expected_result)
66 if(result != expected_result)
70 void char_compare(void)
100 c_char_gt_lit1(0x01);
103 c_char_gt_lit1(0x00);
106 c_char_gt_lit1(0x00);
108 /* Now test entire range */
110 for(char0=2; char0 != 0x7f; char0++)
111 c_char_gt_lit1(0x0f);
113 for(char0=-0x7e; char0 != -1; char0++)
114 c_char_gt_lit1(0x01);
117 void c_int_gt_lit1(unsigned char expected_result)
145 if(result != expected_result)
149 void int_compare1(void)
193 /* now check contiguous ranges */
195 for(int0 = -0x7fff; int0 != -1; int0++)
198 for(int0 = 2; int0 != 0xff; int0++)
201 for(int0 = 0x202; int0 != 0x7fff; int0++)
205 void c_int_gt_lit2(unsigned char expected_result)
233 if(result != expected_result)
237 void int_compare2(void)
287 /* now check contiguous ranges */
289 for(int0 = -0x7ffe; int0 != -0x7f01; int0++)
292 for(int0 = -0x7dff; int0 != -0x101; int0++)
295 for(int0 = 0; int0 != 0x7fff; int0++)
308 printf("failures: %d\n",failures);