Imported Upstream version 2.9.0
[debian/cc1111] / src / regression / and2.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 = 0x13;
20 void and_compound1(void)
21 {
22   uchar0 = (uchar0 + 1) & 0x0f;
23   if(uchar0 != 4)
24     failures++;
25 }
26
27
28 // uchar1 = 0x42;
29 void and_compound2(void)
30 {
31   uchar0 = (uchar1 + 1) & 0x0f;
32   if(uchar0 != 3)
33     failures++;
34
35   if(uchar1 != 0x42)
36     failures++;
37 }
38
39 // uchar0 = 0x13;
40 void or_compound1(void)
41 {
42   uchar0 = (uchar0 + 0xe) | 0x0f;
43   if(uchar0 != 0x2f)
44     failures++;
45 }
46
47
48 // uchar1 = 0x47;
49 void or_compound2(void)
50 {
51   uchar0 = (uchar1 + 0xf) | 0x0f;
52   if(uchar0 != 0x5f)
53     failures++;
54
55   if(uchar1 != 0x47)
56     failures++;
57 }
58
59
60
61 // uchar0 = 0x13;
62 void xor_compound1(void)
63 {
64   uchar0 = (uchar0 + 1) ^ 0x0f;
65   if(uchar0 != 0x1b)
66     failures++;
67 }
68
69
70 // uchar1 = 0x47;
71 void xor_compound2(void)
72 {
73   uchar0 = (uchar1 + 0xf) ^ 0x0f;
74   if(uchar0 != 0x59)
75     failures++;
76
77   if(uchar1 != 0x47)
78     failures++;
79 }
80
81 // uchar0 = 0x13;
82 void neg_compound1(void)
83 {
84   uchar0 = ~(uchar0 + 1);
85   if(uchar0 != 0xeb)
86     failures++;
87 }
88
89
90 void main(void)
91 {
92
93   uchar0 = 0x13;
94   and_compound1();
95
96   uchar1 = 0x42;
97   and_compound2();
98
99   uchar0 = 0x13;
100   or_compound1();
101
102   uchar1 = 0x47;
103   or_compound2();
104
105   uchar0 = 0x13;
106   xor_compound1();
107
108   uchar1 = 0x47;
109   xor_compound2();
110
111   uchar0 = 0x13;
112   neg_compound1();
113
114   done();
115 }