Path: utzoo!utgpu!news-server.csri.toronto.edu!cs.utexas.edu!sun-barr!newstop!sun!joe.Eng.Sun.COM!petolino From: petolino@joe.Eng.Sun.COM (Joe Petolino) Newsgroups: comp.arch Subject: Re: What *should* architectural pointers point at? Message-ID: <141598@sun.Eng.Sun.COM> Date: 30 Aug 90 20:28:14 GMT References: <0887@sheol.UUCP> <41167@mips.mips.COM> Sender: news@sun.Eng.Sun.COM Organization: Sun Microsystems, Mt. View, Ca. Lines: 35 >>You could provide two variants of the load/store instructions, one set >>that trap on unaligned accesses and one set that don't (but are possibly >>much slower). Although you don't say so, I assume that the slower variants would actually give the right results. Remember that there are architectures out there that neither trap nor work correctly when presented with unaligned addresses. >> This latter instruction replaces the specialized >>"bit-field" instructions that some machines have now. Compilers could >>have an option to generate only the slow-but-safe instructions for the >>benefit of fast-but-reckless programmers. I've heard of at least one >>architecture (SPARC?) that uses this approach. No, SPARC doesn't do this, and I'd be surprised if any other architecture did. See answer to next question. However, I think there is a SPARC compiler option to do unaligned loads and stores using software emulation. This is of course very slow. >Why much slower? At most two items would have to be loaded, and a shift >made. The main reason not to allow unaligned accesses is that supporting unaligned accesses greatly increases the *complexity* of the memory system in a machine with virtual addressing and caches. Speed is probably not an issue - in the implementations I've seen (various IBM 370 implementations), you only pay a speed penalty if you actually use an unaliged address. If you did implement instructions that work with unaligned addresses, there would be little reason to also implement the trap-on-unaligned variants - the complexity has to be there anyway. As an example of the kind of complexity that arises with support for unaligned accesses, imagine a store that spans a virtual page boundary, and only one of the pages is write-protected. -Joe