Path: utzoo!utgpu!water!watmath!clyde!bellcore!decvax!purdue!umd5!eneevax!noise From: noise@eneevax.UUCP (Johnson Noise) Newsgroups: comp.lang.c Subject: register unions Summary: Is it reasonable Keywords: registers, unions Message-ID: <1229@eneevax.UUCP> Date: 13 Feb 88 00:43:38 GMT Reply-To: noise@eneevax.umd.edu.UUCP (Johnson Noise) Distribution: comp.lang.c Organization: Elec. Eng. Dept., U of Maryland, College Park, MD 20742 Lines: 36 While testing the availaility of register variables on several machines and compilers, I thought of this possibility: typedef union { char b; short w; long l; } dreg; typedef union { char *b; short *w; long *l; } areg; register dreg d0, d1, d2; register areg a0, a1; 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). Has anyone else considered this possibility? Is there a compiler which allows this? If it were possible, one could almost write exact assembly in C. It probably is not neccessary for the most part, but it would further reduce the neccessity of assembly (not to mention tearing up benchmarks :-). Comments, flames? If there aren't any problems, I would like to incorporate these and other concepts into my copy of gcc.