1 // Signed comparisons of the form: (variable>LIT)
3 // This regression test exercises all of the boundary
4 // conditions in literal less than 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;
17 unsigned char uchar0 = 0;
18 unsigned char uchar1 = 0;
19 signed char char0 = 0;
20 signed char char1 = 0;
25 /* copied from 16f877.inc file supplied with gpasm */
27 #define _CP_ALL 0x0FCF
28 #define _CP_HALF 0x1FDF
29 #define _CP_UPPER_256 0x2FEF
30 #define _CP_OFF 0x3FFF
31 #define _DEBUG_ON 0x37FF
32 #define _DEBUG_OFF 0x3FFF
33 #define _WRT_ENABLE_ON 0x3FFF
34 #define _WRT_ENABLE_OFF 0x3DFF
35 #define _CPD_ON 0x3EFF
36 #define _CPD_OFF 0x3FFF
37 #define _LVP_ON 0x3FFF
38 #define _LVP_OFF 0x3F7F
39 #define _BODEN_ON 0x3FFF
40 #define _BODEN_OFF 0x3FBF
41 #define _PWRTE_OFF 0x3FFF
42 #define _PWRTE_ON 0x3FF7
43 #define _WDT_ON 0x3FFF
44 #define _WDT_OFF 0x3FFB
45 #define _LP_OSC 0x3FFC
46 #define _XT_OSC 0x3FFD
47 #define _HS_OSC 0x3FFE
48 #define _RC_OSC 0x3FFF
50 /* *** NOTE *** This particular test takes quite a while to run
51 * ~ 10,000,000 instruction cycles. (2.5 seconds on a 20Mhz PIC).
52 * The WDT will reset the CPU if it's enabled. So disable it...
55 typedef unsigned int word;
57 word at 0x2007 CONFIG = _WDT_OFF & _PWRTE_ON;
66 void c_char_gt_lit1(unsigned char expected_result)
89 if(result != expected_result)
94 void char_compare(void)
100 c_char_gt_lit1(0x0f);
103 c_char_gt_lit1(0x0f);
106 c_char_gt_lit1(0x0f);
109 c_char_gt_lit1(0x07);
112 c_char_gt_lit1(0x03);
115 c_char_gt_lit1(0x01);
118 c_char_gt_lit1(0x01);
121 c_char_gt_lit1(0x01);
124 c_char_gt_lit1(0x01);
127 c_char_gt_lit1(0x00);
130 c_char_gt_lit1(0x00);
133 /* Now test entire range */
135 for(char0=2; char0 != 0x7f; char0++)
136 c_char_gt_lit1(0x0f);
139 for(char0=-0x7e; char0 != -1; char0++)
140 c_char_gt_lit1(0x01);
146 void c_int_gt_lit1(unsigned char expected_result)
175 if(result != expected_result)
181 void int_compare1(void)
225 /* now check contiguous ranges */
227 for(int0 = -0x7fff; int0 != -1; int0++)
230 for(int0 = 2; int0 != 0xff; int0++)
233 for(int0 = 0x202; int0 != 0x7fff; int0++)
239 void c_int_gt_lit2(unsigned char expected_result)
267 if(result != expected_result)
271 void int_compare2(void)
321 /* now check contiguous ranges */
323 for(int0 = -0x7ffe; int0 != -0x7f01; int0++)
326 for(int0 = -0x7dff; int0 != -0x101; int0++)
329 for(int0 = 0; int0 != 0x7fff; int0++)