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 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;
17 unsigned char uchar0 = 0;
18 unsigned char uchar1 = 0;
19 signed char char0 = 0;
20 signed char char1 = 0;
24 /* *** NOTE *** This particular test takes quite a while to run
25 * ~ 10,000,000 instruction cycles. (2.5 seconds on a 20Mhz PIC).
26 * The WDT will reset the CPU if it's enabled. So disable it...
29 typedef unsigned int word;
31 //word at 0x2007 CONFIG = wdt_off & pwrte_on;
36 ASSERT(MANGLE(failures) == 0);
41 void c_char_gte_lit1(unsigned char expected_result)
64 if(result != expected_result)
69 void char_compare(void)
72 c_char_gte_lit1(0x3f);
75 c_char_gte_lit1(0x1f);
78 c_char_gte_lit1(0x0f);
81 c_char_gte_lit1(0x0f);
84 c_char_gte_lit1(0x0f);
87 c_char_gte_lit1(0x07);
90 c_char_gte_lit1(0x03);
93 c_char_gte_lit1(0x01);
96 c_char_gte_lit1(0x01);
99 c_char_gte_lit1(0x01);
102 c_char_gte_lit1(0x01);
105 c_char_gte_lit1(0x00);
108 /* Now test entire range */
110 for(char0=1; char0 != 0x7e; char0++)
111 c_char_gte_lit1(0x0f);
113 for(char0=-0x7f; char0 != -1; char0++)
114 c_char_gte_lit1(0x01);
119 void c_int_gte_lit1(unsigned char expected_result)
148 if(result != expected_result)
154 void int_compare1(void)
157 c_int_gte_lit1(0x00);
160 c_int_gte_lit1(0x01);
163 c_int_gte_lit1(0x03);
166 c_int_gte_lit1(0x03);
169 c_int_gte_lit1(0x03);
172 c_int_gte_lit1(0x07);
175 c_int_gte_lit1(0x0f);
178 c_int_gte_lit1(0x1f);
181 c_int_gte_lit1(0x1f);
184 c_int_gte_lit1(0x1f);
187 c_int_gte_lit1(0x3f);
190 c_int_gte_lit1(0x7f);
193 c_int_gte_lit1(0xff);
196 c_int_gte_lit1(0xff);
198 /* now check contiguous ranges */
200 for(int0 = -0x7fff; int0 != -1; int0++)
201 c_int_gte_lit1(0x00);
203 for(int0 = 1; int0 != 0xff; int0++)
204 c_int_gte_lit1(0x03);
206 for(int0 = 0x201; int0 != 0x7fff; int0++)
207 c_int_gte_lit1(0xff);
212 void c_int_gte_lit2(unsigned char expected_result)
240 if(result != expected_result)
244 void int_compare2(void)
247 c_int_gte_lit2(0x01);
250 c_int_gte_lit2(0x03);
253 c_int_gte_lit2(0x07);
256 c_int_gte_lit2(0x0f);
259 c_int_gte_lit2(0x0f);
262 c_int_gte_lit2(0x0f);
265 c_int_gte_lit2(0x0f);
268 c_int_gte_lit2(0x0f);
271 c_int_gte_lit2(0x1f);
274 c_int_gte_lit2(0x3f);
277 c_int_gte_lit2(0x7f);
280 c_int_gte_lit2(0x7f);
283 c_int_gte_lit2(0xff);
286 c_int_gte_lit2(0xff);
289 c_int_gte_lit2(0xff);
292 c_int_gte_lit2(0xff);
294 /* now check contiguous ranges */
296 for(int0 = -0x7fff; int0 != -0x7f00; int0++)
297 c_int_gte_lit2(0x01);
299 for(int0 = -0x7e00; int0 != -0x101; int0++)
300 c_int_gte_lit2(0x0f);
302 for(int0 = -1; int0 != 0x7fff; int0++)
303 c_int_gte_lit2(0xff);