Mercurial > hg > CbC > old > device
view test/bitfield1.c @ 874:3454953b3df0
fix inline strinit not yet worked.
author | Shinji KONO <kono@ie.u-ryukyu.ac.jp> |
---|---|
date | Tue, 01 Apr 2014 23:25:05 +0900 |
parents | 9598ecec0af5 |
children | 5313ed059cee |
line wrap: on
line source
int printf(const char *format, ...); typedef long long unsigned LLU; #ifndef INLINE #define INLINE #endif struct aho { int i:1,j:1; char a:7; char :7,k:1,:3; long long v:33; long long w:33; long long x:33; } a /* = {-1,3,3,3,3} */ ; union aho1 { int i:1,j:1; char a:7; char :7,k:1,:3; long long v:33; long long w:33; long long x:33; } a11 ; union ll1 { unsigned char a[32]; struct { char a:4; long long v:33; long long w:33; long long x:33; } b; } ll1; union ll0 { unsigned char a[32]; struct { char a:4; long long v:48; long long w:48; long long x:48; } b; } ll0; union ll { unsigned char a[32]; struct { char a:4; long long v:56; long long w:56; long long x:56; } b; } ll; union cc { int a; struct { char a:1; char b:4; char c:7; char d:4; char e:4; char f:4; } b; } cc; union ii { int a; struct { int a:1; int b:4; int c:4; int d:4; int e:4; int f:4; } b; } ii; void main5(); INLINE int main1() { int i; printf("#0083:%d\n",a.i); ll1.b.v = -1; printf("#0086:01:%llx\n",(LLU)ll1.b.v); printf("#0087:02:"); for(i=0;i<32;i++) printf("#0082:%02x",ll1.a[i]); printf("#0082:\n"); ll1.b.v = 0; ll1.b.w = -1; printf("#0090:02:"); for(i=0;i<32;i++) printf("#0085:%02x",ll1.a[i]); printf("#0085:\n"); ll1.b.w = 0; ll1.b.x = -1; printf("#0093:02:"); for(i=0;i<32;i++) printf("#0088:%02x",ll1.a[i]); printf("#0088:\n"); ll0.b.v = -1; printf("#0096:01:%llx\n",(LLU)ll0.b.v); printf("#0097:02:"); for(i=0;i<32;i++) printf("#0092:%02x",ll0.a[i]); printf("#0092:\n"); ll0.b.v = 0; ll0.b.w = -1; printf("#0100:02:"); for(i=0;i<32;i++) printf("#0095:%02x",ll0.a[i]); printf("#0095:\n"); ll0.b.w = 0; ll0.b.x = -1; printf("#0103:02:"); for(i=0;i<32;i++) printf("#0098:%02x",ll0.a[i]); printf("#0098:\n"); ll.b.v = -1; printf("#0106:1:%llx\n",(LLU)ll.b.v); printf("#0107:02:"); for(i=0;i<32;i++) printf("#0102:%02x",ll.a[i]); printf("#0102:\n"); ll.b.v = 0; ll.b.w = -1; printf("#0110:02:"); for(i=0;i<32;i++) printf("#0105:%02x",ll.a[i]); printf("#0105:\n"); ll.b.w = 0; ll.b.x = -1; printf("#0113:02:"); for(i=0;i<32;i++) printf("#0108:%02x",ll.a[i]); printf("#0108:\n"); printf("#0115:char a:1; char b:4; char c:7; char d:4; char e:4; char f:4;\n"); cc.b.a = -1; printf("#0117:a:%08x\n",cc.a); cc.b.b = -1; printf("#0119:b:%08x\n",cc.a); cc.b.c = -1; printf("#0121:c:%08x\n",cc.a); cc.b.d = -1; printf("#0123:d:%08x\n",cc.a); cc.b.e = -1; printf("#0125:e:%08x\n",cc.a); cc.b.f = -1; printf("#0127:f:%08x\n",cc.a); printf("#0128:3:%d %d\n",cc.b.c,cc.b.d); cc.a = -1; printf("#0130:f:%08x\n",cc.a); cc.b.a = 0; printf("#0132:a:%08x\n",cc.a); cc.b.b = 0; printf("#0134:b:%08x\n",cc.a); cc.b.c = 0; printf("#0136:c:%08x\n",cc.a); cc.b.d = 0; printf("#0138:d:%08x\n",cc.a); cc.b.e = 0; printf("#0140:e:%08x\n",cc.a); cc.b.f = 0; printf("#0142:f:%08x\n",cc.a); printf("#0143:3:%d %d\n",cc.b.c,cc.b.d); cc.a = 0; printf("#0145:f:%08x\n",cc.a); cc.b.a = 1; printf("#0147:a:%08x\n",cc.a); cc.b.b = 1; printf("#0149:b:%08x\n",cc.a); cc.b.c = 1; printf("#0151:c:%08x\n",cc.a); cc.b.d = 1; printf("#0153:d:%08x\n",cc.a); cc.b.e = 1; printf("#0155:e:%08x\n",cc.a); cc.b.f = 1; printf("#0157:f:%08x\n",cc.a); printf("#0158:3:%d %d\n",cc.b.c,cc.b.d); cc.a = -1; printf("#0160:f:%08x\n",cc.a); cc.b.a = 1; printf("#0162:a:%08x\n",cc.a); cc.b.b = 1; printf("#0164:b:%08x\n",cc.a); cc.b.c = 1; printf("#0166:c:%08x\n",cc.a); cc.b.d = 1; printf("#0168:d:%08x\n",cc.a); cc.b.e = 1; printf("#0170:e:%08x\n",cc.a); cc.b.f = 1; printf("#0172:f:%08x\n",cc.a); printf("#0173:3:%d %d\n",cc.b.c,cc.b.d); ii.b.a = -1; printf("#0176:6:%08x\n",ii.a); ii.b.d = -1; printf("#0178:6:%08x\n",ii.a); printf("#0179:5:%d %d\n",ii.b.a,ii.b.d); main5(); return 0; } INLINE // too late void main5() { int i,j,bit=1; for(i=0;i<32;i++,bit<<=1) { ii.a = bit; printf("#0191:%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, ii.b.a,ii.b.b,ii.b.c,ii.b.d,ii.b.e,ii.b.f); } bit=1; for(i=0;i<32;i++,bit<<=1) { cc.a = bit; printf("#0197:%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, cc.b.a,cc.b.b,cc.b.c,cc.b.d,cc.b.e,cc.b.f); } 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; ll.b.v=ll.b.w=ll.b.x = 0; for(i=7;i>=0;i--) { bit=1; for(j=0;j<32;j++,bit<<=1) { ll.a[i] = bit; printf("#0206:02:%02x %02x %02x %02x %02x %02x %02x %02x\n", ll.a[0],ll.a[1],ll.a[2],ll.a[3], ll.a[4],ll.a[5],ll.a[6],ll.a[7] ); printf("#0210: ll.b.v=%lld ll.b.w=%lld ll.b.x=%lld\n",(LLU)ll.b.v,(LLU)ll.b.w,(LLU)ll.b.x); } ll.a[i]=0; } } int main() { main1(); return 0; }