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