Steve Tell fixed a nested for-loop bug in the PIC Port
[fw/sdcc] / src / regression / and1.c
1 #define __16F873
2 #include "p16f873.h"
3
4 unsigned char success=0;
5 unsigned char failures=0;
6 unsigned char dummy=0;
7
8
9 unsigned int uint0 = 0;
10 unsigned int uint1 = 0;
11 unsigned char uchar0 = 0;
12 unsigned char uchar1 = 0;
13 unsigned long ulong0 = 0;
14
15 void done()
16 {
17
18   dummy++;
19
20 }
21
22 // uchar0 = 0xff;
23 void and_lit2uchar(void)
24 {
25
26   if(uchar0 != 0xff)
27     failures++;
28
29   uchar0 &= 0x7f;
30
31   if(uchar0 != 0x7f)
32     failures++;
33
34   uchar0 &= 0x3f;
35
36   if(uchar0 != 0x3f)
37     failures++;
38
39   uchar0 &= 0xdf;
40
41   if(uchar0 != 0x1f)
42     failures++;
43 }
44
45 void and_lit2uint(void)
46 {
47   if(uint0 != 0xffff)
48     failures++;
49
50   uint0 &= 0x7fff;
51
52   if(uint0 != 0x7fff)
53     failures++;
54
55   uint0 &= 0x3fff;
56
57   if(uint0 != 0x3fff)
58     failures++;
59
60   uint0 &= 0xdfff;
61
62   if(uint0 != 0x1fff)
63     failures++;
64
65
66   uint0 &= 0xff7f;
67
68   if(uint0 != 0x1f7f)
69     failures++;
70
71   uint0 &= 0x0f0f;
72
73   if(uint0 != 0x0f0f)
74     failures++;
75
76   uint0 &= 0xfefe;
77
78   if(uint0 != 0x0e0e)
79     failures++;
80
81   uint0 &= 0xf0f0;
82
83   if(uint0 != 0)
84     failures++;
85 }
86
87 void and_lit2ulong(void)
88 {
89
90   if(ulong0 != 0xffffffff)
91     failures++;
92
93   ulong0 &= 0x7fffffff;
94
95   if(ulong0 != 0x7fffffff)
96     failures++;
97
98   ulong0 &= 0xff00ffff;
99
100   if(ulong0 != 0x7f00ffff)
101     failures++;
102
103   ulong0 &= 0xfeff00ff;
104
105   if(ulong0 != 0x7e0000ff)
106     failures++;
107 }
108
109 /*-----------*/
110 void and_uchar2uchar(void)
111 {
112
113   uchar0 &= uchar1;
114
115   if(uchar0 != 0x0f)
116     failures++;
117
118   uchar1 &= 0xf7;
119
120   uchar0 = uchar1 & 0xfe;
121
122   if(uchar0 != 0x06)
123     failures++;
124
125 }
126
127 void main(void)
128 {
129
130   uchar0 = 0xff;
131   and_lit2uchar();
132
133   uint0 = 0xffff;
134   and_lit2uint();
135
136   ulong0 = 0xffffffff;
137   and_lit2ulong();
138
139   uchar0 = 0xff;
140   uchar1 = 0x0f;
141   and_uchar2uchar();
142
143   success = failures;
144   done();
145 }