1 #include "gpsim_assert.h"
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 failures = 0;
12 unsigned char result = 0;
16 signed char char0 = 0;
17 signed char char1 = 0;
19 /* *** NOTE *** This particular test takes quite a while to run
20 * ~ 10,000,000 instruction cycles. (2.5 seconds on a 20Mhz PIC).
21 * The WDT will reset the CPU if it's enabled. So disable it...
24 typedef unsigned int word;
26 //word at 0x2007 CONFIG = wdt_off & pwrte_on;
31 ASSERT(MANGLE(failures) == 0);
35 void c_char_lte_lit1(unsigned char expected_result)
54 if(result != expected_result)
59 void char_compare(void)
62 c_char_lte_lit1(0x10);
65 c_char_lte_lit1(0x10);
68 c_char_lte_lit1(0x10);
71 c_char_lte_lit1(0x10);
74 c_char_lte_lit1(0x18);
77 c_char_lte_lit1(0x1c);
80 c_char_lte_lit1(0x1e);
83 c_char_lte_lit1(0x1e);
86 c_char_lte_lit1(0x1e);
89 c_char_lte_lit1(0x1e);
92 c_char_lte_lit1(0x1f);
95 // c_char_lte_lit1(0x1f);
98 /* Now test entire range */
100 for(char0=2; char0 != 0x7f; char0++)
101 c_char_lte_lit1(0x10);
104 for(char0=-0x7e; char0 != 0; char0++)
105 c_char_lte_lit1(0x1e);
110 void c_int_lte_lit1(unsigned char expected_result)
139 if(result != expected_result)
145 void int_compare1(void)
148 c_int_lte_lit1(0xff);
151 c_int_lte_lit1(0xff);
154 c_int_lte_lit1(0xfe);
157 c_int_lte_lit1(0xfc);
160 c_int_lte_lit1(0xfc);
163 c_int_lte_lit1(0xfc);
166 c_int_lte_lit1(0xf8);
169 c_int_lte_lit1(0xf0);
172 c_int_lte_lit1(0xe0);
175 c_int_lte_lit1(0xe0);
178 c_int_lte_lit1(0xc0);
181 c_int_lte_lit1(0x80);
186 /* now check contiguous ranges */
188 for(int0 = -0x7fff; int0 != 1; int0++)
189 c_int_lte_lit1(0xff);
191 for(int0 = 2; int0 != 0xff; int0++)
192 c_int_lte_lit1(0xfc);
194 for(int0 = 0x202; int0 != 0x7fff; int0++)
201 void c_int_lte_lit2(unsigned char expected_result)
229 if(result != expected_result)
233 void int_compare2(void)
236 c_int_lte_lit2(0xff);
239 c_int_lte_lit2(0xfe);
242 c_int_lte_lit2(0xfc);
245 c_int_lte_lit2(0xf8);
248 c_int_lte_lit2(0xf0);
251 c_int_lte_lit2(0xf0);
254 c_int_lte_lit2(0xf0);
257 c_int_lte_lit2(0xf0);
260 c_int_lte_lit2(0xe0);
263 c_int_lte_lit2(0xc0);
266 c_int_lte_lit2(0x80);
269 c_int_lte_lit2(0x80);
272 c_int_lte_lit2(0x00);
275 c_int_lte_lit2(0x00);
278 c_int_lte_lit2(0x00);
280 /* now check contiguous ranges */
282 for(int0 = -0x7ffe; int0 != -0x7f00; int0++)
283 c_int_lte_lit2(0xfe);
285 for(int0 = -0x7dff; int0 != -0x101; int0++)
286 c_int_lte_lit2(0xf0);
288 for(int0 = 0; int0 != 0x7fff; int0++)