Path: utzoo!attcan!uunet!husc6!bbn!rochester!pt.cs.cmu.edu!ius3.ius.cs.cmu.edu!ralphw From: ralphw@ius3.ius.cs.cmu.edu (Ralph Hyre) Newsgroups: comp.sys.m68k Subject: Re: quad-aligning the 68020 stack Keywords: 68020 stack longword alignment quad Message-ID: <2641@pt.cs.cmu.edu> Date: 8 Aug 88 21:30:43 GMT References: <2194@uhccux.uhcc.hawaii.edu> <4431@cbmvax.UUCP> <2727@winchester.mips.COM> <4434@cbmvax.UUCP> Sender: netnews@pt.cs.cmu.edu Organization: Carnegie-Mellon University, CS/RI Lines: 32 In article <4434@cbmvax.UUCP> ford@kenobi.cts.com (Mike "Ford" Ditto) writes: >One related subject that should be considered with the 64-bit chips in >mind, however, is that of alignment in portable data structures, i.e. >data files on disk or headers in network packets which will have to >be described and used on machines of various types and sizes. .... >What this all means, is that such structures should be *explicitly* >padded so that they will have a high probability of having the same >meaning on any machine. >if I write a program on my Z-80 (8-bit) system ... ...[Z-80 packed struct declaration ommitted] >It is impossible to declare or reference that structure type in a >reasonable way on a 68000. A wise programmer would have put a >one-byte pad field between a and b. I disagree. I'd rather pack my structs in the most reasonable way for that machine, and convert to a canonical representation (like that specified by SUN's XDR, for example) for the networked or other heterogenous environment. Even if the bits are all addressable, some machines have different byte orders (LSB or short in 'high' byte). In Sun's Unix, for example, you have the 'htonl' and various byte ordering macros and routines for working this all out. Someone will always come up with an archictecture that won't fit in with your packing scheme. If you find one that does happen to match, consider yourself lucky and enjoy the potential performance advantage. -- - Ralph W. Hyre, Jr. Internet: ralphw@ius2.cs.cmu.edu Phone:(412)268-{2847,3275} CMU-{BUGS,DARK} Amateur Packet Radio: N3FGW@W2XO, or c/o W3VC, CMU Radio Club, Pittsburgh, PA