]> git.sur5r.net Git - cc65/blob - test/val/rotate7.c
Fixed addressing error for TSB/TSR and enabled tests again.
[cc65] / test / val / rotate7.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 SIZEOF_INT_16BIT
15 #if defined(__LINUX__) || defined(LINUX)
16 signed short aint0 = 0;
17 signed short aint1 = 0;
18
19 #else
20 signed int aint0 = 0;
21 signed int aint1 = 0;
22
23 #endif
24
25 #else
26 signed int aint0 = 0;
27 signed int aint1 = 0;
28
29 #endif
30
31 /*
32 signed char achar0 = 0;
33 signed char achar1 = 0;
34 signed char achar2 = 0;
35 signed char achar3 = 0;
36 */
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
196 main (void)
197 {
198   aint0 = 0xabcd;
199
200   shift_int_left_1();
201   if(aint0 != 0x579a)
202     failures++;
203   printf("failures: %d\n",failures);
204
205   aint0 = 0xabcd;
206
207   shift_int_left_2();
208   if((unsigned short)aint0 != 0xaf34)
209     failures++;
210   printf("failures: %d\n",failures);
211
212   aint0 = 0xabcd;
213
214   shift_int_left_3();
215   if(aint0 != 0x5e68)
216     failures++;
217   printf("failures: %d\n",failures);
218
219   aint0 = 0xabcd;
220
221   shift_int_left_4();
222   if((unsigned short)aint0 != 0xbcd0)
223     failures++;
224   printf("failures: %d\n",failures);
225
226   aint0 = 0xabcd;
227
228   shift_int_left_5();
229   if(aint0 != 0x79a0)
230     failures++;
231   printf("failures: %d\n",failures);
232
233   aint0 = 0xabcd;
234
235   shift_int_left_6();
236   if((unsigned short)aint0 != 0xf340)
237     failures++;
238   printf("failures: %d\n",failures);
239
240   aint0 = 0xabcd;
241
242   shift_int_left_7();
243   if((unsigned short)aint0 != 0xe680)
244     failures++;
245   printf("failures: %d\n",failures);
246
247   aint0 = 0xabcd;
248
249   shift_int_left_8();
250   if((unsigned short)aint0 != 0xcd00)
251     failures++;
252   printf("failures: %d\n",failures);
253
254   aint0 = 0xabcd;
255
256   shift_int_left_9();
257   if((unsigned short)aint0 != 0x9a00)
258     failures++;
259   printf("failures: %d\n",failures);
260
261   aint0 = 0xabcd;
262
263   shift_int_left_10();
264   if(aint0 != 0x3400)
265     failures++;
266   printf("failures: %d\n",failures);
267
268   aint0 = 0xabcd;
269
270   shift_int_left_11();
271   if(aint0 != 0x6800)
272     failures++;
273   printf("failures: %d\n",failures);
274
275   aint0 = 0xabcd;
276
277   shift_int_left_12();
278   if((unsigned short)aint0 != 0xd000)
279     failures++;
280   printf("failures: %d\n",failures);
281
282   aint0 = 0xabcd;
283
284   shift_int_left_13();
285   if((unsigned short)aint0 != 0xa000)
286     failures++;
287   printf("failures: %d\n",failures);
288
289   aint0 = 0xabcd;
290
291   shift_int_left_14();
292   if(aint0 != 0x4000)
293     failures++;
294   printf("failures: %d\n",failures);
295
296   aint0 = 0xabcd;
297
298   shift_int_left_15();
299   if((unsigned short)aint0 != 0x8000)
300     failures++;
301   printf("failures: %d\n",failures);
302
303   /***********************/
304   aint0 = 0xabcd;
305
306   shift_int_right_1();
307   if((unsigned short)aint0 != 0xd5e6)
308     failures++;
309   printf("failures: %d\n",failures);
310
311   aint0 = 0xabcd;
312
313   shift_int_right_2();
314   if((unsigned short)aint0 != 0xeaf3)
315     failures++;
316   printf("failures: %d\n",failures);
317
318   aint0 = 0xabcd;
319
320   shift_int_right_3();
321   if((unsigned short)aint0 != 0xf579)
322     failures++;
323   printf("failures: %d\n",failures);
324
325   aint0 = 0xabcd;
326
327   shift_int_right_4();
328   if((unsigned short)aint0 != 0xfabc)
329     failures++;
330   printf("failures: %d\n",failures);
331
332   aint0 = 0xabcd;
333
334   shift_int_right_5();
335   if((unsigned short)aint0 != 0xfd5e)
336     failures++;
337   printf("failures: %d\n",failures);
338
339   aint0 = 0xabcd;
340
341   shift_int_right_6();
342   if((unsigned short)aint0 != 0xfeaf)
343     failures++;
344   printf("failures: %d\n",failures);
345
346   aint0 = 0xabcd;
347
348   shift_int_right_7();
349   if((unsigned short)aint0 != 0xff57)
350     failures++;
351   printf("failures: %d\n",failures);
352
353   aint0 = 0xabcd;
354
355   shift_int_right_8();
356   if((unsigned short)aint0 != 0xffab)
357     failures++;
358   printf("failures: %d\n",failures);
359
360   aint0 = 0xabcd;
361
362   shift_int_right_9();
363   if((unsigned short)aint0 != 0xffd5)
364     failures++;
365   printf("failures: %d\n",failures);
366
367   aint0 = 0xabcd;
368
369   shift_int_right_10();
370   if((unsigned short)aint0 != 0xffea)
371     failures++;
372   printf("failures: %d\n",failures);
373
374   aint0 = 0xabcd;
375
376   shift_int_right_11();
377   if((unsigned short)aint0 != 0xfff5)
378     failures++;
379   printf("failures: %d\n",failures);
380
381   aint0 = 0xabcd;
382
383   shift_int_right_12();
384   if((unsigned short)aint0 != 0xfffa)
385     failures++;
386   printf("failures: %d\n",failures);
387
388   aint0 = 0xabcd;
389
390   shift_int_right_13();
391   if((unsigned short)aint0 != 0xfffd)
392     failures++;
393   printf("failures: %d\n",failures);
394
395   aint0 = 0xabcd;
396
397   shift_int_right_14();
398   if((unsigned short)aint0 != 0xfffe)
399     failures++;
400   printf("failures: %d\n",failures);
401
402   aint0 = 0xabcd;
403
404   shift_int_right_15();
405   if(aint0 != -1)
406     failures++;
407
408   success=failures;
409   done();
410   printf("failures: %d\n",failures);
411
412   return failures;
413 }