3 // Signed comparisons of the form: (variable<=LIT)
5 // This regression test exercises all of the boundary
6 // conditions in literal less than or equal comparisons. There
7 // are numerous opportunities to optimize these comparison
8 // and each one has an astonishing capability of failing
9 // a boundary condition.
11 unsigned char success = 0;
12 unsigned char failures = 0;
13 unsigned char dummy = 0;
14 unsigned char result = 0;
18 signed char char0 = 0;
19 signed char char1 = 0;
21 /* copied from 16f877.inc file supplied with gpasm */
23 #define _CP_ALL 0x0FCF
24 #define _CP_HALF 0x1FDF
25 #define _CP_UPPER_256 0x2FEF
26 #define _CP_OFF 0x3FFF
27 #define _DEBUG_ON 0x37FF
28 #define _DEBUG_OFF 0x3FFF
29 #define _WRT_ENABLE_ON 0x3FFF
30 #define _WRT_ENABLE_OFF 0x3DFF
31 #define _CPD_ON 0x3EFF
32 #define _CPD_OFF 0x3FFF
33 #define _LVP_ON 0x3FFF
34 #define _LVP_OFF 0x3F7F
35 #define _BODEN_ON 0x3FFF
36 #define _BODEN_OFF 0x3FBF
37 #define _PWRTE_OFF 0x3FFF
38 #define _PWRTE_ON 0x3FF7
39 #define _WDT_ON 0x3FFF
40 #define _WDT_OFF 0x3FFB
41 #define _LP_OSC 0x3FFC
42 #define _XT_OSC 0x3FFD
43 #define _HS_OSC 0x3FFE
44 #define _RC_OSC 0x3FFF
46 /* *** NOTE *** This particular test takes quite a while to run
47 * ~ 10,000,000 instruction cycles. (2.5 seconds on a 20Mhz PIC).
48 * The WDT will reset the CPU if it's enabled. So disable it...
51 typedef unsigned int word;
53 word at 0x2007 CONFIG = _WDT_OFF & _PWRTE_ON;
62 void c_char_lte_lit1(unsigned char expected_result)
81 if(result != expected_result)
86 void char_compare(void)
89 c_char_lte_lit1(0x10);
92 c_char_lte_lit1(0x10);
95 c_char_lte_lit1(0x10);
98 c_char_lte_lit1(0x10);
101 c_char_lte_lit1(0x18);
104 c_char_lte_lit1(0x1c);
107 c_char_lte_lit1(0x1e);
110 c_char_lte_lit1(0x1e);
113 c_char_lte_lit1(0x1e);
116 c_char_lte_lit1(0x1e);
119 c_char_lte_lit1(0x1f);
122 // c_char_lte_lit1(0x1f);
125 /* Now test entire range */
127 for(char0=2; char0 != 0x7f; char0++)
128 c_char_lte_lit1(0x10);
131 for(char0=-0x7e; char0 != 0; char0++)
132 c_char_lte_lit1(0x1e);
137 void c_int_lte_lit1(unsigned char expected_result)
166 if(result != expected_result)
172 void int_compare1(void)
175 c_int_lte_lit1(0xff);
178 c_int_lte_lit1(0xff);
181 c_int_lte_lit1(0xfe);
184 c_int_lte_lit1(0xfc);
187 c_int_lte_lit1(0xfc);
190 c_int_lte_lit1(0xfc);
193 c_int_lte_lit1(0xf8);
196 c_int_lte_lit1(0xf0);
199 c_int_lte_lit1(0xe0);
202 c_int_lte_lit1(0xe0);
205 c_int_lte_lit1(0xc0);
208 c_int_lte_lit1(0x80);
213 /* now check contiguous ranges */
215 for(int0 = -0x7fff; int0 != 1; int0++)
216 c_int_lte_lit1(0xff);
218 for(int0 = 2; int0 != 0xff; int0++)
219 c_int_lte_lit1(0xfc);
221 for(int0 = 0x202; int0 != 0x7fff; int0++)
228 void c_int_lte_lit2(unsigned char expected_result)
256 if(result != expected_result)
260 void int_compare2(void)
263 c_int_lte_lit2(0xff);
266 c_int_lte_lit2(0xfe);
269 c_int_lte_lit2(0xfc);
272 c_int_lte_lit2(0xf8);
275 c_int_lte_lit2(0xf0);
278 c_int_lte_lit2(0xf0);
281 c_int_lte_lit2(0xf0);
284 c_int_lte_lit2(0xf0);
287 c_int_lte_lit2(0xe0);
290 c_int_lte_lit2(0xc0);
293 c_int_lte_lit2(0x80);
296 c_int_lte_lit2(0x80);
299 c_int_lte_lit2(0x00);
302 c_int_lte_lit2(0x00);
305 c_int_lte_lit2(0x00);
307 /* now check contiguous ranges */
309 for(int0 = -0x7ffe; int0 != -0x7f00; int0++)
310 c_int_lte_lit2(0xfe);
312 for(int0 = -0x7dff; int0 != -0x101; int0++)
313 c_int_lte_lit2(0xf0);
315 for(int0 = 0; int0 != 0x7fff; int0++)