Path: utzoo!attcan!uunet!cs.utexas.edu!uwm.edu!lll-winken!sun-barr!newstop!sun!jputnam From: jputnam@raptor.Eng.Sun.COM (James M. Putnam) Newsgroups: comp.arch Subject: Re: Is handling off-alignment important? Message-ID: <140356@sun.Eng.Sun.COM> Date: 8 Aug 90 16:56:51 GMT References: <104037@convex.convex.com> <8840014@hpfcso.HP.COM> <2357@crdos1.crd.ge.COM> <25900@mimsy.umd.edu> <2392@crdos1.crd.ge.COM> Sender: news@sun.Eng.Sun.COM Organization: Sun Microsystems, Mt. View, Ca. Lines: 37 Roland McGrath (in , I think) writes: >On machines that "don't handle misaligned accesses", what do they do when one >happens anyway? Assuming they don't just go up in a puff of blue smoke (which >would be alright with me, as long as the color of smoke is documented), or >cease functioning and need to be power-cycled (which would be alright too, if >documented), the least useful thing I can think of for them to do (within the >bounds of reason) is to do the access wrong (which seems likely since if they >want the low-order two bits of the address to always be zero, they might well >not pay attention to them). Is this what is done? The VAX does this for quad word loads. VAX LISP takes advantage of this feature to get two free tag bits on LISP pointers that don't need to be masked before being dereferenced. Seems useful to me. >The second least useful thing I can think of is to cause a hardware trap to >software, which would presumably be horrendously slow. I would be completely >happy with that. I'd like this behavior to be defined by the user process. Perhaps as a signal? Seems similar to SIGBUS. Anyway, set a bit someplace so you trap or not, based on what kind of process you are. You probably always want to take the trap in system mode, and panic (at least in UN*X) since it indicates a bug of some kind. >Write a software trap handler to deal with it, and write your compiler such >that it never happens if avoidable. If your compiler is doing the right thing, the only time you'll take an interrupt is if your code is buggy. This sort of thing can be caught statically by lint, but there may be some situations in which dynamic behaviour can produce the same event, like in programs that generate their own code. Interesting idea. Jim