Path: utzoo!utgpu!attcan!uunet!husc6!cmcl2!rutgers!ucsd!nosc!humu!uhccux!mikem From: mikem@uhccux.uhcc.hawaii.edu (Mike Morton) Newsgroups: comp.sys.m68k Subject: quad-aligning the 68020 stack Keywords: 68020 alignment quad Message-ID: <2194@uhccux.uhcc.hawaii.edu> Date: 5 Aug 88 05:12:28 GMT Organization: University of Hawaii Lines: 26 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. /* To quad-align the stack, execute this in-line. Uses D0.w and leaves 2 or 4 bytes on the stack. */ move.w sp, d0 /* copy low bits to get alignment */ addq.w #2, d0 /* toggle quad-align bit (#1) */ and.w #2, d0 /* select just that bit */ sub.w d0, sp /* MIS-align the stack */ move.w d0, -(sp) /* then fix it and remember bias */ /* To restore the stack state, execute this in-line. */ add.w (sp)+, sp /* pop bias and un-bias */ Is alignment desirable? Is there a shorter way to do it? Comments? -- Mike Morton // P.O. Box 11378, Honolulu, HI 96828, (808) 456-8455 HST Internet: msm@ceta.ics.hawaii.edu (anagrams): Mr. Machine Tool; Ethical Mormon; Chosen Immortal; etc.