]> git.sur5r.net Git - cc65/blob - test/val/and2.c
Added missing pointer star for Basic structure.
[cc65] / test / val / and2.c
1 /*
2   !!DESCRIPTION!!
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 unsigned int uint0 = 0;
15 unsigned int uint1 = 0;
16 unsigned char uchar0 = 0;
17 unsigned char uchar1 = 0;
18 unsigned long ulong0 = 0;
19
20 void done()
21 {
22   dummy++;
23 }
24
25 /* uchar0 = 0x13; */
26 void and_compound1(void)
27 {
28   uchar0 = (uchar0 + 1) & 0x0f;
29   if(uchar0 != 4)
30     failures++;
31 }
32
33 /* uchar1 = 0x42; */
34 void and_compound2(void)
35 {
36   uchar0 = (uchar1 + 1) & 0x0f;
37   if(uchar0 != 3)
38     failures++;
39
40   if(uchar1 != 0x42)
41     failures++;
42 }
43
44 /* uchar0 = 0x13; */
45 void or_compound1(void)
46 {
47   uchar0 = (uchar0 + 0xe) | 0x0f;
48   if(uchar0 != 0x2f)
49     failures++;
50 }
51
52 /* uchar1 = 0x47; */
53 void or_compound2(void)
54 {
55   uchar0 = (uchar1 + 0xf) | 0x0f;
56   if(uchar0 != 0x5f)
57     failures++;
58
59   if(uchar1 != 0x47)
60     failures++;
61 }
62
63 /* uchar0 = 0x13; */
64 void xor_compound1(void)
65 {
66   uchar0 = (uchar0 + 1) ^ 0x0f;
67   if(uchar0 != 0x1b)
68     failures++;
69 }
70
71 /* uchar1 = 0x47; */
72 void xor_compound2(void)
73 {
74   uchar0 = (uchar1 + 0xf) ^ 0x0f;
75   if(uchar0 != 0x59)
76     failures++;
77
78   if(uchar1 != 0x47)
79     failures++;
80 }
81
82 /* uchar0 = 0x13; */
83 void neg_compound1(void)
84 {
85   uchar0 = ~(uchar0 + 1);
86   if(uchar0 != 0xeb)
87     failures++;
88 }
89
90 int main(void)
91 {
92   uchar0 = 0x13;
93   and_compound1();
94
95   uchar1 = 0x42;
96   and_compound2();
97
98   uchar0 = 0x13;
99   or_compound1();
100
101   uchar1 = 0x47;
102   or_compound2();
103
104   uchar0 = 0x13;
105   xor_compound1();
106
107   uchar1 = 0x47;
108   xor_compound2();
109
110   uchar0 = 0x13;
111   neg_compound1();
112
113   success = failures;
114   done();
115   printf("failures: %d\n",failures);
116
117   return failures;
118 }