1 /** Simple test for the mul/div/mod operations.
3 type: int, char, short, long
10 testUnsignedModDiv(void)
12 #ifndef __SDCC_pdk14 // Lack of memory
13 #if !(defined (__SDCC_pdk15) && defined(__SDCC_STACK_AUTO)) // Lack of code memory
14 {attr
} {storage
} unsigned {type
} i
;
15 unsigned {type
} result
;
37 #ifndef __SDCC_pdk14 // Lack of memory
38 {attr
} {storage
} unsigned {type
} i
;
39 unsigned {type
} result
;
43 LOG(("i*3 == 111 = %u\n", (int)(i
*3)));
45 ASSERT(result
== 111);
48 ASSERT(result
== ((unsigned {type
})444));
55 #ifndef __SDCC_pdk14 // Lack of memory
56 #if !(defined (__SDCC_pdk15) && defined(__SDCC_STACK_AUTO)) // Lack of code memory
57 {attr
} {storage
} signed {type
} i
;
62 LOG(("i*5 == 25 = %d\n", (int)(i
*5)));
65 LOG(("i*-4 == -20 = %d\n", (int)(i
*-4)));
69 LOG(("i*12 == -120 = %d\n", (int)(i
*12)));
71 LOG(("i*-3 == 30 = %d\n", (int)(i
*-3)));
85 #if !defined(__SDCC_pdk14) && !defined(__SDCC_pdk15) // Lack of memory
86 {attr
} {storage
} signed {type
} i
;
89 LOG(("i/5 == 20 = %d\n", (int)i
/5));
91 LOG(("i/-4 == -25 = %d\n", (int)i
/-4));
96 LOG(("i/25 == -2 = %d\n", (int)i
/25));
98 LOG(("i/-12 == 4 = %d\n", (int)i
/-12));
108 #if !defined(__SDCC_pdk14) && !defined(__SDCC_pdk15) // Lack of memory
109 {attr
} {storage
} int i
, j
;
110 {attr
} {storage
} unsigned int ui
, uj
;
114 ASSERT((long)i
* (long)j
== 42l * 42l);
116 ASSERT((long)i
* (long)j
== -42l * 42l);
118 ASSERT((long)i
* (long)j
== -42l * -42l);
121 ASSERT((unsigned long)i
* (unsigned long)j
== 2342ul * 4223ul);
122 ASSERT((long)i
* (long)j
== 2342l * 4223l);
124 ASSERT((long)i
* (long)j
== 2342l * -4223l);
126 ASSERT((long)i
* (long)j
== -2342l * -4223l);
130 ASSERT((unsigned long)ui
* (unsigned long)uj
== 42ul * 42ul);
133 ASSERT((unsigned long)ui
* (unsigned long)uj
== 2342ul * 4223ul);
136 ASSERT((unsigned long)ui
* (unsigned long)uj
== 0xfffful
* 0x8000ul
);
143 #if !defined(__SDCC_pdk14) && !defined(__SDCC_pdk15) // Lack of memory
144 {attr
} {storage
} signed {type
} i
;
146 // Disabled the LOG functions due to a bug in sdcc involving
149 // LOG(("i%%17 == 15 = %u\n", (int)(i%9)));
151 ASSERT(i
%(unsigned char)19 == 5);
153 // LOG(("i%%-7 == 2 = %u\n", (int)i%-7));
159 // LOG(("i%%3 == -1 = %u\n", (int)i%3));
161 // LOG(("i%%-5 == -4 = %u\n", (int)i%-5));