Path: utzoo!mnetor!uunet!lll-winken!lll-lcc!ames!ucsd!sdcsvax!ucsdhub!hp-sdd!hplabs!hpda!hpdslab!hpiacla!scottg From: scottg@hpiacla.HP.COM (Scott Gulland) Newsgroups: comp.arch Subject: Re: RISC is a nasty no-no! Message-ID: <4900002@hpiacla.HP.COM> Date: 1 Mar 88 16:23:56 GMT References: <179@wsccs.UUCP> Organization: Hewlett Packard Lines: 29 > / hpiacla:comp.arch / terry@wsccs.UUCP (terry) / 8:08 pm Feb 22, 1988 / > > THE REASON: Type-casting. You can't. Small programs seem to, but it doesn't > work. Bytes tend to be word aligned. Other messy stuff. . . . > > . . . , but sufficiently varied to allow me to go > off and have the assembler impliment enough macro's that my compiler thinks > it's running on a 680x0. ----Oh rats! If I can't have that, at LEAST my > portable C compiler should be. Sun must have some good people to be able > to have ported a semblance of UNIX to this thing. I think that what you have run into is porting from a machine with very loose data alignment requirements to one with very strict data alignment requirements, probably in combination with a marginal compiler. The 680x0 and 286/386 class of machines have very loose data alignment requirements. Integers, floats, pointers can be placed on any byte address boundry and still work. Risc machines however, may require integers, floats, pointers, etc to be placed on a 4-byte address, doubles on a 8-byte address, etc. If you then take a short and type cast it to a float or int, there is a 50% chance that the data does not sit on the correct byte address boundary, and so your program aborts. This can also happen if the C compiler does not insure correct data alignment within structures and unions. ************************************************************************** * Scott Gulland | {ucbvax,hplabs}!hpda!hpiacla!scottg [UUCP] * * Indus. Appl. Center (IAC) | scottg@hpiacla [SMTP] * * Hewlett-Packard Co. | (408) 746-5498 [AT&T] * * 1266 Kifer Road | 1-746-5498 [HP-TELNET] * * Sunnyvale, CA 94086 USA | "What If..." [HP-TELEPATHY] * **************************************************************************