Path: utzoo!utgpu!watmath!clyde!att!osu-cis!tut.cis.ohio-state.edu!cwjcc!gatech!ncar!cruff From: cruff@ncar.ucar.edu (Craig Ruff) Newsgroups: comp.sys.m68k Subject: Re: Why does addq.w #n,sp work? Keywords: C asm addq Message-ID: <1100@ncar.ucar.edu> Date: 9 Dec 88 15:36:48 GMT References: <5005@bsu-cs.UUCP> <5460@cbmvax.UUCP> Reply-To: cruff@handies.UCAR.EDU (Craig Ruff) Distribution: na Organization: Scientific Computing Division/NCAR, Boulder CO Lines: 22 In article <5460@cbmvax.UUCP> ditto@cbmvax.UUCP (Michael "Ford" Ditto) writes: >In article <5005@bsu-cs.UUCP> jbwaters@bsu-cs.UUCP (J. Brian Waters) writes: >> What I do not understand is why it is not a addq.l #8,sp as I thought >>the sp was a 32 bit counter. Why does it use the addq.w form rather then >>the addq.l? > >Under "addq" in the 68020 manual: "When adding to address registers, >the entire destination address register is used, regardless of the >operation size." (It should be the same for any 68000-family CPU.) The other reason that everyone seemed to miss is that this method saves 2 bytes. If you think about it, this instruction is used commonly to pop arguments off the stack after a function call (for C). If you have many function calls, the savings can add up. Another method some compilers use is to just let the arguments build up on the stack for a while and pop a whole bunch off in one shot, saving even more instructions. -- Craig Ruff NCAR INTERNET: cruff@ncar.UCAR.EDU (303) 497-1211 P.O. Box 3000 CSNET: cruff@ncar.CSNET Boulder, CO 80307 UUCP: cruff@ncar.UUCP