1 // Signed comparisons of the form: (variable<=LIT)
3 // This regression test exercises all of the boundary
4 // conditions in literal less than or equal comparisons. There
5 // are numerous opportunities to optimize these comparison
6 // and each one has an astonishing capability of failing
7 // a boundary condition.
9 unsigned char success = 0;
10 unsigned char failures = 0;
11 unsigned char dummy = 0;
12 unsigned char result = 0;
16 signed char char0 = 0;
17 signed char char1 = 0;
19 /* copied from 16f877.inc file supplied with gpasm */
21 #define _CP_ALL 0x0FCF
22 #define _CP_HALF 0x1FDF
23 #define _CP_UPPER_256 0x2FEF
24 #define _CP_OFF 0x3FFF
25 #define _DEBUG_ON 0x37FF
26 #define _DEBUG_OFF 0x3FFF
27 #define _WRT_ENABLE_ON 0x3FFF
28 #define _WRT_ENABLE_OFF 0x3DFF
29 #define _CPD_ON 0x3EFF
30 #define _CPD_OFF 0x3FFF
31 #define _LVP_ON 0x3FFF
32 #define _LVP_OFF 0x3F7F
33 #define _BODEN_ON 0x3FFF
34 #define _BODEN_OFF 0x3FBF
35 #define _PWRTE_OFF 0x3FFF
36 #define _PWRTE_ON 0x3FF7
37 #define _WDT_ON 0x3FFF
38 #define _WDT_OFF 0x3FFB
39 #define _LP_OSC 0x3FFC
40 #define _XT_OSC 0x3FFD
41 #define _HS_OSC 0x3FFE
42 #define _RC_OSC 0x3FFF
44 /* *** NOTE *** This particular test takes quite a while to run
45 * ~ 10,000,000 instruction cycles. (2.5 seconds on a 20Mhz PIC).
46 * The WDT will reset the CPU if it's enabled. So disable it...
49 typedef unsigned int word;
51 word at 0x2007 CONFIG = _WDT_OFF & _PWRTE_ON;
60 void c_char_lte_lit1(unsigned char expected_result)
79 if(result != expected_result)
84 void char_compare(void)
87 c_char_lte_lit1(0x10);
90 c_char_lte_lit1(0x10);
93 c_char_lte_lit1(0x10);
96 c_char_lte_lit1(0x10);
99 c_char_lte_lit1(0x18);
102 c_char_lte_lit1(0x1c);
105 c_char_lte_lit1(0x1e);
108 c_char_lte_lit1(0x1e);
111 c_char_lte_lit1(0x1e);
114 c_char_lte_lit1(0x1e);
117 c_char_lte_lit1(0x1f);
120 // c_char_lte_lit1(0x1f);
123 /* Now test entire range */
125 for(char0=2; char0 != 0x7f; char0++)
126 c_char_lte_lit1(0x10);
129 for(char0=-0x7e; char0 != 0; char0++)
130 c_char_lte_lit1(0x1e);
135 void c_int_lte_lit1(unsigned char expected_result)
164 if(result != expected_result)
170 void int_compare1(void)
173 c_int_lte_lit1(0xff);
176 c_int_lte_lit1(0xff);
179 c_int_lte_lit1(0xfe);
182 c_int_lte_lit1(0xfc);
185 c_int_lte_lit1(0xfc);
188 c_int_lte_lit1(0xfc);
191 c_int_lte_lit1(0xf8);
194 c_int_lte_lit1(0xf0);
197 c_int_lte_lit1(0xe0);
200 c_int_lte_lit1(0xe0);
203 c_int_lte_lit1(0xc0);
206 c_int_lte_lit1(0x80);
211 /* now check contiguous ranges */
213 for(int0 = -0x7fff; int0 != 1; int0++)
214 c_int_lte_lit1(0xff);
216 for(int0 = 2; int0 != 0xff; int0++)
217 c_int_lte_lit1(0xfc);
219 for(int0 = 0x202; int0 != 0x7fff; int0++)
226 void c_int_lte_lit2(unsigned char expected_result)
254 if(result != expected_result)
258 void int_compare2(void)
261 c_int_lte_lit2(0xff);
264 c_int_lte_lit2(0xfe);
267 c_int_lte_lit2(0xfc);
270 c_int_lte_lit2(0xf8);
273 c_int_lte_lit2(0xf0);
276 c_int_lte_lit2(0xf0);
279 c_int_lte_lit2(0xf0);
282 c_int_lte_lit2(0xf0);
285 c_int_lte_lit2(0xe0);
288 c_int_lte_lit2(0xc0);
291 c_int_lte_lit2(0x80);
294 c_int_lte_lit2(0x80);
297 c_int_lte_lit2(0x00);
300 c_int_lte_lit2(0x00);
303 c_int_lte_lit2(0x00);
305 /* now check contiguous ranges */
307 for(int0 = -0x7ffe; int0 != -0x7f00; int0++)
308 c_int_lte_lit2(0xfe);
310 for(int0 = -0x7dff; int0 != -0x101; int0++)
311 c_int_lte_lit2(0xf0);
313 for(int0 = 0; int0 != 0x7fff; int0++)