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