Mercurial > hg > CbC > old > device
view test/bitfield1.c @ 417:98888da30b35
code jump fixes (not finished)
author | kono |
---|---|
date | Mon, 25 Oct 2004 01:16:28 +0900 |
parents | ca34f02b2056 |
children | 0c256ea2a97e |
line wrap: on
line source
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; main() { int i; printf("%d\n",a.i); ll1.b.v = -1; printf("01:%llx\n",ll1.b.v); printf("02:"); for(i=0;i<32;i++) printf("%02x",ll1.a[i]); printf("\n"); ll1.b.v = 0; ll1.b.w = -1; printf("02:"); for(i=0;i<32;i++) printf("%02x",ll1.a[i]); printf("\n"); ll1.b.w = 0; ll1.b.x = -1; printf("02:"); for(i=0;i<32;i++) printf("%02x",ll1.a[i]); printf("\n"); ll0.b.v = -1; printf("01:%llx\n",ll0.b.v); printf("02:"); for(i=0;i<32;i++) printf("%02x",ll0.a[i]); printf("\n"); ll0.b.v = 0; ll0.b.w = -1; printf("02:"); for(i=0;i<32;i++) printf("%02x",ll0.a[i]); printf("\n"); ll0.b.w = 0; ll0.b.x = -1; printf("02:"); for(i=0;i<32;i++) printf("%02x",ll0.a[i]); printf("\n"); ll.b.v = -1; printf("1:%llx\n",ll.b.v); printf("02:"); for(i=0;i<32;i++) printf("%02x",ll.a[i]); printf("\n"); ll.b.v = 0; ll.b.w = -1; printf("02:"); for(i=0;i<32;i++) printf("%02x",ll.a[i]); printf("\n"); ll.b.w = 0; ll.b.x = -1; printf("02:"); for(i=0;i<32;i++) printf("%02x",ll.a[i]); printf("\n"); printf("char a:1; char b:4; char c:7; char d:4; char e:4; char f:4;\n"); cc.b.a = -1; printf("a:%08x\n",cc.a); cc.b.b = -1; printf("b:%08x\n",cc.a); cc.b.c = -1; printf("c:%08x\n",cc.a); cc.b.d = -1; printf("d:%08x\n",cc.a); cc.b.e = -1; printf("e:%08x\n",cc.a); cc.b.f = -1; printf("f:%08x\n",cc.a); printf("3:%d %d\n",cc.b.c,cc.b.d); cc.a = -1; printf("f:%08x\n",cc.a); cc.b.a = 0; printf("a:%08x\n",cc.a); cc.b.b = 0; printf("b:%08x\n",cc.a); cc.b.c = 0; printf("c:%08x\n",cc.a); cc.b.d = 0; printf("d:%08x\n",cc.a); cc.b.e = 0; printf("e:%08x\n",cc.a); cc.b.f = 0; printf("f:%08x\n",cc.a); printf("3:%d %d\n",cc.b.c,cc.b.d); cc.a = 0; printf("f:%08x\n",cc.a); cc.b.a = 1; printf("a:%08x\n",cc.a); cc.b.b = 1; printf("b:%08x\n",cc.a); cc.b.c = 1; printf("c:%08x\n",cc.a); cc.b.d = 1; printf("d:%08x\n",cc.a); cc.b.e = 1; printf("e:%08x\n",cc.a); cc.b.f = 1; printf("f:%08x\n",cc.a); printf("3:%d %d\n",cc.b.c,cc.b.d); cc.a = -1; printf("f:%08x\n",cc.a); cc.b.a = 1; printf("a:%08x\n",cc.a); cc.b.b = 1; printf("b:%08x\n",cc.a); cc.b.c = 1; printf("c:%08x\n",cc.a); cc.b.d = 1; printf("d:%08x\n",cc.a); cc.b.e = 1; printf("e:%08x\n",cc.a); cc.b.f = 1; printf("f:%08x\n",cc.a); printf("3:%d %d\n",cc.b.c,cc.b.d); ii.b.a = -1; printf("6:%08x\n",ii.a); ii.b.d = -1; printf("6:%08x\n",ii.a); printf("5:%d %d\n",ii.b.a,ii.b.d); main5(); return 0; } main5() { int i,j,bit=1; for(i=0;i<32;i++,bit<<=1) { ii.a = bit; printf("%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("%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("02:%08x %08x %08x %08x %08x %08x %08x %08x\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(" ll.b.v=%d ll.b.w=%d ll.b.x=%d\n",ll.b.v,ll.b.w,ll.b.x); } ll.a[i]=0; } }