1 #include "gpsim_assert.h"
4 // Signed comparisons of the form: (variable>=LIT)
6 // This regression test exercises all of the boundary
7 // conditions in literal less than comparisons. There
8 // are numerous opportunities to optimize these comparison
9 // and each one has an astonishing capability of failing
10 // a boundary condition.
12 unsigned char failures = 0;
13 unsigned char result = 0;
18 unsigned char uchar0 = 0;
19 unsigned char uchar1 = 0;
20 signed char char0 = 0;
21 signed char char1 = 0;
25 /* *** NOTE *** This particular test takes quite a while to run
26 * ~ 10,000,000 instruction cycles. (2.5 seconds on a 20Mhz PIC).
27 * The WDT will reset the CPU if it's enabled. So disable it...
30 typedef unsigned int word;
32 //word at 0x2007 CONFIG = wdt_off & pwrte_on;
37 ASSERT(MANGLE(failures) == 0);
42 void c_char_gte_lit1(unsigned char expected_result)
65 if(result != expected_result)
70 void char_compare(void)
73 c_char_gte_lit1(0x3f);
76 c_char_gte_lit1(0x1f);
79 c_char_gte_lit1(0x0f);
82 c_char_gte_lit1(0x0f);
85 c_char_gte_lit1(0x0f);
88 c_char_gte_lit1(0x07);
91 c_char_gte_lit1(0x03);
94 c_char_gte_lit1(0x01);
97 c_char_gte_lit1(0x01);
100 c_char_gte_lit1(0x01);
103 c_char_gte_lit1(0x01);
106 c_char_gte_lit1(0x00);
109 /* Now test entire range */
111 for(char0=1; char0 != 0x7e; char0++)
112 c_char_gte_lit1(0x0f);
114 for(char0=-0x7f; char0 != -1; char0++)
115 c_char_gte_lit1(0x01);
120 void c_int_gte_lit1(unsigned char expected_result)
149 if(result != expected_result)
155 void int_compare1(void)
158 c_int_gte_lit1(0x00);
161 c_int_gte_lit1(0x01);
164 c_int_gte_lit1(0x03);
167 c_int_gte_lit1(0x03);
170 c_int_gte_lit1(0x03);
173 c_int_gte_lit1(0x07);
176 c_int_gte_lit1(0x0f);
179 c_int_gte_lit1(0x1f);
182 c_int_gte_lit1(0x1f);
185 c_int_gte_lit1(0x1f);
188 c_int_gte_lit1(0x3f);
191 c_int_gte_lit1(0x7f);
194 c_int_gte_lit1(0xff);
197 c_int_gte_lit1(0xff);
199 /* now check contiguous ranges */
201 for(int0 = -0x7fff; int0 != -1; int0++)
202 c_int_gte_lit1(0x00);
204 for(int0 = 1; int0 != 0xff; int0++)
205 c_int_gte_lit1(0x03);
207 for(int0 = 0x201; int0 != 0x7fff; int0++)
208 c_int_gte_lit1(0xff);
213 void c_int_gte_lit2(unsigned char expected_result)
241 if(result != expected_result)
245 void int_compare2(void)
248 c_int_gte_lit2(0x01);
251 c_int_gte_lit2(0x03);
254 c_int_gte_lit2(0x07);
257 c_int_gte_lit2(0x0f);
260 c_int_gte_lit2(0x0f);
263 c_int_gte_lit2(0x0f);
266 c_int_gte_lit2(0x0f);
269 c_int_gte_lit2(0x0f);
272 c_int_gte_lit2(0x1f);
275 c_int_gte_lit2(0x3f);
278 c_int_gte_lit2(0x7f);
281 c_int_gte_lit2(0x7f);
284 c_int_gte_lit2(0xff);
287 c_int_gte_lit2(0xff);
290 c_int_gte_lit2(0xff);
293 c_int_gte_lit2(0xff);
295 /* now check contiguous ranges */
297 for(int0 = -0x7fff; int0 != -0x7f00; int0++)
298 c_int_gte_lit2(0x01);
300 for(int0 = -0x7e00; int0 != -0x101; int0++)
301 c_int_gte_lit2(0x0f);
303 for(int0 = -1; int0 != 0x7fff; int0++)
304 c_int_gte_lit2(0xff);