Path: utzoo!utgpu!water!watmath!clyde!rutgers!psuvax1!vu-vlsi!cbmvax!daveh From: daveh@cbmvax.UUCP (Dave Haynie) Newsgroups: comp.arch Subject: Re: RISC data alignment Message-ID: <3195@cbmvax.UUCP> Date: 25 Jan 88 18:03:43 GMT References: <2635@calmasd.GE.COM> Organization: Commodore Technology, West Chester, PA Lines: 48 in article <2635@calmasd.GE.COM>, gjo@calmasd.GE.COM (Glenn Olander) says: > Please forgive a possibly neophyte-type question, but is it true that > there may be an inherent incompatibility between RISC and conventional > machines? In particular, I believe that many RISC machines require data > to be aligned on a natural boundary, e.g. longwords must be referenced > on a 4-byte boundary. This requires compilers to make accomodations to > ensure that such alignment always occurs, even if it means padding a > data structure which contains mixed types of data, for example a C > structure with a mixture of shorts, longs, and doubles. This is already going on in some degree with non-RISC machines. For the 68000, for instance, short and long words must be accessed on word boundaries. The 68020 doesn't have this requirement, but it'll perform much faster if words are on word boundaries and longwords are on 4-byte boundaries. For at least the Lattice compiler I use (V4.0, Amiga OS), the compiler is normally using word alignment for non-byte objects, but has a switch to force longword alignment. I'm sure all 32 bit processors get a speed advantage with longword aligned items, it's just a matter of whether it's a requirement or not. With RISC type machines, such alignment being a requirement would certainly be in keeping with RISC's goal of hardware simplicity. > If this is true, then it would seem to also be true that a C structure > could have different lengths, depending on whether it was compiled > on a RISC or non-RISC machine. You'll already find these issues in going between non-RISC machines. So you should expect that they may show up in RISC vs. non-RISC. > Further, it would seem that > if that C structure were written out to a file, it could only be read > properly by a machine of the same type as that which wrote it. In many cases. This is especially true when going between machines with different CPU families. The file I write directly on my Amiga won't be directly readable on a VAX or an IBM PC, due to byte ordering as well as word alignment. It would probably be readable on a Macintosh or a Sun/3, providing their compilers make similar assumptions on data alignments. > Glenn Olander > GE Calma > gjo%calmasd.ge.com@sdcsvax.ucsd.edu -- Dave Haynie "The B2000 Guy" Commodore-Amiga "The Crew That Never Rests" {ihnp4|uunet|rutgers}!cbmvax!daveh PLINK: D-DAVE H BIX: hazy "I can't relax, 'cause I'm a Boinger!"