Path: utzoo!utgpu!water!watmath!clyde!rutgers!husc6!bbn!kgregory From: kgregory@bbn.COM (Keith D. Gregory) Newsgroups: comp.lang.c Subject: Re: register unions Summary: Nope, and here's why Keywords: registers unions structures Message-ID: <6831@ccv.bbn.COM> Date: 13 Feb 88 18:44:03 GMT References: <1229@eneevax.UUCP> Reply-To: kgregory@ccv.bbn.com (Keith D. Gregory) Distribution: comp.lang.c Organization: Bolt Beranek and Newman Inc., Cambridge MA Lines: 32 In article <1229@eneevax.UUCP> noise@eneevax.umd.edu.UUCP (Johnson Noise) writes: > [code examples deleted] > >which would effectively allow full use of cpu registers. Note the >similarity to 68k assembly. Unfortunately, all the compilers I have >tried (including pcc) will not allocate unions in registers. My initial >suspicion is that most compilers simply do not allow anything other than >basic types to be allocated in registers. I realize that combining >pointers and non-pointers in 68k systems is not possible, but I don't >intend to do that. I don't see any immediate problems in allowing >such a declaration (with checks on 68k's). I think that the answer becomes apparent with some more code examples :-) struct mystruct { char field1, field2, field3, field4; }; union myunion { int field1; char field2[2]; }; The first example of course, would fail on the 68000 right away - you can't arbitrarily split a register into 4 bytes. The second is simply more of the same, and the key point is that structures and unions are manipulated using pointer arithmetic (to access the fields therein), and pointers to registers can not exist. -kdg