3 // Signed comparisons of the form: (variable>=LIT)
5 // This regression test exercises all of the boundary
6 // conditions in literal less than 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;
19 unsigned char uchar0 = 0;
20 unsigned char uchar1 = 0;
21 signed char char0 = 0;
22 signed char char1 = 0;
26 /* copied from 16f877.inc file supplied with gpasm */
28 #define _CP_ALL 0x0FCF
29 #define _CP_HALF 0x1FDF
30 #define _CP_UPPER_256 0x2FEF
31 #define _CP_OFF 0x3FFF
32 #define _DEBUG_ON 0x37FF
33 #define _DEBUG_OFF 0x3FFF
34 #define _WRT_ENABLE_ON 0x3FFF
35 #define _WRT_ENABLE_OFF 0x3DFF
36 #define _CPD_ON 0x3EFF
37 #define _CPD_OFF 0x3FFF
38 #define _LVP_ON 0x3FFF
39 #define _LVP_OFF 0x3F7F
40 #define _BODEN_ON 0x3FFF
41 #define _BODEN_OFF 0x3FBF
42 #define _PWRTE_OFF 0x3FFF
43 #define _PWRTE_ON 0x3FF7
44 #define _WDT_ON 0x3FFF
45 #define _WDT_OFF 0x3FFB
46 #define _LP_OSC 0x3FFC
47 #define _XT_OSC 0x3FFD
48 #define _HS_OSC 0x3FFE
49 #define _RC_OSC 0x3FFF
51 /* *** NOTE *** This particular test takes quite a while to run
52 * ~ 10,000,000 instruction cycles. (2.5 seconds on a 20Mhz PIC).
53 * The WDT will reset the CPU if it's enabled. So disable it...
56 typedef unsigned int word;
58 word at 0x2007 CONFIG = _WDT_OFF & _PWRTE_ON;
67 void c_char_gte_lit1(unsigned char expected_result)
90 if(result != expected_result)
95 void char_compare(void)
98 c_char_gte_lit1(0x3f);
101 c_char_gte_lit1(0x1f);
104 c_char_gte_lit1(0x0f);
107 c_char_gte_lit1(0x0f);
110 c_char_gte_lit1(0x0f);
113 c_char_gte_lit1(0x07);
116 c_char_gte_lit1(0x03);
119 c_char_gte_lit1(0x01);
122 c_char_gte_lit1(0x01);
125 c_char_gte_lit1(0x01);
128 c_char_gte_lit1(0x01);
131 c_char_gte_lit1(0x00);
134 /* Now test entire range */
136 for(char0=1; char0 != 0x7e; char0++)
137 c_char_gte_lit1(0x0f);
139 for(char0=-0x7f; char0 != -1; char0++)
140 c_char_gte_lit1(0x01);
145 void c_int_gte_lit1(unsigned char expected_result)
174 if(result != expected_result)
180 void int_compare1(void)
183 c_int_gte_lit1(0x00);
186 c_int_gte_lit1(0x01);
189 c_int_gte_lit1(0x03);
192 c_int_gte_lit1(0x03);
195 c_int_gte_lit1(0x03);
198 c_int_gte_lit1(0x07);
201 c_int_gte_lit1(0x0f);
204 c_int_gte_lit1(0x1f);
207 c_int_gte_lit1(0x1f);
210 c_int_gte_lit1(0x1f);
213 c_int_gte_lit1(0x3f);
216 c_int_gte_lit1(0x7f);
219 c_int_gte_lit1(0xff);
222 c_int_gte_lit1(0xff);
224 /* now check contiguous ranges */
226 for(int0 = -0x7fff; int0 != -1; int0++)
227 c_int_gte_lit1(0x00);
229 for(int0 = 1; int0 != 0xff; int0++)
230 c_int_gte_lit1(0x03);
232 for(int0 = 0x201; int0 != 0x7fff; int0++)
233 c_int_gte_lit1(0xff);
238 void c_int_gte_lit2(unsigned char expected_result)
266 if(result != expected_result)
270 void int_compare2(void)
273 c_int_gte_lit2(0x01);
276 c_int_gte_lit2(0x03);
279 c_int_gte_lit2(0x07);
282 c_int_gte_lit2(0x0f);
285 c_int_gte_lit2(0x0f);
288 c_int_gte_lit2(0x0f);
291 c_int_gte_lit2(0x0f);
294 c_int_gte_lit2(0x0f);
297 c_int_gte_lit2(0x1f);
300 c_int_gte_lit2(0x3f);
303 c_int_gte_lit2(0x7f);
306 c_int_gte_lit2(0x7f);
309 c_int_gte_lit2(0xff);
312 c_int_gte_lit2(0xff);
315 c_int_gte_lit2(0xff);
318 c_int_gte_lit2(0xff);
320 /* now check contiguous ranges */
322 for(int0 = -0x7fff; int0 != -0x7f00; int0++)
323 c_int_gte_lit2(0x01);
325 for(int0 = -0x7e00; int0 != -0x101; int0++)
326 c_int_gte_lit2(0x0f);
328 for(int0 = -1; int0 != 0x7fff; int0++)
329 c_int_gte_lit2(0xff);