annotate test/bitfield1.c @ 449:c55363eff5e5

parallel assignment (modify not completed)
author kono
date Thu, 25 Nov 2004 16:56:26 +0900
parents 61c77ff18023
children 32737bad7489
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
336
d488b72254fb bit-field done.
kono
parents:
diff changeset
1
d488b72254fb bit-field done.
kono
parents:
diff changeset
2 struct aho {
d488b72254fb bit-field done.
kono
parents:
diff changeset
3 int i:1,j:1;
d488b72254fb bit-field done.
kono
parents:
diff changeset
4 char a:7;
d488b72254fb bit-field done.
kono
parents:
diff changeset
5 char :7,k:1,:3;
d488b72254fb bit-field done.
kono
parents:
diff changeset
6 long long v:33;
d488b72254fb bit-field done.
kono
parents:
diff changeset
7 long long w:33;
d488b72254fb bit-field done.
kono
parents:
diff changeset
8 long long x:33;
d488b72254fb bit-field done.
kono
parents:
diff changeset
9 } a /* = {-1,3,3,3,3} */ ;
d488b72254fb bit-field done.
kono
parents:
diff changeset
10
d488b72254fb bit-field done.
kono
parents:
diff changeset
11 union aho1 {
d488b72254fb bit-field done.
kono
parents:
diff changeset
12 int i:1,j:1;
d488b72254fb bit-field done.
kono
parents:
diff changeset
13 char a:7;
d488b72254fb bit-field done.
kono
parents:
diff changeset
14 char :7,k:1,:3;
d488b72254fb bit-field done.
kono
parents:
diff changeset
15 long long v:33;
d488b72254fb bit-field done.
kono
parents:
diff changeset
16 long long w:33;
d488b72254fb bit-field done.
kono
parents:
diff changeset
17 long long x:33;
d488b72254fb bit-field done.
kono
parents:
diff changeset
18 } a11 ;
d488b72254fb bit-field done.
kono
parents:
diff changeset
19
d488b72254fb bit-field done.
kono
parents:
diff changeset
20 union ll1 {
337
694cdf15c5bd MIPS bit-field done.
kono
parents: 336
diff changeset
21 unsigned char a[32];
336
d488b72254fb bit-field done.
kono
parents:
diff changeset
22 struct {
d488b72254fb bit-field done.
kono
parents:
diff changeset
23 char a:4;
d488b72254fb bit-field done.
kono
parents:
diff changeset
24 long long v:33;
d488b72254fb bit-field done.
kono
parents:
diff changeset
25 long long w:33;
d488b72254fb bit-field done.
kono
parents:
diff changeset
26 long long x:33;
d488b72254fb bit-field done.
kono
parents:
diff changeset
27 } b;
d488b72254fb bit-field done.
kono
parents:
diff changeset
28 } ll1;
d488b72254fb bit-field done.
kono
parents:
diff changeset
29
d488b72254fb bit-field done.
kono
parents:
diff changeset
30 union ll0 {
337
694cdf15c5bd MIPS bit-field done.
kono
parents: 336
diff changeset
31 unsigned char a[32];
336
d488b72254fb bit-field done.
kono
parents:
diff changeset
32 struct {
d488b72254fb bit-field done.
kono
parents:
diff changeset
33 char a:4;
d488b72254fb bit-field done.
kono
parents:
diff changeset
34 long long v:48;
d488b72254fb bit-field done.
kono
parents:
diff changeset
35 long long w:48;
d488b72254fb bit-field done.
kono
parents:
diff changeset
36 long long x:48;
d488b72254fb bit-field done.
kono
parents:
diff changeset
37 } b;
d488b72254fb bit-field done.
kono
parents:
diff changeset
38 } ll0;
d488b72254fb bit-field done.
kono
parents:
diff changeset
39
d488b72254fb bit-field done.
kono
parents:
diff changeset
40
d488b72254fb bit-field done.
kono
parents:
diff changeset
41 union ll {
337
694cdf15c5bd MIPS bit-field done.
kono
parents: 336
diff changeset
42 unsigned char a[32];
336
d488b72254fb bit-field done.
kono
parents:
diff changeset
43 struct {
d488b72254fb bit-field done.
kono
parents:
diff changeset
44 char a:4;
d488b72254fb bit-field done.
kono
parents:
diff changeset
45 long long v:56;
d488b72254fb bit-field done.
kono
parents:
diff changeset
46 long long w:56;
d488b72254fb bit-field done.
kono
parents:
diff changeset
47 long long x:56;
d488b72254fb bit-field done.
kono
parents:
diff changeset
48 } b;
d488b72254fb bit-field done.
kono
parents:
diff changeset
49 } ll;
d488b72254fb bit-field done.
kono
parents:
diff changeset
50
d488b72254fb bit-field done.
kono
parents:
diff changeset
51 union cc {
d488b72254fb bit-field done.
kono
parents:
diff changeset
52 int a;
d488b72254fb bit-field done.
kono
parents:
diff changeset
53 struct {
d488b72254fb bit-field done.
kono
parents:
diff changeset
54 char a:1;
d488b72254fb bit-field done.
kono
parents:
diff changeset
55 char b:4;
d488b72254fb bit-field done.
kono
parents:
diff changeset
56 char c:7;
d488b72254fb bit-field done.
kono
parents:
diff changeset
57 char d:4;
d488b72254fb bit-field done.
kono
parents:
diff changeset
58 char e:4;
d488b72254fb bit-field done.
kono
parents:
diff changeset
59 char f:4;
d488b72254fb bit-field done.
kono
parents:
diff changeset
60 } b;
d488b72254fb bit-field done.
kono
parents:
diff changeset
61 } cc;
d488b72254fb bit-field done.
kono
parents:
diff changeset
62
d488b72254fb bit-field done.
kono
parents:
diff changeset
63 union ii {
d488b72254fb bit-field done.
kono
parents:
diff changeset
64 int a;
d488b72254fb bit-field done.
kono
parents:
diff changeset
65 struct {
d488b72254fb bit-field done.
kono
parents:
diff changeset
66 int a:1;
d488b72254fb bit-field done.
kono
parents:
diff changeset
67 int b:4;
d488b72254fb bit-field done.
kono
parents:
diff changeset
68 int c:4;
d488b72254fb bit-field done.
kono
parents:
diff changeset
69 int d:4;
d488b72254fb bit-field done.
kono
parents:
diff changeset
70 int e:4;
d488b72254fb bit-field done.
kono
parents:
diff changeset
71 int f:4;
d488b72254fb bit-field done.
kono
parents:
diff changeset
72 } b;
d488b72254fb bit-field done.
kono
parents:
diff changeset
73 } ii;
d488b72254fb bit-field done.
kono
parents:
diff changeset
74
d488b72254fb bit-field done.
kono
parents:
diff changeset
75 main()
d488b72254fb bit-field done.
kono
parents:
diff changeset
76 {
337
694cdf15c5bd MIPS bit-field done.
kono
parents: 336
diff changeset
77 int i;
427
0c256ea2a97e Bitfield left value for ia32
kono
parents: 341
diff changeset
78 printf("#0077:%d\n",a.i);
336
d488b72254fb bit-field done.
kono
parents:
diff changeset
79
d488b72254fb bit-field done.
kono
parents:
diff changeset
80 ll1.b.v = -1;
427
0c256ea2a97e Bitfield left value for ia32
kono
parents: 341
diff changeset
81 printf("#0080:01:%llx\n",ll1.b.v);
0c256ea2a97e Bitfield left value for ia32
kono
parents: 341
diff changeset
82 printf("#0081:02:"); for(i=0;i<32;i++) printf("%02x",ll1.a[i]); printf("\n");
336
d488b72254fb bit-field done.
kono
parents:
diff changeset
83 ll1.b.v = 0;
d488b72254fb bit-field done.
kono
parents:
diff changeset
84 ll1.b.w = -1;
427
0c256ea2a97e Bitfield left value for ia32
kono
parents: 341
diff changeset
85 printf("#0084:02:"); for(i=0;i<32;i++) printf("%02x",ll1.a[i]); printf("\n");
336
d488b72254fb bit-field done.
kono
parents:
diff changeset
86 ll1.b.w = 0;
d488b72254fb bit-field done.
kono
parents:
diff changeset
87 ll1.b.x = -1;
427
0c256ea2a97e Bitfield left value for ia32
kono
parents: 341
diff changeset
88 printf("#0087:02:"); for(i=0;i<32;i++) printf("%02x",ll1.a[i]); printf("\n");
336
d488b72254fb bit-field done.
kono
parents:
diff changeset
89
d488b72254fb bit-field done.
kono
parents:
diff changeset
90 ll0.b.v = -1;
427
0c256ea2a97e Bitfield left value for ia32
kono
parents: 341
diff changeset
91 printf("#0090:01:%llx\n",ll0.b.v);
0c256ea2a97e Bitfield left value for ia32
kono
parents: 341
diff changeset
92 printf("#0091:02:"); for(i=0;i<32;i++) printf("%02x",ll0.a[i]); printf("\n");
336
d488b72254fb bit-field done.
kono
parents:
diff changeset
93 ll0.b.v = 0;
d488b72254fb bit-field done.
kono
parents:
diff changeset
94 ll0.b.w = -1;
427
0c256ea2a97e Bitfield left value for ia32
kono
parents: 341
diff changeset
95 printf("#0094:02:"); for(i=0;i<32;i++) printf("%02x",ll0.a[i]); printf("\n");
336
d488b72254fb bit-field done.
kono
parents:
diff changeset
96 ll0.b.w = 0;
d488b72254fb bit-field done.
kono
parents:
diff changeset
97 ll0.b.x = -1;
427
0c256ea2a97e Bitfield left value for ia32
kono
parents: 341
diff changeset
98 printf("#0097:02:"); for(i=0;i<32;i++) printf("%02x",ll0.a[i]); printf("\n");
336
d488b72254fb bit-field done.
kono
parents:
diff changeset
99
d488b72254fb bit-field done.
kono
parents:
diff changeset
100 ll.b.v = -1;
427
0c256ea2a97e Bitfield left value for ia32
kono
parents: 341
diff changeset
101 printf("#0100:1:%llx\n",ll.b.v);
0c256ea2a97e Bitfield left value for ia32
kono
parents: 341
diff changeset
102 printf("#0101:02:"); for(i=0;i<32;i++) printf("%02x",ll.a[i]); printf("\n");
336
d488b72254fb bit-field done.
kono
parents:
diff changeset
103 ll.b.v = 0;
d488b72254fb bit-field done.
kono
parents:
diff changeset
104 ll.b.w = -1;
427
0c256ea2a97e Bitfield left value for ia32
kono
parents: 341
diff changeset
105 printf("#0104:02:"); for(i=0;i<32;i++) printf("%02x",ll.a[i]); printf("\n");
336
d488b72254fb bit-field done.
kono
parents:
diff changeset
106 ll.b.w = 0;
d488b72254fb bit-field done.
kono
parents:
diff changeset
107 ll.b.x = -1;
427
0c256ea2a97e Bitfield left value for ia32
kono
parents: 341
diff changeset
108 printf("#0107:02:"); for(i=0;i<32;i++) printf("%02x",ll.a[i]); printf("\n");
336
d488b72254fb bit-field done.
kono
parents:
diff changeset
109
427
0c256ea2a97e Bitfield left value for ia32
kono
parents: 341
diff changeset
110 printf("#0109:char a:1; char b:4; char c:7; char d:4; char e:4; char f:4;\n");
336
d488b72254fb bit-field done.
kono
parents:
diff changeset
111 cc.b.a = -1;
427
0c256ea2a97e Bitfield left value for ia32
kono
parents: 341
diff changeset
112 printf("#0111:a:%08x\n",cc.a);
336
d488b72254fb bit-field done.
kono
parents:
diff changeset
113 cc.b.b = -1;
427
0c256ea2a97e Bitfield left value for ia32
kono
parents: 341
diff changeset
114 printf("#0113:b:%08x\n",cc.a);
336
d488b72254fb bit-field done.
kono
parents:
diff changeset
115 cc.b.c = -1;
427
0c256ea2a97e Bitfield left value for ia32
kono
parents: 341
diff changeset
116 printf("#0115:c:%08x\n",cc.a);
336
d488b72254fb bit-field done.
kono
parents:
diff changeset
117 cc.b.d = -1;
427
0c256ea2a97e Bitfield left value for ia32
kono
parents: 341
diff changeset
118 printf("#0117:d:%08x\n",cc.a);
336
d488b72254fb bit-field done.
kono
parents:
diff changeset
119 cc.b.e = -1;
427
0c256ea2a97e Bitfield left value for ia32
kono
parents: 341
diff changeset
120 printf("#0119:e:%08x\n",cc.a);
336
d488b72254fb bit-field done.
kono
parents:
diff changeset
121 cc.b.f = -1;
427
0c256ea2a97e Bitfield left value for ia32
kono
parents: 341
diff changeset
122 printf("#0121:f:%08x\n",cc.a);
0c256ea2a97e Bitfield left value for ia32
kono
parents: 341
diff changeset
123 printf("#0122:3:%d %d\n",cc.b.c,cc.b.d);
336
d488b72254fb bit-field done.
kono
parents:
diff changeset
124 cc.a = -1;
427
0c256ea2a97e Bitfield left value for ia32
kono
parents: 341
diff changeset
125 printf("#0124:f:%08x\n",cc.a);
336
d488b72254fb bit-field done.
kono
parents:
diff changeset
126 cc.b.a = 0;
427
0c256ea2a97e Bitfield left value for ia32
kono
parents: 341
diff changeset
127 printf("#0126:a:%08x\n",cc.a);
336
d488b72254fb bit-field done.
kono
parents:
diff changeset
128 cc.b.b = 0;
427
0c256ea2a97e Bitfield left value for ia32
kono
parents: 341
diff changeset
129 printf("#0128:b:%08x\n",cc.a);
336
d488b72254fb bit-field done.
kono
parents:
diff changeset
130 cc.b.c = 0;
427
0c256ea2a97e Bitfield left value for ia32
kono
parents: 341
diff changeset
131 printf("#0130:c:%08x\n",cc.a);
336
d488b72254fb bit-field done.
kono
parents:
diff changeset
132 cc.b.d = 0;
427
0c256ea2a97e Bitfield left value for ia32
kono
parents: 341
diff changeset
133 printf("#0132:d:%08x\n",cc.a);
336
d488b72254fb bit-field done.
kono
parents:
diff changeset
134 cc.b.e = 0;
427
0c256ea2a97e Bitfield left value for ia32
kono
parents: 341
diff changeset
135 printf("#0134:e:%08x\n",cc.a);
336
d488b72254fb bit-field done.
kono
parents:
diff changeset
136 cc.b.f = 0;
427
0c256ea2a97e Bitfield left value for ia32
kono
parents: 341
diff changeset
137 printf("#0136:f:%08x\n",cc.a);
0c256ea2a97e Bitfield left value for ia32
kono
parents: 341
diff changeset
138 printf("#0137:3:%d %d\n",cc.b.c,cc.b.d);
336
d488b72254fb bit-field done.
kono
parents:
diff changeset
139 cc.a = 0;
427
0c256ea2a97e Bitfield left value for ia32
kono
parents: 341
diff changeset
140 printf("#0139:f:%08x\n",cc.a);
336
d488b72254fb bit-field done.
kono
parents:
diff changeset
141 cc.b.a = 1;
427
0c256ea2a97e Bitfield left value for ia32
kono
parents: 341
diff changeset
142 printf("#0141:a:%08x\n",cc.a);
336
d488b72254fb bit-field done.
kono
parents:
diff changeset
143 cc.b.b = 1;
427
0c256ea2a97e Bitfield left value for ia32
kono
parents: 341
diff changeset
144 printf("#0143:b:%08x\n",cc.a);
336
d488b72254fb bit-field done.
kono
parents:
diff changeset
145 cc.b.c = 1;
427
0c256ea2a97e Bitfield left value for ia32
kono
parents: 341
diff changeset
146 printf("#0145:c:%08x\n",cc.a);
336
d488b72254fb bit-field done.
kono
parents:
diff changeset
147 cc.b.d = 1;
427
0c256ea2a97e Bitfield left value for ia32
kono
parents: 341
diff changeset
148 printf("#0147:d:%08x\n",cc.a);
336
d488b72254fb bit-field done.
kono
parents:
diff changeset
149 cc.b.e = 1;
427
0c256ea2a97e Bitfield left value for ia32
kono
parents: 341
diff changeset
150 printf("#0149:e:%08x\n",cc.a);
336
d488b72254fb bit-field done.
kono
parents:
diff changeset
151 cc.b.f = 1;
427
0c256ea2a97e Bitfield left value for ia32
kono
parents: 341
diff changeset
152 printf("#0151:f:%08x\n",cc.a);
0c256ea2a97e Bitfield left value for ia32
kono
parents: 341
diff changeset
153 printf("#0152:3:%d %d\n",cc.b.c,cc.b.d);
336
d488b72254fb bit-field done.
kono
parents:
diff changeset
154 cc.a = -1;
427
0c256ea2a97e Bitfield left value for ia32
kono
parents: 341
diff changeset
155 printf("#0154:f:%08x\n",cc.a);
336
d488b72254fb bit-field done.
kono
parents:
diff changeset
156 cc.b.a = 1;
427
0c256ea2a97e Bitfield left value for ia32
kono
parents: 341
diff changeset
157 printf("#0156:a:%08x\n",cc.a);
336
d488b72254fb bit-field done.
kono
parents:
diff changeset
158 cc.b.b = 1;
427
0c256ea2a97e Bitfield left value for ia32
kono
parents: 341
diff changeset
159 printf("#0158:b:%08x\n",cc.a);
336
d488b72254fb bit-field done.
kono
parents:
diff changeset
160 cc.b.c = 1;
427
0c256ea2a97e Bitfield left value for ia32
kono
parents: 341
diff changeset
161 printf("#0160:c:%08x\n",cc.a);
336
d488b72254fb bit-field done.
kono
parents:
diff changeset
162 cc.b.d = 1;
427
0c256ea2a97e Bitfield left value for ia32
kono
parents: 341
diff changeset
163 printf("#0162:d:%08x\n",cc.a);
336
d488b72254fb bit-field done.
kono
parents:
diff changeset
164 cc.b.e = 1;
427
0c256ea2a97e Bitfield left value for ia32
kono
parents: 341
diff changeset
165 printf("#0164:e:%08x\n",cc.a);
336
d488b72254fb bit-field done.
kono
parents:
diff changeset
166 cc.b.f = 1;
427
0c256ea2a97e Bitfield left value for ia32
kono
parents: 341
diff changeset
167 printf("#0166:f:%08x\n",cc.a);
0c256ea2a97e Bitfield left value for ia32
kono
parents: 341
diff changeset
168 printf("#0167:3:%d %d\n",cc.b.c,cc.b.d);
336
d488b72254fb bit-field done.
kono
parents:
diff changeset
169
d488b72254fb bit-field done.
kono
parents:
diff changeset
170 ii.b.a = -1;
427
0c256ea2a97e Bitfield left value for ia32
kono
parents: 341
diff changeset
171 printf("#0170:6:%08x\n",ii.a);
336
d488b72254fb bit-field done.
kono
parents:
diff changeset
172 ii.b.d = -1;
427
0c256ea2a97e Bitfield left value for ia32
kono
parents: 341
diff changeset
173 printf("#0172:6:%08x\n",ii.a);
0c256ea2a97e Bitfield left value for ia32
kono
parents: 341
diff changeset
174 printf("#0173:5:%d %d\n",ii.b.a,ii.b.d);
336
d488b72254fb bit-field done.
kono
parents:
diff changeset
175
d488b72254fb bit-field done.
kono
parents:
diff changeset
176 main5();
d488b72254fb bit-field done.
kono
parents:
diff changeset
177 return 0;
d488b72254fb bit-field done.
kono
parents:
diff changeset
178 }
d488b72254fb bit-field done.
kono
parents:
diff changeset
179
d488b72254fb bit-field done.
kono
parents:
diff changeset
180
d488b72254fb bit-field done.
kono
parents:
diff changeset
181 main5()
d488b72254fb bit-field done.
kono
parents:
diff changeset
182 {
d488b72254fb bit-field done.
kono
parents:
diff changeset
183 int i,j,bit=1;
d488b72254fb bit-field done.
kono
parents:
diff changeset
184 for(i=0;i<32;i++,bit<<=1) {
d488b72254fb bit-field done.
kono
parents:
diff changeset
185 ii.a = bit;
427
0c256ea2a97e Bitfield left value for ia32
kono
parents: 341
diff changeset
186 printf("#0185:%08x:ii.b.a=%d ii.b.b=%d ii.b.c=%d ii.b.d=%d ii.b.e=%d ii.b.f=%d\n",bit,
336
d488b72254fb bit-field done.
kono
parents:
diff changeset
187 ii.b.a,ii.b.b,ii.b.c,ii.b.d,ii.b.e,ii.b.f);
d488b72254fb bit-field done.
kono
parents:
diff changeset
188 }
d488b72254fb bit-field done.
kono
parents:
diff changeset
189 bit=1;
d488b72254fb bit-field done.
kono
parents:
diff changeset
190 for(i=0;i<32;i++,bit<<=1) {
d488b72254fb bit-field done.
kono
parents:
diff changeset
191 cc.a = bit;
427
0c256ea2a97e Bitfield left value for ia32
kono
parents: 341
diff changeset
192 printf("#0191:%08x:cc.b.a=%d cc.b.b=%d cc.b.c=%d cc.b.d=%d cc.b.e=%d cc.b.f=%d\n",bit,
336
d488b72254fb bit-field done.
kono
parents:
diff changeset
193 cc.b.a,cc.b.b,cc.b.c,cc.b.d,cc.b.e,cc.b.f);
d488b72254fb bit-field done.
kono
parents:
diff changeset
194 }
337
694cdf15c5bd MIPS bit-field done.
kono
parents: 336
diff changeset
195 ll.a[0]=ll.a[1]=ll.a[2]=ll.a[3]= ll.a[4]=ll.a[5]=ll.a[6]=ll.a[7]=0;
341
ca34f02b2056 ptr cache speed up
kono
parents: 337
diff changeset
196 ll.b.v=ll.b.w=ll.b.x = 0;
337
694cdf15c5bd MIPS bit-field done.
kono
parents: 336
diff changeset
197 for(i=7;i>=0;i--) {
336
d488b72254fb bit-field done.
kono
parents:
diff changeset
198 bit=1;
d488b72254fb bit-field done.
kono
parents:
diff changeset
199 for(j=0;j<32;j++,bit<<=1) {
d488b72254fb bit-field done.
kono
parents:
diff changeset
200 ll.a[i] = bit;
427
0c256ea2a97e Bitfield left value for ia32
kono
parents: 341
diff changeset
201 printf("#0200:02:%08x %08x %08x %08x %08x %08x %08x %08x\n",
336
d488b72254fb bit-field done.
kono
parents:
diff changeset
202 ll.a[0],ll.a[1],ll.a[2],ll.a[3],
d488b72254fb bit-field done.
kono
parents:
diff changeset
203 ll.a[4],ll.a[5],ll.a[6],ll.a[7]
d488b72254fb bit-field done.
kono
parents:
diff changeset
204 );
428
61c77ff18023 MIPS bitfield fix
kono
parents: 427
diff changeset
205 printf("#0204: ll.b.v=%lld ll.b.w=%lld ll.b.x=%lld\n",ll.b.v,ll.b.w,ll.b.x);
336
d488b72254fb bit-field done.
kono
parents:
diff changeset
206 }
337
694cdf15c5bd MIPS bit-field done.
kono
parents: 336
diff changeset
207 ll.a[i]=0;
336
d488b72254fb bit-field done.
kono
parents:
diff changeset
208 }
d488b72254fb bit-field done.
kono
parents:
diff changeset
209 }
d488b72254fb bit-field done.
kono
parents:
diff changeset
210