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 signed char char0 = 0;
18 signed char char1 = 0;
23 /* copied from 16f877.inc file supplied with gpasm */
25 #define _CP_ALL 0x0FCF
26 #define _CP_HALF 0x1FDF
27 #define _CP_UPPER_256 0x2FEF
28 #define _CP_OFF 0x3FFF
29 #define _DEBUG_ON 0x37FF
30 #define _DEBUG_OFF 0x3FFF
31 #define _WRT_ENABLE_ON 0x3FFF
32 #define _WRT_ENABLE_OFF 0x3DFF
33 #define _CPD_ON 0x3EFF
34 #define _CPD_OFF 0x3FFF
35 #define _LVP_ON 0x3FFF
36 #define _LVP_OFF 0x3F7F
37 #define _BODEN_ON 0x3FFF
38 #define _BODEN_OFF 0x3FBF
39 #define _PWRTE_OFF 0x3FFF
40 #define _PWRTE_ON 0x3FF7
41 #define _WDT_ON 0x3FFF
42 #define _WDT_OFF 0x3FFB
43 #define _LP_OSC 0x3FFC
44 #define _XT_OSC 0x3FFD
45 #define _HS_OSC 0x3FFE
46 #define _RC_OSC 0x3FFF
48 /* *** NOTE *** This particular test takes quite a while to run
49 * ~ 10,000,000 instruction cycles. (2.5 seconds on a 20Mhz PIC).
50 * The WDT will reset the CPU if it's enabled. So disable it...
53 typedef unsigned int word;
55 word at 0x2007 CONFIG = _WDT_OFF & _PWRTE_ON;
64 void c_char_lt_lit1(unsigned char expected_result)
84 if(result != expected_result)
89 void char_compare(void)
101 c_char_lt_lit1(0x10);
104 c_char_lt_lit1(0x10);
107 c_char_lt_lit1(0x18);
110 c_char_lt_lit1(0x1c);
113 c_char_lt_lit1(0x1e);
116 c_char_lt_lit1(0x1e);
119 c_char_lt_lit1(0x1e);
122 c_char_lt_lit1(0x1e);
125 c_char_lt_lit1(0x1f);
128 /* Now test entire range */
130 for(char0=1; char0 != 0x7f; char0++)
131 c_char_lt_lit1(0x10);
134 for(char0=-0x7f; char0 != -1; char0++)
135 c_char_lt_lit1(0x1e);
140 void c_int_lt_lit1(unsigned char expected_result)
169 if(result != expected_result)
175 void int_compare1(void)
216 /* now check contiguous ranges */
218 for(int0 = -0x7fff; int0 != -1; int0++)
221 for(int0 = 1; int0 != 0xff; int0++)
224 for(int0 = 0x201; int0 != 0x7fff; int0++)
231 void c_int_lt_lit2(unsigned char expected_result)
259 if(result != expected_result)
263 void int_compare2(void)
310 /* now check contiguous ranges */
314 for(int0 = -0x7ffe; int0 != -0x7f01; int0++)
317 for(int0 = -0x7e00; int0 != -0x101; int0++)
320 for(int0 = -1; int0 != 0x7fff; int0++)