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;
27 /* copied from 16f877.inc file supplied with gpasm */
29 #define _CP_ALL 0x0FCF
30 #define _CP_HALF 0x1FDF
31 #define _CP_UPPER_256 0x2FEF
32 #define _CP_OFF 0x3FFF
33 #define _DEBUG_ON 0x37FF
34 #define _DEBUG_OFF 0x3FFF
35 #define _WRT_ENABLE_ON 0x3FFF
36 #define _WRT_ENABLE_OFF 0x3DFF
37 #define _CPD_ON 0x3EFF
38 #define _CPD_OFF 0x3FFF
39 #define _LVP_ON 0x3FFF
40 #define _LVP_OFF 0x3F7F
41 #define _BODEN_ON 0x3FFF
42 #define _BODEN_OFF 0x3FBF
43 #define _PWRTE_OFF 0x3FFF
44 #define _PWRTE_ON 0x3FF7
45 #define _WDT_ON 0x3FFF
46 #define _WDT_OFF 0x3FFB
47 #define _LP_OSC 0x3FFC
48 #define _XT_OSC 0x3FFD
49 #define _HS_OSC 0x3FFE
50 #define _RC_OSC 0x3FFF
52 /* *** NOTE *** This particular test takes quite a while to run
53 * ~ 10,000,000 instruction cycles. (2.5 seconds on a 20Mhz PIC).
54 * The WDT will reset the CPU if it's enabled. So disable it...
57 typedef unsigned int word;
59 word at 0x2007 CONFIG = _WDT_OFF & _PWRTE_ON;
68 void c_char_gt_lit1(unsigned char expected_result)
91 if(result != expected_result)
96 void char_compare(void)
102 c_char_gt_lit1(0x0f);
105 c_char_gt_lit1(0x0f);
108 c_char_gt_lit1(0x0f);
111 c_char_gt_lit1(0x07);
114 c_char_gt_lit1(0x03);
117 c_char_gt_lit1(0x01);
120 c_char_gt_lit1(0x01);
123 c_char_gt_lit1(0x01);
126 c_char_gt_lit1(0x01);
129 c_char_gt_lit1(0x00);
132 c_char_gt_lit1(0x00);
135 /* Now test entire range */
137 for(char0=2; char0 != 0x7f; char0++)
138 c_char_gt_lit1(0x0f);
141 for(char0=-0x7e; char0 != -1; char0++)
142 c_char_gt_lit1(0x01);
148 void c_int_gt_lit1(unsigned char expected_result)
177 if(result != expected_result)
183 void int_compare1(void)
227 /* now check contiguous ranges */
229 for(int0 = -0x7fff; int0 != -1; int0++)
232 for(int0 = 2; int0 != 0xff; int0++)
235 for(int0 = 0x202; int0 != 0x7fff; int0++)
241 void c_int_gt_lit2(unsigned char expected_result)
269 if(result != expected_result)
273 void int_compare2(void)
323 /* now check contiguous ranges */
325 for(int0 = -0x7ffe; int0 != -0x7f01; int0++)
328 for(int0 = -0x7dff; int0 != -0x101; int0++)
331 for(int0 = 0; int0 != 0x7fff; int0++)