Path: utzoo!attcan!uunet!lll-winken!lll-tis!helios.ee.lbl.gov!nosc!ucsd!rutgers!bellcore!tness7!ninja!dalsqnt!rpp386!pigs!haugj From: haugj@pigs.UUCP (Joe Bob Willie) Newsgroups: comp.sys.m68k Subject: Re: quad-aligning the 68020 stack Summary: very simple alignment included Keywords: 68020 alignment quad Message-ID: <214@pigs.UUCP> Date: 8 Aug 88 19:30:58 GMT References: <2194@uhccux.uhcc.hawaii.edu> Reply-To: haugj@pigs.UUCP (Joe Bob Willie) Organization: Big "D" Oil and Gas Lines: 36 In article <2194@uhccux.uhcc.hawaii.edu> mikem@uhccux.uhcc.hawaii.edu (Mike Morton) writes: > >Maybe this is old hat to all you '020 hackers, but I've been wondering about >aligning stack frames on four-byte boundaries. I assume that in certain >critical situations, you should make sure your local variables are aligned >for speed. > >Is there a standard way to do this? I'll post these code fragments, in >hopes of getting someone to post something better. These are tested on a >68000, since that's all I have. [ long winded example deleted ] real simple: to align the stack on entry: link #0,a6 | set up your frame pointer like always ;-) move.l sp,d0 | copy sp to scratch register and.l #2,d0 | lop off low to bits (mod 4 alignment) move.l d0,a0 | restore sp with now-aligned version to unalign the stack on exit: unlk a6 | restore stack pointer to value on entry >Is alignment desirable? Is there a shorter way to do it? Comments? yes, alignment is desirable on the 68020 and 030. there is no point in doing 4 byte alignment on the 68000 or 010, and anything other than 2 byte alignment causes bus errors. see my method for a definition of `short', i believe you can't get any shorter since the and instruction won't take an address register as an operand (will it on the 020? 030?) -- jfh@rpp386.uucp (The Beach Bum at The Big "D" Home for Wayward Hackers) "Never attribute to malice what is adequately explained by stupidity" -- Hanlon's Razor