]> git.sur5r.net Git - cc65/blob - test/val/rotate3.c
goto.c warning fix for implicit truncation
[cc65] / test / val / rotate3.c
1 /*
2   !!DESCRIPTION!! Shift ints left and right
3   !!ORIGIN!!      SDCC regression tests
4   !!LICENCE!!     GPL, read COPYING.GPL
5 */
6
7 #include <stdio.h>
8 #include <limits.h>
9
10 unsigned char success=0;
11 unsigned char failures=0;
12 unsigned char dummy=0;
13
14 #ifdef SUPPORT_BIT_TYPES
15 bit bit0 = 0;
16 #endif
17 #ifdef SIZEOF_INT_16BIT
18 #if defined(__LINUX__) || defined(LINUX)
19 unsigned short aint0 = 0;
20 unsigned short aint1 = 0;
21
22 #else
23 unsigned int aint0 = 0;
24 unsigned int aint1 = 0;
25
26 #endif
27
28 #else
29 unsigned int aint0 = 0;
30 unsigned int aint1 = 0;
31
32 #endif
33 unsigned char achar0 = 0;
34 unsigned char achar1 = 0;
35 unsigned char achar2 = 0;
36 unsigned char achar3 = 0;
37
38 void done()
39 {
40   dummy++;
41 }
42
43 void shift_int_left_1(void)
44 {
45   aint0 <<= 1;
46 }
47
48 void shift_int_left_2(void)
49 {
50   aint0 <<= 2;
51 }
52
53 void shift_int_left_3(void)
54 {
55   aint0 <<= 3;
56 }
57
58 void shift_int_left_4(void)
59 {
60   aint0 <<= 4;
61 }
62
63 void shift_int_left_5(void)
64 {
65   aint0 <<= 5;
66 }
67
68 void shift_int_left_6(void)
69 {
70   aint0 <<= 6;
71 }
72
73 void shift_int_left_7(void)
74 {
75   aint0 <<= 7;
76 }
77
78 void shift_int_left_8(void)
79 {
80   aint0 <<= 8;
81 }
82
83 void shift_int_left_9(void)
84 {
85   aint0 <<= 9;
86 }
87
88 void shift_int_left_10(void)
89 {
90   aint0 <<= 10;
91 }
92
93 void shift_int_left_11(void)
94 {
95   aint0 <<= 11;
96 }
97
98 void shift_int_left_12(void)
99 {
100   aint0 <<= 12;
101 }
102
103 void shift_int_left_13(void)
104 {
105   aint0 <<= 13;
106 }
107
108 void shift_int_left_14(void)
109 {
110   aint0 <<= 14;
111 }
112
113 void shift_int_left_15(void)
114 {
115   aint0 <<= 15;
116 }
117
118 /*****************************************************/
119 void shift_int_right_1(void)
120 {
121   aint0 >>= 1;
122 }
123
124 void shift_int_right_2(void)
125 {
126   aint0 >>= 2;
127 }
128
129 void shift_int_right_3(void)
130 {
131   aint0 >>= 3;
132 }
133
134 void shift_int_right_4(void)
135 {
136   aint0 >>= 4;
137 }
138
139 void shift_int_right_5(void)
140 {
141   aint0 >>= 5;
142 }
143
144 void shift_int_right_6(void)
145 {
146   aint0 >>= 6;
147 }
148
149 void shift_int_right_7(void)
150 {
151   aint0 >>= 7;
152 }
153
154 void shift_int_right_8(void)
155 {
156   aint0 >>= 8;
157 }
158
159 void shift_int_right_9(void)
160 {
161   aint0 >>= 9;
162 }
163
164 void shift_int_right_10(void)
165 {
166   aint0 >>= 10;
167 }
168
169 void shift_int_right_11(void)
170 {
171   aint0 >>= 11;
172 }
173
174 void shift_int_right_12(void)
175 {
176   aint0 >>= 12;
177 }
178
179 void shift_int_right_13(void)
180 {
181   aint0 >>= 13;
182 }
183
184 void shift_int_right_14(void)
185 {
186   aint0 >>= 14;
187 }
188
189 void shift_int_right_15(void)
190 {
191   aint0 >>= 15;
192 }
193
194 /*****************************************************/
195 int main(void)
196 {
197   /*char i;*/
198   aint0 = 0xabcd;
199
200   shift_int_left_1();
201   if(aint0 != 0x579a)
202     failures++;
203
204   aint0 = 0xabcd;
205
206   shift_int_left_2();
207   if(aint0 != 0xaf34)
208     failures++;
209
210   aint0 = 0xabcd;
211
212   shift_int_left_3();
213   if(aint0 != 0x5e68)
214     failures++;
215
216   aint0 = 0xabcd;
217
218   shift_int_left_4();
219   if(aint0 != 0xbcd0)
220     failures++;
221
222   aint0 = 0xabcd;
223
224   shift_int_left_5();
225   if(aint0 != 0x79a0)
226     failures++;
227
228   aint0 = 0xabcd;
229
230   shift_int_left_6();
231   if(aint0 != 0xf340)
232     failures++;
233
234   aint0 = 0xabcd;
235
236   shift_int_left_7();
237   if(aint0 != 0xe680)
238     failures++;
239
240   aint0 = 0xabcd;
241
242   shift_int_left_8();
243   if(aint0 != 0xcd00)
244     failures++;
245
246   aint0 = 0xabcd;
247
248   shift_int_left_9();
249   if(aint0 != 0x9a00)
250     failures++;
251
252   aint0 = 0xabcd;
253
254   shift_int_left_10();
255   if(aint0 != 0x3400)
256     failures++;
257
258   aint0 = 0xabcd;
259
260   shift_int_left_11();
261   if(aint0 != 0x6800)
262     failures++;
263
264   aint0 = 0xabcd;
265
266   shift_int_left_12();
267   if(aint0 != 0xd000)
268     failures++;
269
270   aint0 = 0xabcd;
271
272   shift_int_left_13();
273   if(aint0 != 0xa000)
274     failures++;
275
276   aint0 = 0xabcd;
277
278   shift_int_left_14();
279   if(aint0 != 0x4000)
280     failures++;
281
282   aint0 = 0xabcd;
283
284   shift_int_left_15();
285   if(aint0 != 0x8000)
286     failures++;
287
288   /***********************/
289   aint0 = 0xabcd;
290
291   shift_int_right_1();
292   if(aint0 != 0x55e6)
293     failures++;
294
295   aint0 = 0xabcd;
296
297   shift_int_right_2();
298   if(aint0 != 0x2af3)
299     failures++;
300
301   aint0 = 0xabcd;
302
303   shift_int_right_3();
304   if(aint0 != 0x1579)
305     failures++;
306
307   aint0 = 0xabcd;
308
309   shift_int_right_4();
310   if(aint0 != 0x0abc)
311     failures++;
312
313   aint0 = 0xabcd;
314
315   shift_int_right_5();
316   if(aint0 != 0x055e)
317     failures++;
318
319   aint0 = 0xabcd;
320
321   shift_int_right_6();
322   if(aint0 != 0x02af)
323     failures++;
324
325   aint0 = 0xabcd;
326
327   shift_int_right_7();
328   if(aint0 != 0x0157)
329     failures++;
330
331   aint0 = 0xabcd;
332
333   shift_int_right_8();
334   if(aint0 != 0x00ab)
335     failures++;
336
337   aint0 = 0xabcd;
338
339   shift_int_right_9();
340   if(aint0 != 0x0055)
341     failures++;
342
343   aint0 = 0xabcd;
344
345   shift_int_right_10();
346   if(aint0 != 0x002a)
347     failures++;
348
349   aint0 = 0xabcd;
350
351   shift_int_right_11();
352   if(aint0 != 0x0015)
353     failures++;
354
355   aint0 = 0xabcd;
356
357   shift_int_right_12();
358   if(aint0 != 0x000a)
359     failures++;
360
361   aint0 = 0xabcd;
362
363   shift_int_right_13();
364   if(aint0 != 0x0005)
365     failures++;
366
367   aint0 = 0xabcd;
368
369   shift_int_right_14();
370   if(aint0 != 0x0002)
371     failures++;
372
373   aint0 = 0xabcd;
374
375   shift_int_right_15();
376   if(aint0 != 0x0001)
377     failures++;
378
379   success=failures;
380   done();
381   printf("failures: %d\n",failures);
382
383   return failures;
384 }