Path: utzoo!mnetor!uunet!seismo!sundc!pitstop!sun!amdcad!ames!hao!gatech!mcnc!rti!mcm From: mcm@rti.UUCP (Mike Mitchell) Newsgroups: comp.arch Subject: Re: RISC data alignment Message-ID: <2047@rti.UUCP> Date: 18 Feb 88 20:29:58 GMT References: <2635@calmasd.GE.COM> <28200092@ccvaxa> <496@ecrcvax.UUCP> <3001@bloom-beacon.MIT.EDU> Reply-To: mcm@rti.UUCP (Mike Mitchell) Organization: Research Triangle Institute, RTP, NC Lines: 22 I have written device drivers where I created a structure to hold the memory-mapped status registers. Some of the hardware had very strange memory alignments, and if the structure elements were changed, the driver would break. For example, a structure to reference a serial port might look something like: struct ttport { short t_tbaud; /* xmit baud rate */ char t_txt; /* transmitted character */ short t_rbaud; /* recv baud rate */ char t_rec; /* received character */ } *csr = 0xFF8000; /* address of device */ It would be more correct if a one byte pad were explicity put in after the "char t_txt", but I think my point is still valid. There are some cases where the order of the structure elements cannot be changed. -- Mike Mitchell {decvax,seismo,ihnp4,philabs}!mcnc!rti!mcm mcm@rti.rti.org "There's laughter where I used to see a tear. w (919) 541-6098 It's all done with mirrors, have no fear." h (919) 361-2048